Skip to content

Commit ba15b3a

Browse files
committed
feat: add filterTOC function for language-specific navigation filtering
- Introduced filterTOC to filter navigation links based on the selected language, specifically blocking certain links for Japanese. - Updated DocTemplate to utilize filterTOC for improved navigation handling based on language context.
1 parent 1dc169a commit ba15b3a

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

src/shared/filterTOC.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { Locale, RepoNav, RepoNavLink } from "./interface";
2+
3+
const BLOCK_NAVS = [
4+
"/ja/tidbcloud/set-up-private-endpoint-connections-on-alibaba-cloud",
5+
];
6+
7+
export const filterTOC = (navs?: RepoNavLink[]): RepoNav => {
8+
if (!navs) return [];
9+
10+
return navs.filter((item) => {
11+
item.children = filterTOC(item.children);
12+
return !BLOCK_NAVS.includes(item.link || "");
13+
});
14+
};

src/templates/DocTemplate.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import {
3636
useCloudPlan,
3737
useCloudPlanNavigate,
3838
} from "shared/useCloudPlan";
39+
import { filterTOC } from "shared/filterTOC";
3940

4041
interface DocTemplateProps {
4142
pageContext: PageContext & {
@@ -116,11 +117,13 @@ function DocTemplate({
116117
const essentialNavigation = essentialNav
117118
? essentialNav.essentialNavigation
118119
: [];
119-
const navigation = isStarter
120-
? starterNavigation
121-
: isEssential
122-
? essentialNavigation
123-
: classicNavigation;
120+
const navigation = filterTOC(
121+
isStarter
122+
? starterNavigation
123+
: isEssential
124+
? essentialNavigation
125+
: classicNavigation
126+
);
124127

125128
const { language } = useI18next();
126129
const haveStarter = starterNavigation.length > 0;

0 commit comments

Comments
 (0)