File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
docs/.vitepress/theme/components Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -6,13 +6,26 @@ import {
66 isChapter ,
77} from " ../../../.vitepress/theme/constrants/route" ;
88
9+ function apply_prefix(link : string , prefix : string ) {
10+ if (! prefix ) return link ;
11+ if (link .startsWith (" /" ) && prefix .endsWith (" /" )) {
12+ return prefix .slice (0 , - 1 ) + link ;
13+ } else if (! link .startsWith (" /" ) && ! prefix .endsWith (" /" )) {
14+ return prefix + " /" + link ;
15+ }
16+ return prefix + link ;
17+ }
18+
919const { chapter : chapter_root, root = true } = defineProps <{
1020 // 参数chapter应该是如 Chapter.xrobot_device这样的
1121 chapter: Chapters ;
1222 // root用于控制递归生成目录
1323 root? : boolean ;
1424}>();
1525
26+ const { site } = useData ();
27+ const base = site .value .base ;
28+
1629// console.log("contents");
1730let chapter_name: string [] = [];
1831let tocs: { link: string ; text: string }[][] = [];
@@ -61,7 +74,7 @@ if (!items) {
6174 :chapter =" item.link as Chapters"
6275 ></ChapterContents >
6376 </ol >
64- <a v-else :href =" item.link" >{{ item.text }}</a >
77+ <a v-else :href =" apply_prefix( item.link, base) " >{{ item.text }}</a >
6578 </li >
6679 </ol >
6780 </div >
You can’t perform that action at this time.
0 commit comments