Skip to content

Commit ed2735a

Browse files
committed
新增标题
1 parent e1f98a7 commit ed2735a

File tree

6 files changed

+33
-5
lines changed

6 files changed

+33
-5
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ yarn.lock
55
/dist
66

77
docs/.vitepress/cache/
8-
8+
docs/.vitepress/dist/
99
*.mov
1010

1111
test/

README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,17 @@ yarn
1010

1111
```shell
1212
yarn docs:dev
13-
// 浏览器打开
14-
http://localhost:5173
13+
```
14+
浏览器打开 http://localhost:5173
15+
16+
## 部署
17+
18+
```shell
19+
yarn docs:build
20+
```
21+
22+
本地预览,执行下列命令后,浏览器打开 http://localhost:4173
23+
```shell
24+
yarn docs:preview
1525
```
1626

docs/.vitepress/config.mts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { defineConfig } from "vitepress";
22
import { ChapterItems, Chapters } from "./theme/constrants/route";
3+
import autoH1 from "./plugins/autoH1";
34

45
// https://vitepress.dev/reference/site-config
56
export default defineConfig({
@@ -48,5 +49,8 @@ export default defineConfig({
4849
toc: {
4950
level: [1, 2, 3, 4],
5051
},
52+
config: (md) => {
53+
md.use(autoH1);
54+
},
5155
},
5256
});

docs/.vitepress/plugins/autoH1.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
export default (md) => {
2+
const hasH1 = (content) => /^\s*#\s+.+/m.test(content);
3+
4+
md.core.ruler.before("normalize", "auto_add_h1", (state) => {
5+
const { frontmatter } = state.env;
6+
const src = state.src;
7+
if (frontmatter?.title && !hasH1(src)) {
8+
state.src = `# ${frontmatter.title}\n\n` + src;
9+
}
10+
return false;
11+
});
12+
};

docs/.vitepress/theme/layout.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const { Layout } = DefaultTheme;
66

77
<template>
88
<Layout>
9+
<!-- <template #not-found> 404 not-found </template> -->
910
<!-- <template #home-hero-image> </template> -->
1011
</Layout>
1112
</template>

docs/xrobot/api/api.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: 通过 API 来绑定设备
33
---
4+
45
## 1. 用户注册
56

67
```plain
@@ -227,6 +228,6 @@ authorization Bearer 4fxxxxxxxxxxxxxxxxxxxxxxx
227228
228229
```
229230

230-
# 11. 声音复刻
231+
## 11. 声音复刻
231232

232-
[声音复刻](./voice-clone.md)
233+
[声音复刻](./voice-clone.md)

0 commit comments

Comments
 (0)