From e5833b01d10f666653e927398010a99347947df6 Mon Sep 17 00:00:00 2001 From: MUI bot <2109932+Janpot@users.noreply.github.com> Date: Thu, 1 Feb 2024 14:47:06 +0100 Subject: [PATCH] Docs config --- docs/config.d.ts | 8 +---- docs/config.js | 30 +------------------ docs/src/modules/components/AppSearch.js | 2 +- docs/src/modules/components/Head.tsx | 2 +- docs/src/modules/utils/helpers.ts | 2 +- .../baseUi/projectSettings.ts | 2 +- .../joyUi/projectSettings.ts | 2 +- .../materialUi/projectSettings.ts | 2 +- .../muiSystem/projectSettings.ts | 2 +- packages/api-docs-builder-core/package.json | 1 + packages/mui-docs/src/config/index.d.ts | 7 +++++ packages/mui-docs/src/config/index.js | 29 ++++++++++++++++++ pnpm-lock.yaml | 3 ++ 13 files changed, 49 insertions(+), 43 deletions(-) create mode 100644 packages/mui-docs/src/config/index.d.ts create mode 100644 packages/mui-docs/src/config/index.js diff --git a/docs/config.d.ts b/docs/config.d.ts index 605606f1179e10..84c6e6a0ccb163 100644 --- a/docs/config.d.ts +++ b/docs/config.d.ts @@ -1,7 +1 @@ -export const LANGUAGES: string[]; - -export const LANGUAGES_SSR: string[]; - -export const LANGUAGES_IN_PROGRESS: string[]; - -export const LANGUAGES_IGNORE_PAGES: (pathname: string) => boolean; +export * from '@mui/docs/config'; diff --git a/docs/config.js b/docs/config.js index 3dfdb2d1a01e72..4c56bb4807cfa0 100644 --- a/docs/config.js +++ b/docs/config.js @@ -1,29 +1 @@ -// Valid languages to server-side render in production -const LANGUAGES = ['en']; - -// Server side rendered languages -const LANGUAGES_SSR = ['en']; - -// Work in progress -const LANGUAGES_IN_PROGRESS = LANGUAGES.slice(); - -const LANGUAGES_IGNORE_PAGES = (pathname) => { - // We don't have the bandwidth like Qt to translate our blog posts - // https://www.qt.io/zh-cn/blog - if (pathname === '/blog' || pathname.startsWith('/blog/')) { - return true; - } - - if (pathname === '/size-snapshot/') { - return true; - } - - return false; -}; - -module.exports = { - LANGUAGES, - LANGUAGES_IN_PROGRESS, - LANGUAGES_SSR, - LANGUAGES_IGNORE_PAGES, -}; +module.exports = require('@mui/docs/config'); diff --git a/docs/src/modules/components/AppSearch.js b/docs/src/modules/components/AppSearch.js index f6da0f050af680..0bd93acc59e02c 100644 --- a/docs/src/modules/components/AppSearch.js +++ b/docs/src/modules/components/AppSearch.js @@ -22,7 +22,7 @@ import NewspaperRoundedIcon from '@mui/icons-material/NewspaperRounded'; import GlobalStyles from '@mui/material/GlobalStyles'; import { alpha, styled } from '@mui/material/styles'; import { pathnameToLanguage } from 'docs/src/modules/utils/helpers'; -import { LANGUAGES_SSR } from 'docs/config'; +import { LANGUAGES_SSR } from '@mui/docs/config'; import Link from 'docs/src/modules/components/Link'; import { useTranslate, useUserLanguage } from '@mui/docs/i18n'; import useLazyCSS from 'docs/src/modules/utils/useLazyCSS'; diff --git a/docs/src/modules/components/Head.tsx b/docs/src/modules/components/Head.tsx index 7366a2ce2fd8ff..914b692039feae 100644 --- a/docs/src/modules/components/Head.tsx +++ b/docs/src/modules/components/Head.tsx @@ -1,7 +1,7 @@ import * as React from 'react'; import NextHead from 'next/head'; import { useRouter } from 'next/router'; -import { LANGUAGES_SSR } from 'docs/config'; +import { LANGUAGES_SSR } from '@mui/docs/config'; import { useUserLanguage, useTranslate } from '@mui/docs/i18n'; import { pathnameToLanguage } from 'docs/src/modules/utils/helpers'; diff --git a/docs/src/modules/utils/helpers.ts b/docs/src/modules/utils/helpers.ts index d15cd5695a0c5c..3e6f1fd7950275 100644 --- a/docs/src/modules/utils/helpers.ts +++ b/docs/src/modules/utils/helpers.ts @@ -1,6 +1,6 @@ import upperFirst from 'lodash/upperFirst'; import camelCase from 'lodash/camelCase'; -import { LANGUAGES } from 'docs/config'; +import { LANGUAGES } from '@mui/docs/config'; function pascalCase(str: string) { return upperFirst(camelCase(str)); diff --git a/packages/api-docs-builder-core/baseUi/projectSettings.ts b/packages/api-docs-builder-core/baseUi/projectSettings.ts index b9b64d42adc3c4..84c78f81928806 100644 --- a/packages/api-docs-builder-core/baseUi/projectSettings.ts +++ b/packages/api-docs-builder-core/baseUi/projectSettings.ts @@ -1,5 +1,5 @@ import path from 'path'; -import { LANGUAGES } from 'docs/config'; +import { LANGUAGES } from '@mui/docs/config'; import { ProjectSettings } from '@mui-internal/api-docs-builder'; import findApiPages from '@mui-internal/api-docs-builder/utils/findApiPages'; import { diff --git a/packages/api-docs-builder-core/joyUi/projectSettings.ts b/packages/api-docs-builder-core/joyUi/projectSettings.ts index 5162b1879cabb5..8415ca5f343176 100644 --- a/packages/api-docs-builder-core/joyUi/projectSettings.ts +++ b/packages/api-docs-builder-core/joyUi/projectSettings.ts @@ -1,5 +1,5 @@ import path from 'path'; -import { LANGUAGES } from 'docs/config'; +import { LANGUAGES } from '@mui/docs/config'; import { ProjectSettings } from '@mui-internal/api-docs-builder'; import findApiPages from '@mui-internal/api-docs-builder/utils/findApiPages'; import { diff --git a/packages/api-docs-builder-core/materialUi/projectSettings.ts b/packages/api-docs-builder-core/materialUi/projectSettings.ts index c3d87f07b44ee7..a7793343bf8e9d 100644 --- a/packages/api-docs-builder-core/materialUi/projectSettings.ts +++ b/packages/api-docs-builder-core/materialUi/projectSettings.ts @@ -1,5 +1,5 @@ import path from 'path'; -import { LANGUAGES } from 'docs/config'; +import { LANGUAGES } from '@mui/docs/config'; import { ProjectSettings } from '@mui-internal/api-docs-builder'; import findApiPages from '@mui-internal/api-docs-builder/utils/findApiPages'; import { diff --git a/packages/api-docs-builder-core/muiSystem/projectSettings.ts b/packages/api-docs-builder-core/muiSystem/projectSettings.ts index e9d8a4d7fa8c18..9cfc8b60627d9d 100644 --- a/packages/api-docs-builder-core/muiSystem/projectSettings.ts +++ b/packages/api-docs-builder-core/muiSystem/projectSettings.ts @@ -1,5 +1,5 @@ import path from 'path'; -import { LANGUAGES } from 'docs/config'; +import { LANGUAGES } from '@mui/docs/config'; import { ProjectSettings } from '@mui-internal/api-docs-builder'; import findApiPages from '@mui-internal/api-docs-builder/utils/findApiPages'; import { diff --git a/packages/api-docs-builder-core/package.json b/packages/api-docs-builder-core/package.json index 10e52caf15cd44..90203508065035 100644 --- a/packages/api-docs-builder-core/package.json +++ b/packages/api-docs-builder-core/package.json @@ -9,6 +9,7 @@ "typescript": "tsc -p tsconfig.json" }, "dependencies": { + "@mui/docs": "workspace:^", "@mui-internal/api-docs-builder": "workspace:^", "@mui/markdown": "workspace:^", "docs": "workspace:^", diff --git a/packages/mui-docs/src/config/index.d.ts b/packages/mui-docs/src/config/index.d.ts new file mode 100644 index 00000000000000..605606f1179e10 --- /dev/null +++ b/packages/mui-docs/src/config/index.d.ts @@ -0,0 +1,7 @@ +export const LANGUAGES: string[]; + +export const LANGUAGES_SSR: string[]; + +export const LANGUAGES_IN_PROGRESS: string[]; + +export const LANGUAGES_IGNORE_PAGES: (pathname: string) => boolean; diff --git a/packages/mui-docs/src/config/index.js b/packages/mui-docs/src/config/index.js new file mode 100644 index 00000000000000..3dfdb2d1a01e72 --- /dev/null +++ b/packages/mui-docs/src/config/index.js @@ -0,0 +1,29 @@ +// Valid languages to server-side render in production +const LANGUAGES = ['en']; + +// Server side rendered languages +const LANGUAGES_SSR = ['en']; + +// Work in progress +const LANGUAGES_IN_PROGRESS = LANGUAGES.slice(); + +const LANGUAGES_IGNORE_PAGES = (pathname) => { + // We don't have the bandwidth like Qt to translate our blog posts + // https://www.qt.io/zh-cn/blog + if (pathname === '/blog' || pathname.startsWith('/blog/')) { + return true; + } + + if (pathname === '/size-snapshot/') { + return true; + } + + return false; +}; + +module.exports = { + LANGUAGES, + LANGUAGES_IN_PROGRESS, + LANGUAGES_SSR, + LANGUAGES_IGNORE_PAGES, +}; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 74f330de56f3eb..949ad73bc1f96f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -993,6 +993,9 @@ importers: '@mui-internal/api-docs-builder': specifier: workspace:^ version: link:../api-docs-builder + '@mui/docs': + specifier: workspace:^ + version: link:../mui-docs/build '@mui/markdown': specifier: workspace:^ version: link:../markdown