mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-06 10:20:09 +02:00
chore: migrate website config to createConfigAsync (#8911)
This commit is contained in:
parent
41a52161fd
commit
4a4a8be062
1 changed files with 550 additions and 560 deletions
|
@ -88,8 +88,9 @@ function getLocalizedConfigValue(/** @type {string} */ key) {
|
|||
return value;
|
||||
}
|
||||
|
||||
/** @type {import('@docusaurus/types').Config} */
|
||||
const config = {
|
||||
/** @returns {Promise<import('@docusaurus/types').Config>} */
|
||||
module.exports = async function createConfigAsync() {
|
||||
return {
|
||||
title: 'Docusaurus',
|
||||
tagline: getLocalizedConfigValue('tagline'),
|
||||
organizationName: 'facebook',
|
||||
|
@ -152,8 +153,8 @@ const config = {
|
|||
staticDirectories: [
|
||||
'static',
|
||||
path.join(__dirname, '_dogfooding/_asset-tests'),
|
||||
// Adding a non-existent static directory. If user deleted `static` without
|
||||
// specifying `staticDirectories: []`, build should still work
|
||||
// Adding a non-existent static directory. If user deleted `static`
|
||||
// without specifying `staticDirectories: []`, build should still work
|
||||
path.join(__dirname, '_dogfooding/non-existent'),
|
||||
],
|
||||
themes: ['live-codeblock', ...dogfoodingThemeInstances],
|
||||
|
@ -303,6 +304,8 @@ const config = {
|
|||
},
|
||||
],
|
||||
'@docusaurus/theme-mermaid',
|
||||
(await import('./src/plugins/featureRequests/FeatureRequestsPlugin.mjs'))
|
||||
.default,
|
||||
...dogfoodingPluginInstances,
|
||||
],
|
||||
presets: [
|
||||
|
@ -321,7 +324,7 @@ const config = {
|
|||
if (locale !== defaultLocale) {
|
||||
return `https://crowdin.com/project/docusaurus-v2/${locale}`;
|
||||
}
|
||||
// We want users to submit doc updates to the upstream/next version!
|
||||
// We want users to submit updates to the upstream/next version!
|
||||
// Otherwise we risk losing the update on the next release.
|
||||
const nextVersionDocsDirPath = 'docs';
|
||||
return `https://github.com/facebook/docusaurus/edit/main/website/${nextVersionDocsDirPath}/${docPath}`;
|
||||
|
@ -332,11 +335,17 @@ const config = {
|
|||
},
|
||||
showLastUpdateAuthor: true,
|
||||
showLastUpdateTime: true,
|
||||
remarkPlugins: [math, [npm2yarn, {sync: true}]],
|
||||
rehypePlugins: [],
|
||||
remarkPlugins: [
|
||||
math,
|
||||
[npm2yarn, {sync: true}],
|
||||
(await import('./src/remark/configTabs.mjs')).default,
|
||||
],
|
||||
rehypePlugins: [(await import('rehype-katex')).default],
|
||||
disableVersioning: isVersioningDisabled,
|
||||
lastVersion:
|
||||
isDev || isDeployPreview || isBranchDeploy ? 'current' : undefined,
|
||||
isDev || isDeployPreview || isBranchDeploy
|
||||
? 'current'
|
||||
: undefined,
|
||||
onlyIncludeVersions: (() => {
|
||||
if (isBuildFast) {
|
||||
return ['current'];
|
||||
|
@ -429,6 +438,8 @@ const config = {
|
|||
line: 'This will error',
|
||||
},
|
||||
],
|
||||
theme: (await import('./src/utils/prismLight.mjs')).default,
|
||||
darkTheme: (await import('./src/utils/prismDark.mjs')).default,
|
||||
},
|
||||
image: 'img/docusaurus-social-card.jpg',
|
||||
// metadata: [{name: 'twitter:card', content: 'summary'}],
|
||||
|
@ -654,25 +665,4 @@ const config = {
|
|||
},
|
||||
}),
|
||||
};
|
||||
|
||||
async function createConfig() {
|
||||
const FeatureRequestsPlugin = (
|
||||
await import('./src/plugins/featureRequests/FeatureRequestsPlugin.mjs')
|
||||
).default;
|
||||
const configTabs = (await import('./src/remark/configTabs.mjs')).default;
|
||||
const lightTheme = (await import('./src/utils/prismLight.mjs')).default;
|
||||
const darkTheme = (await import('./src/utils/prismDark.mjs')).default;
|
||||
const katex = (await import('rehype-katex')).default;
|
||||
config.plugins?.push(FeatureRequestsPlugin);
|
||||
// @ts-expect-error: we know it exists, right
|
||||
config.presets[0][1].docs.remarkPlugins.push(configTabs);
|
||||
// @ts-expect-error: we know it exists, right
|
||||
config.themeConfig.prism.theme = lightTheme;
|
||||
// @ts-expect-error: we know it exists, right
|
||||
config.themeConfig.prism.darkTheme = darkTheme;
|
||||
// @ts-expect-error: we know it exists, right
|
||||
config.presets[0][1].docs.rehypePlugins.push(katex);
|
||||
return config;
|
||||
}
|
||||
|
||||
module.exports = createConfig;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue