mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 15:47:23 +02:00
chore: rename siteConfig.js to docusaurus.config.js (#1245)
* chore: rename siteConfig.js to docusaurus.config.js * Prettier
This commit is contained in:
parent
870f6daa6b
commit
7dae4bd0d1
21 changed files with 57 additions and 57 deletions
3
v2/CHANGES.md
Normal file
3
v2/CHANGES.md
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
# Breaking Changes
|
||||||
|
|
||||||
|
- `siteConfig.js` renamed to `docusaurus.config.js`.
|
|
@ -34,7 +34,7 @@ module.exports = async function deploy(siteDir) {
|
||||||
siteConfig.organizationName;
|
siteConfig.organizationName;
|
||||||
if (!organizationName) {
|
if (!organizationName) {
|
||||||
throw new Error(
|
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 =
|
const projectName =
|
||||||
|
@ -43,7 +43,7 @@ module.exports = async function deploy(siteDir) {
|
||||||
siteConfig.projectName;
|
siteConfig.projectName;
|
||||||
if (!projectName) {
|
if (!projectName) {
|
||||||
throw new Error(
|
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.",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ module.exports = async function start(siteDir, cliOptions = {}) {
|
||||||
[
|
[
|
||||||
`../${docsRelativeDir}/**/*.md`,
|
`../${docsRelativeDir}/**/*.md`,
|
||||||
'blog/**/*.md',
|
'blog/**/*.md',
|
||||||
'siteConfig.js',
|
'docusaurus.config.js',
|
||||||
'sidebars.json',
|
'sidebars.json',
|
||||||
],
|
],
|
||||||
{
|
{
|
||||||
|
|
|
@ -14,7 +14,7 @@ import docsMetadatas from '@generated/docsMetadatas'; // eslint-disable-line
|
||||||
import env from '@generated/env'; // eslint-disable-line
|
import env from '@generated/env'; // eslint-disable-line
|
||||||
import docsSidebars from '@generated/docsSidebars'; // eslint-disable-line
|
import docsSidebars from '@generated/docsSidebars'; // eslint-disable-line
|
||||||
import pagesMetadatas from '@generated/pagesMetadatas'; // 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';
|
import DocusaurusContext from '@docusaurus/context';
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ module.exports = async function createSitemap({
|
||||||
const {url: siteUrl} = siteConfig;
|
const {url: siteUrl} = siteConfig;
|
||||||
|
|
||||||
if (!siteUrl) {
|
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 = [];
|
const urls = [];
|
||||||
|
|
|
@ -9,7 +9,7 @@ const fs = require('fs-extra');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
module.exports = function loadConfig(siteDir, deleteCache = true) {
|
module.exports = function loadConfig(siteDir, deleteCache = true) {
|
||||||
const configPath = path.resolve(siteDir, 'siteConfig.js');
|
const configPath = path.resolve(siteDir, 'docusaurus.config.js');
|
||||||
if (deleteCache) {
|
if (deleteCache) {
|
||||||
delete require.cache[configPath];
|
delete require.cache[configPath];
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ module.exports = function loadConfig(siteDir, deleteCache = true) {
|
||||||
const missingFields = requiredFields.filter(field => !config[field]);
|
const missingFields = requiredFields.filter(field => !config[field]);
|
||||||
if (missingFields && missingFields.length > 0) {
|
if (missingFields && missingFields.length > 0) {
|
||||||
throw new Error(
|
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;
|
const {customFields = []} = config;
|
||||||
|
|
||||||
/* We don't allow useless/ not meaningful field */
|
// We don't allow unused fields.
|
||||||
const allowedFields = [...requiredFields, ...optionalFields, ...customFields];
|
const allowedFields = [...requiredFields, ...optionalFields, ...customFields];
|
||||||
const uselessFields = Object.keys(config).filter(
|
const uselessFields = Object.keys(config).filter(
|
||||||
field => !allowedFields.includes(field),
|
field => !allowedFields.includes(field),
|
||||||
);
|
);
|
||||||
if (uselessFields && uselessFields.length > 0) {
|
if (uselessFields && uselessFields.length > 0) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`${uselessFields.join(', ')} fields are useless in siteConfig.js`,
|
`The fields ${uselessFields.join(
|
||||||
|
', ',
|
||||||
|
)} are not recognized in docusaurus.config.js`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ module.exports = function loadEnv({siteDir, siteConfig}) {
|
||||||
);
|
);
|
||||||
if (!defaultLanguage) {
|
if (!defaultLanguage) {
|
||||||
throw new Error(
|
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;
|
translation.defaultLanguage = defaultLanguage;
|
||||||
|
|
|
@ -19,7 +19,7 @@ module.exports = async function load(siteDir) {
|
||||||
// @tested - siteConfig
|
// @tested - siteConfig
|
||||||
const siteConfig = loadConfig(siteDir);
|
const siteConfig = loadConfig(siteDir);
|
||||||
await generate(
|
await generate(
|
||||||
'siteConfig.js',
|
'docusaurus.config.js',
|
||||||
`export default ${JSON.stringify(siteConfig, null, 2)};`,
|
`export default ${JSON.stringify(siteConfig, null, 2)};`,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -22,8 +22,7 @@ function DocsPaginator() {
|
||||||
return (
|
return (
|
||||||
<div className={styles.paginatorContainer}>
|
<div className={styles.paginatorContainer}>
|
||||||
<div>
|
<div>
|
||||||
{metadata.previous &&
|
{metadata.previous && docsMetadatas[metadata.previous] && (
|
||||||
docsMetadatas[metadata.previous] && (
|
|
||||||
<Link
|
<Link
|
||||||
className={styles.paginatorLink}
|
className={styles.paginatorLink}
|
||||||
to={docsMetadatas[metadata.previous].permalink}>
|
to={docsMetadatas[metadata.previous].permalink}>
|
||||||
|
@ -38,8 +37,7 @@ function DocsPaginator() {
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className={styles.paginatorRightContainer}>
|
<div className={styles.paginatorRightContainer}>
|
||||||
{metadata.next &&
|
{metadata.next && docsMetadatas[metadata.next] && (
|
||||||
docsMetadatas[metadata.next] && (
|
|
||||||
<Link
|
<Link
|
||||||
className={styles.paginatorLink}
|
className={styles.paginatorLink}
|
||||||
to={docsMetadatas[metadata.next].permalink}>
|
to={docsMetadatas[metadata.next].permalink}>
|
||||||
|
|
|
@ -45,7 +45,7 @@ describe('sitemap', () => {
|
||||||
test('empty site', async () => {
|
test('empty site', async () => {
|
||||||
const props = await loadSetup('empty');
|
const props = await loadSetup('empty');
|
||||||
expect(createSitemap(props)).rejects.toThrowErrorMatchingInlineSnapshot(
|
expect(createSitemap(props)).rejects.toThrowErrorMatchingInlineSnapshot(
|
||||||
`"Url in siteConfig.js cannot be empty/undefined"`,
|
`"Url in docusaurus.config.js cannot be empty/undefined"`,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -48,7 +48,7 @@ Object {
|
||||||
expect(() => {
|
expect(() => {
|
||||||
loadConfig(siteDir);
|
loadConfig(siteDir);
|
||||||
}).toThrowErrorMatchingInlineSnapshot(
|
}).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(() => {
|
expect(() => {
|
||||||
loadConfig(siteDir);
|
loadConfig(siteDir);
|
||||||
}).toThrowErrorMatchingInlineSnapshot(
|
}).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(() => {
|
expect(() => {
|
||||||
loadConfig(siteDir);
|
loadConfig(siteDir);
|
||||||
}).toThrowErrorMatchingInlineSnapshot(
|
}).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"`,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -100,7 +100,7 @@ describe('loadEnv', () => {
|
||||||
expect(() => {
|
expect(() => {
|
||||||
loadEnv({siteDir, siteConfig});
|
loadEnv({siteDir, siteConfig});
|
||||||
}).toThrowErrorMatchingInlineSnapshot(
|
}).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'"`,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -113,8 +113,7 @@ const QUOTES = [
|
||||||
|
|
||||||
function Home() {
|
function Home() {
|
||||||
const [featureIndex, setFeatureIndex] = useState(0);
|
const [featureIndex, setFeatureIndex] = useState(0);
|
||||||
useEffect(
|
useEffect(() => {
|
||||||
() => {
|
|
||||||
const timer = window.setTimeout(() => {
|
const timer = window.setTimeout(() => {
|
||||||
setFeatureIndex(
|
setFeatureIndex(
|
||||||
prevFeatureIndex => (prevFeatureIndex + 1) % FEATURES.length,
|
prevFeatureIndex => (prevFeatureIndex + 1) % FEATURES.length,
|
||||||
|
@ -123,9 +122,7 @@ function Home() {
|
||||||
return () => {
|
return () => {
|
||||||
window.clearTimeout(timer);
|
window.clearTimeout(timer);
|
||||||
};
|
};
|
||||||
},
|
}, [featureIndex]);
|
||||||
[featureIndex],
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue