diff --git a/v2/CHANGES.md b/v2/CHANGES.md new file mode 100644 index 000000000000..f73d47d0f63a --- /dev/null +++ b/v2/CHANGES.md @@ -0,0 +1,3 @@ +# Breaking Changes + +- `siteConfig.js` renamed to `docusaurus.config.js`. diff --git a/v2/lib/commands/deploy.js b/v2/lib/commands/deploy.js index 1f32105b2a59..671bb71992d8 100644 --- a/v2/lib/commands/deploy.js +++ b/v2/lib/commands/deploy.js @@ -34,7 +34,7 @@ module.exports = async function deploy(siteDir) { siteConfig.organizationName; if (!organizationName) { throw new Error( - "Missing project organization name. Did you forget to define 'organizationName' in siteConfig.js? You may also export it via the organizationName environment variable.", + "Missing project organization name. Did you forget to define 'organizationName' in docusaurus.config.js? You may also export it via the organizationName environment variable.", ); } const projectName = @@ -43,7 +43,7 @@ module.exports = async function deploy(siteDir) { siteConfig.projectName; if (!projectName) { throw new Error( - "Missing project name. Did you forget to define 'projectName' in siteConfig.js? You may also export it via the projectName environment variable.", + "Missing project name. Did you forget to define 'projectName' in docusaurus.config.js? You may also export it via the projectName environment variable.", ); } diff --git a/v2/lib/commands/start.js b/v2/lib/commands/start.js index 080b9d31eb91..69163fc15d92 100644 --- a/v2/lib/commands/start.js +++ b/v2/lib/commands/start.js @@ -50,7 +50,7 @@ module.exports = async function start(siteDir, cliOptions = {}) { [ `../${docsRelativeDir}/**/*.md`, 'blog/**/*.md', - 'siteConfig.js', + 'docusaurus.config.js', 'sidebars.json', ], { diff --git a/v2/lib/core/App.js b/v2/lib/core/App.js index 0d2c1817e831..1f569324f2b2 100644 --- a/v2/lib/core/App.js +++ b/v2/lib/core/App.js @@ -14,7 +14,7 @@ import docsMetadatas from '@generated/docsMetadatas'; // eslint-disable-line import env from '@generated/env'; // eslint-disable-line import docsSidebars from '@generated/docsSidebars'; // eslint-disable-line import pagesMetadatas from '@generated/pagesMetadatas'; // eslint-disable-line -import siteConfig from '@generated/siteConfig'; //eslint-disable-line +import siteConfig from '@generated/docusaurus.config'; //eslint-disable-line import DocusaurusContext from '@docusaurus/context'; diff --git a/v2/lib/core/sitemap.js b/v2/lib/core/sitemap.js index 147059c706e7..ab3cd33701f1 100644 --- a/v2/lib/core/sitemap.js +++ b/v2/lib/core/sitemap.js @@ -22,7 +22,7 @@ module.exports = async function createSitemap({ const {url: siteUrl} = siteConfig; if (!siteUrl) { - throw new Error('Url in siteConfig.js cannot be empty/undefined'); + throw new Error('Url in docusaurus.config.js cannot be empty/undefined'); } const urls = []; diff --git a/v2/lib/load/config.js b/v2/lib/load/config.js index c822ab0cf28f..13d413b1469f 100644 --- a/v2/lib/load/config.js +++ b/v2/lib/load/config.js @@ -9,7 +9,7 @@ const fs = require('fs-extra'); const path = require('path'); module.exports = function loadConfig(siteDir, deleteCache = true) { - const configPath = path.resolve(siteDir, 'siteConfig.js'); + const configPath = path.resolve(siteDir, 'docusaurus.config.js'); if (deleteCache) { delete require.cache[configPath]; } @@ -44,7 +44,7 @@ module.exports = function loadConfig(siteDir, deleteCache = true) { const missingFields = requiredFields.filter(field => !config[field]); if (missingFields && missingFields.length > 0) { throw new Error( - `${missingFields.join(', ')} fields are missing in siteConfig.js`, + `${missingFields.join(', ')} fields are missing in docusaurus.config.js`, ); } @@ -89,14 +89,16 @@ module.exports = function loadConfig(siteDir, deleteCache = true) { */ const {customFields = []} = config; - /* We don't allow useless/ not meaningful field */ + // We don't allow unused fields. const allowedFields = [...requiredFields, ...optionalFields, ...customFields]; const uselessFields = Object.keys(config).filter( field => !allowedFields.includes(field), ); if (uselessFields && uselessFields.length > 0) { throw new Error( - `${uselessFields.join(', ')} fields are useless in siteConfig.js`, + `The fields ${uselessFields.join( + ', ', + )} are not recognized in docusaurus.config.js`, ); } diff --git a/v2/lib/load/env.js b/v2/lib/load/env.js index 58c9f27313ce..682d711f734f 100644 --- a/v2/lib/load/env.js +++ b/v2/lib/load/env.js @@ -36,7 +36,7 @@ module.exports = function loadEnv({siteDir, siteConfig}) { ); if (!defaultLanguage) { throw new Error( - `Please set a default language in 'siteConfig.js' which is enabled in 'languages.js'`, + `Please set a default language in 'docusaurus.config.js' which is enabled in 'languages.js'`, ); } translation.defaultLanguage = defaultLanguage; diff --git a/v2/lib/load/index.js b/v2/lib/load/index.js index 9d3da0fd55b0..fadb33a251af 100644 --- a/v2/lib/load/index.js +++ b/v2/lib/load/index.js @@ -19,7 +19,7 @@ module.exports = async function load(siteDir) { // @tested - siteConfig const siteConfig = loadConfig(siteDir); await generate( - 'siteConfig.js', + 'docusaurus.config.js', `export default ${JSON.stringify(siteConfig, null, 2)};`, ); diff --git a/v2/lib/theme/DocsPaginator/index.js b/v2/lib/theme/DocsPaginator/index.js index 25fcd224ccd4..203aa35d77ac 100644 --- a/v2/lib/theme/DocsPaginator/index.js +++ b/v2/lib/theme/DocsPaginator/index.js @@ -22,36 +22,34 @@ function DocsPaginator() { return (
- {metadata.previous && - docsMetadatas[metadata.previous] && ( - - - - - - - {' '} - {metadata.previous_title} - - )} + {metadata.previous && docsMetadatas[metadata.previous] && ( + + + + + + + {' '} + {metadata.previous_title} + + )}
- {metadata.next && - docsMetadatas[metadata.next] && ( - - {metadata.next_title}{' '} - - - - - - - - )} + {metadata.next && docsMetadatas[metadata.next] && ( + + {metadata.next_title}{' '} + + + + + + + + )}
); diff --git a/v2/test/__fixtures__/custom-site/siteConfig.js b/v2/test/__fixtures__/custom-site/docusaurus.config.js similarity index 100% rename from v2/test/__fixtures__/custom-site/siteConfig.js rename to v2/test/__fixtures__/custom-site/docusaurus.config.js diff --git a/v2/test/__fixtures__/simple-site/siteConfig.js b/v2/test/__fixtures__/simple-site/docusaurus.config.js similarity index 100% rename from v2/test/__fixtures__/simple-site/siteConfig.js rename to v2/test/__fixtures__/simple-site/docusaurus.config.js diff --git a/v2/test/__fixtures__/translated-site/siteConfig.js b/v2/test/__fixtures__/translated-site/docusaurus.config.js similarity index 100% rename from v2/test/__fixtures__/translated-site/siteConfig.js rename to v2/test/__fixtures__/translated-site/docusaurus.config.js diff --git a/v2/test/__fixtures__/transversioned-site/siteConfig.js b/v2/test/__fixtures__/transversioned-site/docusaurus.config.js similarity index 100% rename from v2/test/__fixtures__/transversioned-site/siteConfig.js rename to v2/test/__fixtures__/transversioned-site/docusaurus.config.js diff --git a/v2/test/__fixtures__/versioned-site/siteConfig.js b/v2/test/__fixtures__/versioned-site/docusaurus.config.js similarity index 100% rename from v2/test/__fixtures__/versioned-site/siteConfig.js rename to v2/test/__fixtures__/versioned-site/docusaurus.config.js diff --git a/v2/test/core/sitemap.test.js b/v2/test/core/sitemap.test.js index a91d7e187dcd..87dc1ec98ad8 100644 --- a/v2/test/core/sitemap.test.js +++ b/v2/test/core/sitemap.test.js @@ -45,7 +45,7 @@ describe('sitemap', () => { test('empty site', async () => { const props = await loadSetup('empty'); expect(createSitemap(props)).rejects.toThrowErrorMatchingInlineSnapshot( - `"Url in siteConfig.js cannot be empty/undefined"`, + `"Url in docusaurus.config.js cannot be empty/undefined"`, ); }); }); diff --git a/v2/test/load/__fixtures__/bad-site/siteConfig.js b/v2/test/load/__fixtures__/bad-site/docusaurus.config.js similarity index 100% rename from v2/test/load/__fixtures__/bad-site/siteConfig.js rename to v2/test/load/__fixtures__/bad-site/docusaurus.config.js diff --git a/v2/test/load/__fixtures__/wrong-site/siteConfig.js b/v2/test/load/__fixtures__/wrong-site/docusaurus.config.js similarity index 100% rename from v2/test/load/__fixtures__/wrong-site/siteConfig.js rename to v2/test/load/__fixtures__/wrong-site/docusaurus.config.js diff --git a/v2/test/load/config.test.js b/v2/test/load/config.test.js index c83d899590e7..71bb677062f6 100644 --- a/v2/test/load/config.test.js +++ b/v2/test/load/config.test.js @@ -48,7 +48,7 @@ Object { expect(() => { loadConfig(siteDir); }).toThrowErrorMatchingInlineSnapshot( - `"tagline, organizationName, projectName, url, headerLinks, headerIcon, favicon fields are missing in siteConfig.js"`, + `"tagline, organizationName, projectName, url, headerLinks, headerIcon, favicon fields are missing in docusaurus.config.js"`, ); }); @@ -57,7 +57,7 @@ Object { expect(() => { loadConfig(siteDir); }).toThrowErrorMatchingInlineSnapshot( - `"headerLinks, headerIcon, favicon fields are missing in siteConfig.js"`, + `"headerLinks, headerIcon, favicon fields are missing in docusaurus.config.js"`, ); }); @@ -66,7 +66,7 @@ Object { expect(() => { loadConfig(siteDir); }).toThrowErrorMatchingInlineSnapshot( - `"title, tagline, organizationName, projectName, baseUrl, url, headerLinks, headerIcon, favicon fields are missing in siteConfig.js"`, + `"title, tagline, organizationName, projectName, baseUrl, url, headerLinks, headerIcon, favicon fields are missing in docusaurus.config.js"`, ); }); }); diff --git a/v2/test/load/env.test.js b/v2/test/load/env.test.js index 49e164f0329f..7505ec1968ca 100644 --- a/v2/test/load/env.test.js +++ b/v2/test/load/env.test.js @@ -100,7 +100,7 @@ describe('loadEnv', () => { expect(() => { loadEnv({siteDir, siteConfig}); }).toThrowErrorMatchingInlineSnapshot( - `"Please set a default language in 'siteConfig.js' which is enabled in 'languages.js'"`, + `"Please set a default language in 'docusaurus.config.js' which is enabled in 'languages.js'"`, ); }); }); diff --git a/v2/website/siteConfig.js b/v2/website/docusaurus.config.js similarity index 100% rename from v2/website/siteConfig.js rename to v2/website/docusaurus.config.js diff --git a/v2/website/pages/index.js b/v2/website/pages/index.js index 343ea6a336ab..8f2f17e99db4 100644 --- a/v2/website/pages/index.js +++ b/v2/website/pages/index.js @@ -113,19 +113,16 @@ const QUOTES = [ function Home() { const [featureIndex, setFeatureIndex] = useState(0); - useEffect( - () => { - const timer = window.setTimeout(() => { - setFeatureIndex( - prevFeatureIndex => (prevFeatureIndex + 1) % FEATURES.length, - ); - }, FEATURE_INTERVAL); - return () => { - window.clearTimeout(timer); - }; - }, - [featureIndex], - ); + useEffect(() => { + const timer = window.setTimeout(() => { + setFeatureIndex( + prevFeatureIndex => (prevFeatureIndex + 1) % FEATURES.length, + ); + }, FEATURE_INTERVAL); + return () => { + window.clearTimeout(timer); + }; + }, [featureIndex]); return (