Disable localization in all content plugins

This commit is contained in:
sebastien 2025-07-03 17:08:10 +02:00
parent 0924b8baa6
commit ae4637bec5
8 changed files with 77 additions and 64 deletions

View file

@ -186,11 +186,16 @@ export async function getVersionMetadataPaths({
>
> {
const isCurrent = versionName === CURRENT_VERSION_NAME;
const contentPathLocalized = getDocsDirPathLocalized({
localizationDir: context.localizationDir,
pluginId: options.id,
versionName,
});
const shouldTranslate = false; // TODO wire this properly
const contentPathLocalized = shouldTranslate
? getDocsDirPathLocalized({
localizationDir: context.localizationDir,
pluginId: options.id,
versionName,
})
: undefined;
const contentPath = isCurrent
? path.resolve(context.siteDir, options.path)
: getVersionDocsDirPath(context.siteDir, options.id, versionName);

View file

@ -50,33 +50,47 @@ function getVersionEditUrls({
return {editUrl: undefined, editUrlLocalized: undefined};
}
const editDirPath = options.editCurrentVersion ? options.path : contentPath;
const editDirPathLocalized = options.editCurrentVersion
? getDocsDirPathLocalized({
localizationDir: context.localizationDir,
versionName: CURRENT_VERSION_NAME,
pluginId: options.id,
})
: contentPathLocalized;
// Intermediate var just to please TS not narrowing to "string"
const editUrlOption = options.editUrl;
const versionPathSegment = posixPath(
path.relative(context.siteDir, path.resolve(context.siteDir, editDirPath)),
);
const versionPathSegmentLocalized = posixPath(
path.relative(
context.siteDir,
path.resolve(context.siteDir, editDirPathLocalized),
),
);
const getEditUrl = () => {
const editDirPath = options.editCurrentVersion ? options.path : contentPath;
const editUrl = normalizeUrl([options.editUrl, versionPathSegment]);
return normalizeUrl([
editUrlOption,
posixPath(
path.relative(
context.siteDir,
path.resolve(context.siteDir, editDirPath),
),
),
]);
};
const editUrlLocalized = normalizeUrl([
options.editUrl,
versionPathSegmentLocalized,
]);
const getEditUrlLocalized = () => {
if (!contentPathLocalized) {
return undefined;
}
const editDirPathLocalized = options.editCurrentVersion
? getDocsDirPathLocalized({
localizationDir: context.localizationDir,
versionName: CURRENT_VERSION_NAME,
pluginId: options.id,
})
: contentPathLocalized;
return {editUrl, editUrlLocalized};
return normalizeUrl([
editUrlOption,
posixPath(
path.relative(
context.siteDir,
path.resolve(context.siteDir, editDirPathLocalized),
),
),
]);
};
return {editUrl: getEditUrl(), editUrlLocalized: getEditUrlLocalized()};
}
/**