Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: rename siteConfig.js to docusaurus.config.js #1245

Merged
merged 2 commits into from
Feb 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions v2/CHANGES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Breaking Changes

- `siteConfig.js` renamed to `docusaurus.config.js`.
4 changes: 2 additions & 2 deletions v2/lib/commands/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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.",
);
}

Expand Down
2 changes: 1 addition & 1 deletion v2/lib/commands/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ module.exports = async function start(siteDir, cliOptions = {}) {
[
`../${docsRelativeDir}/**/*.md`,
'blog/**/*.md',
'siteConfig.js',
'docusaurus.config.js',
'sidebars.json',
],
{
Expand Down
2 changes: 1 addition & 1 deletion v2/lib/core/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
2 changes: 1 addition & 1 deletion v2/lib/core/sitemap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down
10 changes: 6 additions & 4 deletions v2/lib/load/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down Expand Up @@ -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`,
);
}

Expand Down Expand Up @@ -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`,
);
}

Expand Down
2 changes: 1 addition & 1 deletion v2/lib/load/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion v2/lib/load/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)};`,
);

Expand Down
54 changes: 26 additions & 28 deletions v2/lib/theme/DocsPaginator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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>
);
Expand Down
2 changes: 1 addition & 1 deletion v2/test/core/sitemap.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"`,
);
});
});
6 changes: 3 additions & 3 deletions v2/test/load/config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"`,
);
});

Expand All @@ -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"`,
);
});

Expand All @@ -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"`,
);
});
});
2 changes: 1 addition & 1 deletion v2/test/load/env.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'"`,
);
});
});
File renamed without changes.
23 changes: 10 additions & 13 deletions v2/website/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down