diff --git a/.prettierignore b/.prettierignore index d6e837be0c..c8fba6db4c 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,4 +1,3 @@ -__fixtures__ dist node_modules build diff --git a/v2-website/docusaurus.config.js b/v2-website/docusaurus.config.js index 3dff09bf52..7a5fbc6d82 100644 --- a/v2-website/docusaurus.config.js +++ b/v2-website/docusaurus.config.js @@ -37,5 +37,8 @@ module.exports = { path: '../v1/website/blog', }, }, + { + name: 'docusaurus-plugin-content-pages', + }, ], }; diff --git a/v2/lib/load/index.js b/v2/lib/load/index.js index 717b8b9f94..d64fc47918 100644 --- a/v2/lib/load/index.js +++ b/v2/lib/load/index.js @@ -11,7 +11,6 @@ const path = require('path'); const loadConfig = require('./config'); const loadDocs = require('./docs'); const loadEnv = require('./env'); -const loadPages = require('./pages'); const loadTheme = require('./theme'); const {generate} = require('./utils'); const loadRoutes = require('./routes'); @@ -71,25 +70,16 @@ module.exports = async function load(siteDir) { }, ); - // Pages. - const pagesDir = path.resolve(siteDir, 'pages'); - const pagesMetadatas = await loadPages({pagesDir, env, siteConfig}); - await generate( - generatedFilesDir, - 'pagesMetadatas.js', - `export default ${JSON.stringify(pagesMetadatas, null, 2)};`, - ); - // Process plugins. const pluginConfigs = siteConfig.plugins || []; const context = {env, siteDir, siteConfig}; // Initialize plugins. - const plugins = pluginConfigs.map(({name, options: opts}) => { + const plugins = pluginConfigs.map(({name, options}) => { // TODO: Resolve using node_modules as well. // eslint-disable-next-line const Plugin = require(path.resolve(__dirname, '../../plugins', name)); - return new Plugin(opts, context); + return new Plugin(options, context); }); // Plugin lifecycle - loadContents(). @@ -156,7 +146,6 @@ module.exports = async function load(siteDir) { const {routesConfig, routesPaths} = await loadRoutes({ siteConfig, docsMetadatas, - pagesMetadatas, pluginRouteConfigs, }); await generate(generatedFilesDir, 'routes.js', routesConfig); @@ -189,10 +178,6 @@ module.exports = async function load(siteDir) { name: 'docsSidebars', path: '@generated/docsSidebars', }, - { - name: 'pagesMetadatas', - path: '@generated/pagesMetadatas', - }, ], }); await generate(generatedFilesDir, 'metadata.js', metadataFile); @@ -204,8 +189,6 @@ module.exports = async function load(siteDir) { docsMetadatas, docsSidebars, env, - pagesDir, - pagesMetadatas, outDir, themePath, baseUrl, diff --git a/v2/lib/load/pages.js b/v2/lib/load/pages.js deleted file mode 100644 index 6b7ccb69da..0000000000 --- a/v2/lib/load/pages.js +++ /dev/null @@ -1,65 +0,0 @@ -/** - * Copyright (c) 2017-present, Facebook, Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -const globby = require('globby'); -const path = require('path'); -const {encodePath, fileToPath, idx} = require('./utils'); - -async function loadPages({pagesDir, env, siteConfig}) { - const pagesFiles = await globby(['**/*.js'], { - cwd: pagesDir, - }); - - const {baseUrl} = siteConfig; - - // Prepare metadata container. - const pagesMetadatas = []; - - // Translation. - const translationEnabled = idx(env, ['translation', 'enabled']); - const enabledLanguages = - translationEnabled && idx(env, ['translation', 'enabledLanguages']); - const enabledLangTags = - (enabledLanguages && enabledLanguages.map(lang => lang.tag)) || []; - const defaultLangTag = idx(env, ['translation', 'defaultLanguage', 'tag']); - - await Promise.all( - pagesFiles.map(async relativeSource => { - const source = path.join(pagesDir, relativeSource); - const pathName = encodePath(fileToPath(relativeSource)); - if (translationEnabled && enabledLangTags.length > 0) { - enabledLangTags.forEach(langTag => { - // Default lang should also be available. E.g: /en/users and /users is the same. - if (langTag === defaultLangTag) { - pagesMetadatas.push({ - permalink: pathName.replace(/^\//, baseUrl), - language: langTag, - source, - }); - } - - const metadata = { - permalink: pathName.replace(/^\//, `${baseUrl}${langTag}/`), - language: langTag, - source, - }; - pagesMetadatas.push(metadata); - }); - } else { - // Default Language. - const metadata = { - permalink: pathName.replace(/^\//, baseUrl), - source, - }; - pagesMetadatas.push(metadata); - } - }), - ); - return pagesMetadatas; -} - -module.exports = loadPages; diff --git a/v2/lib/load/routes.js b/v2/lib/load/routes.js index 7f1e42ecbf..befa2407bc 100644 --- a/v2/lib/load/routes.js +++ b/v2/lib/load/routes.js @@ -10,7 +10,6 @@ const {normalizeUrl} = require('./utils'); async function loadRoutes({ siteConfig = {}, docsMetadatas = {}, - pagesMetadatas = [], pluginRouteConfigs = [], }) { const imports = [ @@ -19,7 +18,6 @@ async function loadRoutes({ `import Loading from '@theme/Loading';`, `import Doc from '@theme/Doc';`, `import DocBody from '@theme/DocBody';`, - `import Pages from '@theme/Pages';`, `import NotFound from '@theme/NotFound';`, ]; @@ -64,29 +62,6 @@ async function loadRoutes({ .join(',')}], }`; - // Pages. - function genPagesRoute(metadata) { - const {permalink, source} = metadata; - addRoutesPath(permalink); - return ` -{ - path: '${permalink}', - exact: true, - component: Loadable({ - loader: () => import('${source}'), - loading: Loading, - render(loaded, props) { - let Content = loaded.default; - return ( - - - - ); - } - }) -}`; - } - const notFoundRoute = ` { path: '*', @@ -131,9 +106,7 @@ ${modules ${imports.join('\n')} const routes = [ -// Docs.${pagesMetadatas.map(genPagesRoute).join(',')}, - -// Pages.${docsRoutes}, +// Docs.${docsRoutes}, // Plugins.${routes.join(',')}, diff --git a/v2/lib/theme/Footer/index.js b/v2/lib/theme/Footer/index.js index ccf4d3f64e..5427ef998b 100644 --- a/v2/lib/theme/Footer/index.js +++ b/v2/lib/theme/Footer/index.js @@ -14,8 +14,6 @@ import styles from './styles.module.css'; function Footer() { const context = useContext(DocusaurusContext); - const {pagesMetadatas} = context; - return (