mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-23 19:48:54 +02:00
wire to the config attribute
This commit is contained in:
parent
98469e1099
commit
650f51662a
8 changed files with 24 additions and 13 deletions
|
@ -12,6 +12,7 @@ import {
|
||||||
posixPath,
|
posixPath,
|
||||||
getFileCommitDate,
|
getFileCommitDate,
|
||||||
LAST_UPDATE_FALLBACK,
|
LAST_UPDATE_FALLBACK,
|
||||||
|
getCurrentLocaleConfig,
|
||||||
} from '@docusaurus/utils';
|
} from '@docusaurus/utils';
|
||||||
import {DEFAULT_FUTURE_CONFIG} from '@docusaurus/core/src/server/configValidation';
|
import {DEFAULT_FUTURE_CONFIG} from '@docusaurus/core/src/server/configValidation';
|
||||||
import pluginContentBlog from '../index';
|
import pluginContentBlog from '../index';
|
||||||
|
@ -100,7 +101,7 @@ const getPlugin = async (
|
||||||
const localizationDir = path.join(
|
const localizationDir = path.join(
|
||||||
siteDir,
|
siteDir,
|
||||||
i18n.path,
|
i18n.path,
|
||||||
i18n.localeConfigs[i18n.currentLocale]!.path,
|
getCurrentLocaleConfig(i18n).path,
|
||||||
);
|
);
|
||||||
const siteConfig = {
|
const siteConfig = {
|
||||||
title: 'Hello',
|
title: 'Hello',
|
||||||
|
|
|
@ -19,6 +19,7 @@ import {
|
||||||
getDataFilePath,
|
getDataFilePath,
|
||||||
DEFAULT_PLUGIN_ID,
|
DEFAULT_PLUGIN_ID,
|
||||||
resolveMarkdownLinkPathname,
|
resolveMarkdownLinkPathname,
|
||||||
|
getCurrentLocaleConfig,
|
||||||
} from '@docusaurus/utils';
|
} from '@docusaurus/utils';
|
||||||
import {getTagsFilePathsToWatch} from '@docusaurus/utils-validation';
|
import {getTagsFilePathsToWatch} from '@docusaurus/utils-validation';
|
||||||
import {createMDXLoaderItem} from '@docusaurus/mdx-loader';
|
import {createMDXLoaderItem} from '@docusaurus/mdx-loader';
|
||||||
|
@ -73,10 +74,10 @@ export default async function pluginContentBlog(
|
||||||
|
|
||||||
const {baseUrl} = siteConfig;
|
const {baseUrl} = siteConfig;
|
||||||
|
|
||||||
const shouldLocalize = false;
|
const shouldTranslate = getCurrentLocaleConfig(context.i18n).translate;
|
||||||
const contentPaths: BlogContentPaths = {
|
const contentPaths: BlogContentPaths = {
|
||||||
contentPath: path.resolve(siteDir, options.path),
|
contentPath: path.resolve(siteDir, options.path),
|
||||||
contentPathLocalized: shouldLocalize
|
contentPathLocalized: shouldTranslate
|
||||||
? getPluginI18nPath({
|
? getPluginI18nPath({
|
||||||
localizationDir,
|
localizationDir,
|
||||||
pluginName: PluginName,
|
pluginName: PluginName,
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
import fs from 'fs-extra';
|
import fs from 'fs-extra';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import logger from '@docusaurus/logger';
|
import logger from '@docusaurus/logger';
|
||||||
import {DEFAULT_PLUGIN_ID} from '@docusaurus/utils';
|
import {DEFAULT_PLUGIN_ID, getCurrentLocaleConfig} from '@docusaurus/utils';
|
||||||
import {
|
import {
|
||||||
getVersionsFilePath,
|
getVersionsFilePath,
|
||||||
getVersionDocsDirPath,
|
getVersionDocsDirPath,
|
||||||
|
@ -89,7 +89,7 @@ async function cliDocsVersionCommand(
|
||||||
const localizationDir = path.resolve(
|
const localizationDir = path.resolve(
|
||||||
siteDir,
|
siteDir,
|
||||||
i18n.path,
|
i18n.path,
|
||||||
i18n.localeConfigs[locale]!.path,
|
getCurrentLocaleConfig(i18n).path,
|
||||||
);
|
);
|
||||||
// Copy docs files.
|
// Copy docs files.
|
||||||
const docsDir =
|
const docsDir =
|
||||||
|
|
|
@ -7,7 +7,11 @@
|
||||||
|
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import fs from 'fs-extra';
|
import fs from 'fs-extra';
|
||||||
import {getPluginI18nPath, DEFAULT_PLUGIN_ID} from '@docusaurus/utils';
|
import {
|
||||||
|
getPluginI18nPath,
|
||||||
|
DEFAULT_PLUGIN_ID,
|
||||||
|
getCurrentLocaleConfig,
|
||||||
|
} from '@docusaurus/utils';
|
||||||
import {
|
import {
|
||||||
VERSIONS_JSON_FILE,
|
VERSIONS_JSON_FILE,
|
||||||
VERSIONED_DOCS_DIR,
|
VERSIONED_DOCS_DIR,
|
||||||
|
@ -187,7 +191,7 @@ export async function getVersionMetadataPaths({
|
||||||
> {
|
> {
|
||||||
const isCurrent = versionName === CURRENT_VERSION_NAME;
|
const isCurrent = versionName === CURRENT_VERSION_NAME;
|
||||||
|
|
||||||
const shouldTranslate = false; // TODO wire this properly
|
const shouldTranslate = getCurrentLocaleConfig(context.i18n).translate;
|
||||||
const contentPathLocalized = shouldTranslate
|
const contentPathLocalized = shouldTranslate
|
||||||
? getDocsDirPathLocalized({
|
? getDocsDirPathLocalized({
|
||||||
localizationDir: context.localizationDir,
|
localizationDir: context.localizationDir,
|
||||||
|
|
|
@ -23,6 +23,7 @@ import {
|
||||||
getPluginI18nPath,
|
getPluginI18nPath,
|
||||||
getContentPathList,
|
getContentPathList,
|
||||||
type ContentPaths,
|
type ContentPaths,
|
||||||
|
getCurrentLocaleConfig,
|
||||||
} from '@docusaurus/utils';
|
} from '@docusaurus/utils';
|
||||||
import {validatePageFrontMatter} from './frontMatter';
|
import {validatePageFrontMatter} from './frontMatter';
|
||||||
import type {LoadContext} from '@docusaurus/types';
|
import type {LoadContext} from '@docusaurus/types';
|
||||||
|
@ -41,10 +42,10 @@ export function createPagesContentPaths({
|
||||||
}): ContentPaths {
|
}): ContentPaths {
|
||||||
const {siteDir, localizationDir} = context;
|
const {siteDir, localizationDir} = context;
|
||||||
|
|
||||||
const shouldLocalize = false;
|
const shouldTranslate = getCurrentLocaleConfig(context.i18n).translate;
|
||||||
return {
|
return {
|
||||||
contentPath: path.resolve(siteDir, options.path),
|
contentPath: path.resolve(siteDir, options.path),
|
||||||
contentPathLocalized: shouldLocalize
|
contentPathLocalized: shouldTranslate
|
||||||
? getPluginI18nPath({
|
? getPluginI18nPath({
|
||||||
localizationDir,
|
localizationDir,
|
||||||
pluginName: 'docusaurus-plugin-content-pages',
|
pluginName: 'docusaurus-plugin-content-pages',
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {PerfLogger} from '@docusaurus/logger';
|
import {PerfLogger} from '@docusaurus/logger';
|
||||||
|
import {getCurrentLocaleConfig} from '@docusaurus/utils';
|
||||||
import {initPlugins} from './init';
|
import {initPlugins} from './init';
|
||||||
import {createBootstrapPlugin, createMDXFallbackPlugin} from './synthetic';
|
import {createBootstrapPlugin, createMDXFallbackPlugin} from './synthetic';
|
||||||
import {localizePluginTranslationFile} from '../translations/translations';
|
import {localizePluginTranslationFile} from '../translations/translations';
|
||||||
|
@ -81,8 +82,7 @@ async function executePluginContentLoading({
|
||||||
plugin.loadContent?.(),
|
plugin.loadContent?.(),
|
||||||
);
|
);
|
||||||
|
|
||||||
// TODO wire
|
const shouldTranslate = getCurrentLocaleConfig(context.i18n).translate;
|
||||||
const shouldTranslate = false;
|
|
||||||
|
|
||||||
if (shouldTranslate) {
|
if (shouldTranslate) {
|
||||||
content = await PerfLogger.async('translatePluginContent()', () =>
|
content = await PerfLogger.async('translatePluginContent()', () =>
|
||||||
|
@ -94,6 +94,8 @@ async function executePluginContentLoading({
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If shouldTranslate === false, we still need the code translations
|
||||||
|
// Otherwise an unlocalized French site would show code strings in English
|
||||||
const defaultCodeTranslations =
|
const defaultCodeTranslations =
|
||||||
(await PerfLogger.async('getDefaultCodeTranslationMessages()', () =>
|
(await PerfLogger.async('getDefaultCodeTranslationMessages()', () =>
|
||||||
plugin.getDefaultCodeTranslationMessages?.(),
|
plugin.getDefaultCodeTranslationMessages?.(),
|
||||||
|
|
|
@ -10,6 +10,7 @@ import {
|
||||||
localizePath,
|
localizePath,
|
||||||
DEFAULT_BUILD_DIR_NAME,
|
DEFAULT_BUILD_DIR_NAME,
|
||||||
GENERATED_FILES_DIR_NAME,
|
GENERATED_FILES_DIR_NAME,
|
||||||
|
getCurrentLocaleConfig,
|
||||||
} from '@docusaurus/utils';
|
} from '@docusaurus/utils';
|
||||||
import {PerfLogger} from '@docusaurus/logger';
|
import {PerfLogger} from '@docusaurus/logger';
|
||||||
import combinePromises from 'combine-promises';
|
import combinePromises from 'combine-promises';
|
||||||
|
@ -113,7 +114,7 @@ export async function loadContext(
|
||||||
const localizationDir = path.resolve(
|
const localizationDir = path.resolve(
|
||||||
siteDir,
|
siteDir,
|
||||||
i18n.path,
|
i18n.path,
|
||||||
i18n.localeConfigs[i18n.currentLocale]!.path,
|
getCurrentLocaleConfig(i18n).path,
|
||||||
);
|
);
|
||||||
|
|
||||||
const siteConfig: DocusaurusConfig = {...initialSiteConfig, baseUrl};
|
const siteConfig: DocusaurusConfig = {...initialSiteConfig, baseUrl};
|
||||||
|
|
|
@ -11,6 +11,7 @@ import {BundleAnalyzerPlugin} from 'webpack-bundle-analyzer';
|
||||||
import ReactLoadableSSRAddon from 'react-loadable-ssr-addon-v5-slorber';
|
import ReactLoadableSSRAddon from 'react-loadable-ssr-addon-v5-slorber';
|
||||||
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
||||||
import {getProgressBarPlugin} from '@docusaurus/bundler';
|
import {getProgressBarPlugin} from '@docusaurus/bundler';
|
||||||
|
import {getCurrentLocaleConfig} from '@docusaurus/utils';
|
||||||
import {createBaseConfig} from './base';
|
import {createBaseConfig} from './base';
|
||||||
import ChunkAssetPlugin from './plugins/ChunkAssetPlugin';
|
import ChunkAssetPlugin from './plugins/ChunkAssetPlugin';
|
||||||
import ForceTerminatePlugin from './plugins/ForceTerminatePlugin';
|
import ForceTerminatePlugin from './plugins/ForceTerminatePlugin';
|
||||||
|
@ -117,7 +118,7 @@ export async function createStartClientConfig({
|
||||||
headTags,
|
headTags,
|
||||||
preBodyTags,
|
preBodyTags,
|
||||||
postBodyTags,
|
postBodyTags,
|
||||||
lang: props.i18n.localeConfigs[props.i18n.currentLocale]!.htmlLang,
|
lang: getCurrentLocaleConfig(props.i18n).htmlLang,
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue