Skip to content

Commit 6c3eac6

Browse files
authored
Merge pull request #2 from srsng/main
8.5日 调整文档结构、内容
2 parents 00b70fd + a63b6ee commit 6c3eac6

File tree

142 files changed

+847
-561
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

142 files changed

+847
-561
lines changed

.markdownlint.jsonc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"no-reversed-links": false,
3+
"line-length": false,
4+
"no-inline-html": false,
5+
"first-line-h1": false
6+
}

docs/.vitepress/config.mts

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import { defineConfig } from "vitepress";
2-
import { ChapterItems, Chapters } from "./theme/constrants/route";
2+
import { Chapters, getChapterItems } from "./theme/constrants/route";
33
import autoH1 from "./plugins/autoH1";
44

5+
// 限制sidebar最多深入两层章节
6+
const sidebarItems = getChapterItems(1, 2);
7+
58
// https://vitepress.dev/reference/site-config
69
export default defineConfig({
710
title: "灵矽文档中心",
@@ -24,22 +27,12 @@ export default defineConfig({
2427
outline: [2, 4],
2528
nav: [
2629
{ text: "主页", link: "/" },
27-
{ text: "设备操作指南", link: Chapters.xrobot_device },
30+
{ text: "开发文档", link: Chapters.xrobot_platform },
2831
{ text: "API参考", link: Chapters.xrobot_api },
32+
{ text: "最佳实践", link: Chapters.xrobot_platform_esp32 },
2933
{ text: "FAQ", link: Chapters.xrobot_faq },
3034
],
31-
sidebar: {
32-
"/": [
33-
{
34-
text: "Examples",
35-
items: [
36-
{ text: "Markdown Examples", link: "/markdown-examples" },
37-
{ text: "Runtime API Examples", link: "/api-examples" },
38-
],
39-
},
40-
],
41-
...ChapterItems,
42-
},
35+
sidebar: sidebarItems,
4336
socialLinks: [
4437
{
4538
icon: "github",

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

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<script setup lang="ts">
2+
import { useData } from "vitepress";
23
import {
34
ChapterItems,
45
Chapters,
@@ -16,27 +17,43 @@ const { chapter: chapter_root, root = true } = defineProps<{
1617
let chapter_name: string[] = [];
1718
let tocs: { link: string; text: string }[][] = [];
1819
19-
// console.log(chapter_root);
20+
// console.log("chapter_root", chapter_root);
21+
// console.log("ChapterItems[chapter_root]", ChapterItems[chapter_root]);
2022
21-
ChapterItems[chapter_root]?.forEach((subchapter) => {
22-
const t = subchapter.items?.filter((item) => {
23-
return item.link !== chapter_root && !item.goback;
23+
const items = ChapterItems[chapter_root];
24+
if (!items) {
25+
const { page } = useData();
26+
console.warn(
27+
"Error at gen ChapterContents, chapter_root:",
28+
chapter_root,
29+
"filePath:",
30+
page.value.filePath,
31+
"title:",
32+
page.value.title
33+
);
34+
} else {
35+
items.forEach((subchapter) => {
36+
// console.log(subchapter);
37+
const t = subchapter.items?.filter((item) => {
38+
return item.link !== chapter_root && !item.goback;
39+
});
40+
if (t) {
41+
tocs.push(t);
42+
chapter_name.push(subchapter.text);
43+
}
2444
});
25-
if (t) {
26-
tocs.push(t);
27-
chapter_name.push(subchapter.text);
28-
}
29-
});
45+
}
3046
3147
// console.log("chapter_name:", chapter_name);
3248
// console.log("tocs:", tocs);
3349
</script>
3450

3551
<template>
36-
<h1 v-if="root">目录</h1>
52+
<h2 v-if="root">目录</h2>
3753
<div v-for="(subchapter, index) in tocs">
38-
<h2>{{ chapter_name[index] }}</h2>
39-
<ol>
54+
<h3>{{ chapter_name[index] }}</h3>
55+
<div v-if="subchapter.length === 0"><span>暂无内容</span></div>
56+
<ol v-else>
4057
<li v-for="(item, index2) in subchapter" :key="item.link">
4158
<ol v-if="isChapter(item.link)">
4259
<ChapterContents

0 commit comments

Comments
 (0)