fix(content-docs): make category index text translatable (#7233)

This commit is contained in:
Joshua Chen 2022-04-27 23:40:15 +08:00 committed by GitHub
parent 996901b53b
commit 10a5ebecec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 121 additions and 104 deletions

View file

@ -7,8 +7,8 @@
import _ from 'lodash';
import type {Sidebars} from './sidebars/types';
import {createSidebarsUtils} from './sidebars/utils';
import type {LoadedVersion} from './types';
import {getMainDocId} from './docs';
import type {FullVersion} from './types';
import type {
CategoryGeneratedIndexMetadata,
DocMetadata,
@ -39,11 +39,10 @@ function toGlobalDataGeneratedIndex(
function toGlobalSidebars(
sidebars: Sidebars,
version: LoadedVersion,
version: FullVersion,
): {[sidebarId: string]: GlobalSidebar} {
const {getFirstLink} = createSidebarsUtils(sidebars);
return _.mapValues(sidebars, (sidebar, sidebarId) => {
const firstLink = getFirstLink(sidebarId);
const firstLink = version.sidebarsUtils.getFirstLink(sidebarId);
if (!firstLink) {
return {};
}
@ -62,13 +61,13 @@ function toGlobalSidebars(
});
}
export function toGlobalDataVersion(version: LoadedVersion): GlobalVersion {
export function toGlobalDataVersion(version: FullVersion): GlobalVersion {
return {
name: version.versionName,
label: version.label,
isLast: version.isLast,
path: version.path,
mainDocId: version.mainDocId,
mainDocId: getMainDocId(version),
docs: version.docs
.map(toGlobalDataDoc)
.concat(version.categoryGeneratedIndices.map(toGlobalDataGeneratedIndex)),