mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-23 03:29:11 +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,
|
||||
getFileCommitDate,
|
||||
LAST_UPDATE_FALLBACK,
|
||||
getCurrentLocaleConfig,
|
||||
} from '@docusaurus/utils';
|
||||
import {DEFAULT_FUTURE_CONFIG} from '@docusaurus/core/src/server/configValidation';
|
||||
import pluginContentBlog from '../index';
|
||||
|
@ -100,7 +101,7 @@ const getPlugin = async (
|
|||
const localizationDir = path.join(
|
||||
siteDir,
|
||||
i18n.path,
|
||||
i18n.localeConfigs[i18n.currentLocale]!.path,
|
||||
getCurrentLocaleConfig(i18n).path,
|
||||
);
|
||||
const siteConfig = {
|
||||
title: 'Hello',
|
||||
|
|
|
@ -19,6 +19,7 @@ import {
|
|||
getDataFilePath,
|
||||
DEFAULT_PLUGIN_ID,
|
||||
resolveMarkdownLinkPathname,
|
||||
getCurrentLocaleConfig,
|
||||
} from '@docusaurus/utils';
|
||||
import {getTagsFilePathsToWatch} from '@docusaurus/utils-validation';
|
||||
import {createMDXLoaderItem} from '@docusaurus/mdx-loader';
|
||||
|
@ -73,10 +74,10 @@ export default async function pluginContentBlog(
|
|||
|
||||
const {baseUrl} = siteConfig;
|
||||
|
||||
const shouldLocalize = false;
|
||||
const shouldTranslate = getCurrentLocaleConfig(context.i18n).translate;
|
||||
const contentPaths: BlogContentPaths = {
|
||||
contentPath: path.resolve(siteDir, options.path),
|
||||
contentPathLocalized: shouldLocalize
|
||||
contentPathLocalized: shouldTranslate
|
||||
? getPluginI18nPath({
|
||||
localizationDir,
|
||||
pluginName: PluginName,
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
import fs from 'fs-extra';
|
||||
import path from 'path';
|
||||
import logger from '@docusaurus/logger';
|
||||
import {DEFAULT_PLUGIN_ID} from '@docusaurus/utils';
|
||||
import {DEFAULT_PLUGIN_ID, getCurrentLocaleConfig} from '@docusaurus/utils';
|
||||
import {
|
||||
getVersionsFilePath,
|
||||
getVersionDocsDirPath,
|
||||
|
@ -89,7 +89,7 @@ async function cliDocsVersionCommand(
|
|||
const localizationDir = path.resolve(
|
||||
siteDir,
|
||||
i18n.path,
|
||||
i18n.localeConfigs[locale]!.path,
|
||||
getCurrentLocaleConfig(i18n).path,
|
||||
);
|
||||
// Copy docs files.
|
||||
const docsDir =
|
||||
|
|
|
@ -7,7 +7,11 @@
|
|||
|
||||
import path from 'path';
|
||||
import fs from 'fs-extra';
|
||||
import {getPluginI18nPath, DEFAULT_PLUGIN_ID} from '@docusaurus/utils';
|
||||
import {
|
||||
getPluginI18nPath,
|
||||
DEFAULT_PLUGIN_ID,
|
||||
getCurrentLocaleConfig,
|
||||
} from '@docusaurus/utils';
|
||||
import {
|
||||
VERSIONS_JSON_FILE,
|
||||
VERSIONED_DOCS_DIR,
|
||||
|
@ -187,7 +191,7 @@ export async function getVersionMetadataPaths({
|
|||
> {
|
||||
const isCurrent = versionName === CURRENT_VERSION_NAME;
|
||||
|
||||
const shouldTranslate = false; // TODO wire this properly
|
||||
const shouldTranslate = getCurrentLocaleConfig(context.i18n).translate;
|
||||
const contentPathLocalized = shouldTranslate
|
||||
? getDocsDirPathLocalized({
|
||||
localizationDir: context.localizationDir,
|
||||
|
|
|
@ -23,6 +23,7 @@ import {
|
|||
getPluginI18nPath,
|
||||
getContentPathList,
|
||||
type ContentPaths,
|
||||
getCurrentLocaleConfig,
|
||||
} from '@docusaurus/utils';
|
||||
import {validatePageFrontMatter} from './frontMatter';
|
||||
import type {LoadContext} from '@docusaurus/types';
|
||||
|
@ -41,10 +42,10 @@ export function createPagesContentPaths({
|
|||
}): ContentPaths {
|
||||
const {siteDir, localizationDir} = context;
|
||||
|
||||
const shouldLocalize = false;
|
||||
const shouldTranslate = getCurrentLocaleConfig(context.i18n).translate;
|
||||
return {
|
||||
contentPath: path.resolve(siteDir, options.path),
|
||||
contentPathLocalized: shouldLocalize
|
||||
contentPathLocalized: shouldTranslate
|
||||
? getPluginI18nPath({
|
||||
localizationDir,
|
||||
pluginName: 'docusaurus-plugin-content-pages',
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
import {PerfLogger} from '@docusaurus/logger';
|
||||
import {getCurrentLocaleConfig} from '@docusaurus/utils';
|
||||
import {initPlugins} from './init';
|
||||
import {createBootstrapPlugin, createMDXFallbackPlugin} from './synthetic';
|
||||
import {localizePluginTranslationFile} from '../translations/translations';
|
||||
|
@ -81,8 +82,7 @@ async function executePluginContentLoading({
|
|||
plugin.loadContent?.(),
|
||||
);
|
||||
|
||||
// TODO wire
|
||||
const shouldTranslate = false;
|
||||
const shouldTranslate = getCurrentLocaleConfig(context.i18n).translate;
|
||||
|
||||
if (shouldTranslate) {
|
||||
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 =
|
||||
(await PerfLogger.async('getDefaultCodeTranslationMessages()', () =>
|
||||
plugin.getDefaultCodeTranslationMessages?.(),
|
||||
|
|
|
@ -10,6 +10,7 @@ import {
|
|||
localizePath,
|
||||
DEFAULT_BUILD_DIR_NAME,
|
||||
GENERATED_FILES_DIR_NAME,
|
||||
getCurrentLocaleConfig,
|
||||
} from '@docusaurus/utils';
|
||||
import {PerfLogger} from '@docusaurus/logger';
|
||||
import combinePromises from 'combine-promises';
|
||||
|
@ -113,7 +114,7 @@ export async function loadContext(
|
|||
const localizationDir = path.resolve(
|
||||
siteDir,
|
||||
i18n.path,
|
||||
i18n.localeConfigs[i18n.currentLocale]!.path,
|
||||
getCurrentLocaleConfig(i18n).path,
|
||||
);
|
||||
|
||||
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 HtmlWebpackPlugin from 'html-webpack-plugin';
|
||||
import {getProgressBarPlugin} from '@docusaurus/bundler';
|
||||
import {getCurrentLocaleConfig} from '@docusaurus/utils';
|
||||
import {createBaseConfig} from './base';
|
||||
import ChunkAssetPlugin from './plugins/ChunkAssetPlugin';
|
||||
import ForceTerminatePlugin from './plugins/ForceTerminatePlugin';
|
||||
|
@ -117,7 +118,7 @@ export async function createStartClientConfig({
|
|||
headTags,
|
||||
preBodyTags,
|
||||
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