mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 07:37:19 +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;
|
||||
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.",
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ module.exports = async function start(siteDir, cliOptions = {}) {
|
|||
[
|
||||
`../${docsRelativeDir}/**/*.md`,
|
||||
'blog/**/*.md',
|
||||
'siteConfig.js',
|
||||
'docusaurus.config.js',
|
||||
'sidebars.json',
|
||||
],
|
||||
{
|
||||
|
|
|
@ -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';
|
||||
|
||||
|
|
|
@ -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 = [];
|
||||
|
|
|
@ -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`,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)};`,
|
||||
);
|
||||
|
||||
|
|
|
@ -22,36 +22,34 @@ function DocsPaginator() {
|
|||
return (
|
||||
<div className={styles.paginatorContainer}>
|
||||
<div>
|
||||
{metadata.previous &&
|
||||
docsMetadatas[metadata.previous] && (
|
||||
<Link
|
||||
className={styles.paginatorLink}
|
||||
to={docsMetadatas[metadata.previous].permalink}>
|
||||
<svg className={styles.arrow} viewBox="0 0 24 24">
|
||||
<g>
|
||||
<line x1="19" y1="12" x2="5" y2="12" />
|
||||
<polyline points="12 19 5 12 12 5" />
|
||||
</g>
|
||||
</svg>{' '}
|
||||
<span className={styles.label}>{metadata.previous_title}</span>
|
||||
</Link>
|
||||
)}
|
||||
{metadata.previous && docsMetadatas[metadata.previous] && (
|
||||
<Link
|
||||
className={styles.paginatorLink}
|
||||
to={docsMetadatas[metadata.previous].permalink}>
|
||||
<svg className={styles.arrow} viewBox="0 0 24 24">
|
||||
<g>
|
||||
<line x1="19" y1="12" x2="5" y2="12" />
|
||||
<polyline points="12 19 5 12 12 5" />
|
||||
</g>
|
||||
</svg>{' '}
|
||||
<span className={styles.label}>{metadata.previous_title}</span>
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
<div className={styles.paginatorRightContainer}>
|
||||
{metadata.next &&
|
||||
docsMetadatas[metadata.next] && (
|
||||
<Link
|
||||
className={styles.paginatorLink}
|
||||
to={docsMetadatas[metadata.next].permalink}>
|
||||
<span className={styles.label}>{metadata.next_title}</span>{' '}
|
||||
<svg className={styles.arrow} viewBox="0 0 24 24">
|
||||
<g>
|
||||
<line x1="5" y1="12" x2="19" y2="12" />
|
||||
<polyline points="12 5 19 12 12 19" />
|
||||
</g>
|
||||
</svg>
|
||||
</Link>
|
||||
)}
|
||||
{metadata.next && docsMetadatas[metadata.next] && (
|
||||
<Link
|
||||
className={styles.paginatorLink}
|
||||
to={docsMetadatas[metadata.next].permalink}>
|
||||
<span className={styles.label}>{metadata.next_title}</span>{' '}
|
||||
<svg className={styles.arrow} viewBox="0 0 24 24">
|
||||
<g>
|
||||
<line x1="5" y1="12" x2="19" y2="12" />
|
||||
<polyline points="12 5 19 12 12 19" />
|
||||
</g>
|
||||
</svg>
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
|
|
@ -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"`,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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"`,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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'"`,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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 (
|
||||
<div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue