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 {
6
6
isChapter ,
7
7
} from " ../../../.vitepress/theme/constrants/route" ;
8
8
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
+
9
19
const { chapter : chapter_root, root = true } = defineProps <{
10
20
// 参数chapter应该是如 Chapter.xrobot_device这样的
11
21
chapter: Chapters ;
12
22
// root用于控制递归生成目录
13
23
root? : boolean ;
14
24
}>();
15
25
26
+ const { site } = useData ();
27
+ const base = site .value .base ;
28
+
16
29
// console.log("contents");
17
30
let chapter_name: string [] = [];
18
31
let tocs: { link: string ; text: string }[][] = [];
@@ -61,7 +74,7 @@ if (!items) {
61
74
:chapter =" item.link as Chapters"
62
75
></ChapterContents >
63
76
</ol >
64
- <a v-else :href =" item.link" >{{ item.text }}</a >
77
+ <a v-else :href =" apply_prefix( item.link, base) " >{{ item.text }}</a >
65
78
</li >
66
79
</ol >
67
80
</div >
You can’t perform that action at this time.
0 commit comments