Skip to content

Commit 2f32a85

Browse files
committed
chores
1 parent 4cf5a8e commit 2f32a85

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

docs/.vitepress/theme/components/ChapterContents.vue

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,12 @@
11
<script setup lang="ts">
22
import { useData } from "vitepress";
33
import {
4+
ChapterItem,
45
ChapterItems,
56
Chapters,
67
isChapter,
78
} from "../../../.vitepress/theme/constrants/route";
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-
}
9+
import { apply_prefix } from "../utils";
1810
1911
const { chapter: chapter_root, root = true } = defineProps<{
2012
// 参数chapter应该是如 Chapter.xrobot_device这样的
@@ -28,12 +20,13 @@ const base = site.value.base;
2820
2921
// console.log("contents");
3022
let chapter_name: string[] = [];
31-
let tocs: { link: string; text: string }[][] = [];
23+
let tocs: ChapterItem[][] = [];
3224
3325
// console.log("chapter_root", chapter_root);
3426
// console.log("ChapterItems[chapter_root]", ChapterItems[chapter_root]);
3527
36-
const items = ChapterItems[chapter_root];
28+
const items: ChapterItem[] = ChapterItems[chapter_root];
29+
3730
if (!items) {
3831
const { page } = useData();
3932
console.warn(

0 commit comments

Comments
 (0)