create-react-docs-ui 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +85 -82
- package/package.json +15 -2
- package/template/index.html +3 -2
- package/template/public/config/site.en.yaml +7 -7
- package/template/public/config/site.yaml +7 -7
- package/template/public/docs/en/guide/configuration.md +149 -122
- package/template/public/docs/en/guide/quick-start.md +107 -108
- package/template/public/docs/zh-cn/guide/configuration.md +150 -122
- package/template/public/docs/zh-cn/guide/quick-start.md +107 -108
package/README.md
CHANGED
|
@@ -1,82 +1,85 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
1
|
+
English | [简体中文](README-zh.md)
|
|
2
|
+
|
|
3
|
+
## create-react-docs-ui
|
|
4
|
+
|
|
5
|
+
Scaffold a React documentation site in seconds, powered by [`react-docs-ui`](https://github.com/shenjianZ/react-docs-ui). Focus on writing Markdown; routing, theming, MDX, syntax highlighting, i18n, sidebar/TOC and a command menu are prewired.
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
- Configuration over code via `public/config/site.yaml`
|
|
9
|
+
- MD/MDX rendering, syntax highlight, GFM, simple frontmatter parsing
|
|
10
|
+
- Light/dark theme and command palette (Cmd/Ctrl+K)
|
|
11
|
+
- Built-in i18n folders (e.g. `en`, `zh-cn`)
|
|
12
|
+
- Ready-to-run Vite setup
|
|
13
|
+
|
|
14
|
+
### Requirements
|
|
15
|
+
- Node.js >= 18
|
|
16
|
+
|
|
17
|
+
### Quick start
|
|
18
|
+
- npm:
|
|
19
|
+
```bash
|
|
20
|
+
npm create react-docs-ui@latest my-docs
|
|
21
|
+
```
|
|
22
|
+
- yarn:
|
|
23
|
+
```bash
|
|
24
|
+
yarn create react-docs-ui my-docs
|
|
25
|
+
```
|
|
26
|
+
- pnpm:
|
|
27
|
+
```bash
|
|
28
|
+
pnpm create react-docs-ui my-docs
|
|
29
|
+
```
|
|
30
|
+
Then:
|
|
31
|
+
```bash
|
|
32
|
+
cd my-docs
|
|
33
|
+
npm install
|
|
34
|
+
npm run dev
|
|
35
|
+
```
|
|
36
|
+
Dev server runs at http://localhost:5173
|
|
37
|
+
|
|
38
|
+
### Scripts (generated project)
|
|
39
|
+
- `dev`: start Vite dev server
|
|
40
|
+
- `build`: type-check and build
|
|
41
|
+
- `preview`: preview production build
|
|
42
|
+
|
|
43
|
+
### Project structure (generated)
|
|
44
|
+
- `public/config/site.yaml` and `public/config/site.en.yaml`: site config per language
|
|
45
|
+
- `public/docs/<lang>/**/*.md`: Markdown docs, matched by route slug
|
|
46
|
+
- `src/`: app entry; usually no changes required
|
|
47
|
+
|
|
48
|
+
### Config example (`public/config/site.yaml`)
|
|
49
|
+
```yaml
|
|
50
|
+
site:
|
|
51
|
+
logo: /logo.svg
|
|
52
|
+
title: My Docs
|
|
53
|
+
description: Awesome docs
|
|
54
|
+
navbar:
|
|
55
|
+
showTitle: true
|
|
56
|
+
items:
|
|
57
|
+
- title: GitHub
|
|
58
|
+
link: https://github.com/shenjianZ/react-docs-ui
|
|
59
|
+
external: true
|
|
60
|
+
sidebar:
|
|
61
|
+
collections:
|
|
62
|
+
guide:
|
|
63
|
+
sections:
|
|
64
|
+
- title: Getting Started
|
|
65
|
+
path: guide
|
|
66
|
+
children:
|
|
67
|
+
- { title: Introduction, path: guide/introduction }
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Docs example (`public/docs/en/guide/introduction.md`)
|
|
71
|
+
```markdown
|
|
72
|
+
---
|
|
73
|
+
title: Introduction
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
# Introduction
|
|
77
|
+
|
|
78
|
+
Welcome to My Docs!
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Links
|
|
82
|
+
- Underlying UI library: `react-docs-ui` — https://github.com/shenjianZ/react-docs-ui
|
|
83
|
+
|
|
84
|
+
### License
|
|
85
|
+
[MIT](LICENSE)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-react-docs-ui",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -19,7 +19,20 @@
|
|
|
19
19
|
"template/vite.config.ts",
|
|
20
20
|
"README.md"
|
|
21
21
|
],
|
|
22
|
-
"description": "Scaffold a React
|
|
22
|
+
"description": "Scaffold a React documentation site with one command — built-in routing, theming, MDX, examples, and production-ready build config, powered by react-docs-ui.",
|
|
23
|
+
"homepage": "https://github.com/shenjianZ/create-react-docs-ui",
|
|
24
|
+
"keywords": [
|
|
25
|
+
"react",
|
|
26
|
+
"cli",
|
|
27
|
+
"scaffolding",
|
|
28
|
+
"starter",
|
|
29
|
+
"template",
|
|
30
|
+
"docs",
|
|
31
|
+
"documentation",
|
|
32
|
+
"mdx",
|
|
33
|
+
"boilerplate",
|
|
34
|
+
"create-tool"
|
|
35
|
+
],
|
|
23
36
|
"license": "MIT"
|
|
24
37
|
}
|
|
25
38
|
|
package/template/index.html
CHANGED
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
<html lang="en">
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
|
+
<link rel="icon" type="image/svg+xml" href="/images/favicon.svg" />
|
|
5
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
-
<title>
|
|
7
|
+
<title>Docs</title>
|
|
7
8
|
</head>
|
|
8
9
|
<body>
|
|
9
10
|
<div id="root"></div>
|
|
10
11
|
<script type="module" src="/src/main.tsx"></script>
|
|
11
12
|
</body>
|
|
12
|
-
|
|
13
|
+
</html>
|
|
13
14
|
|
|
14
15
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Website Configuration
|
|
2
2
|
site:
|
|
3
|
-
title: "
|
|
4
|
-
description: "Example documentation website built with
|
|
3
|
+
title: "React Docs UI Example"
|
|
4
|
+
description: "Example documentation website built with React Docs UI"
|
|
5
5
|
# Logo formats supported:
|
|
6
6
|
# 1. emoji: "🤖"
|
|
7
7
|
# 2. image URL: "https://example.com/logo.png"
|
|
@@ -10,7 +10,7 @@ site:
|
|
|
10
10
|
logo:
|
|
11
11
|
light: "/images/favicon.svg"
|
|
12
12
|
dark: "/images/favicon-dark.svg"
|
|
13
|
-
author: "
|
|
13
|
+
author: "React Docs UI Team"
|
|
14
14
|
|
|
15
15
|
# Navigation Bar Configuration
|
|
16
16
|
navbar:
|
|
@@ -25,7 +25,7 @@ navbar:
|
|
|
25
25
|
link: "/guide"
|
|
26
26
|
actions:
|
|
27
27
|
- type: "github"
|
|
28
|
-
link: "https://github.com/shenjianZ/
|
|
28
|
+
link: "https://github.com/shenjianZ/React-docs-ui"
|
|
29
29
|
enabled: true
|
|
30
30
|
|
|
31
31
|
# Sidebar Navigation Configuration
|
|
@@ -73,7 +73,7 @@ toc:
|
|
|
73
73
|
# Footer Configuration
|
|
74
74
|
footer:
|
|
75
75
|
enabled: true
|
|
76
|
-
copyright: "© 2024
|
|
76
|
+
copyright: "© 2024 React Docs UI. All rights reserved."
|
|
77
77
|
repository:
|
|
78
78
|
url: "https://github.com/your_github_id/your_repo_name"
|
|
79
79
|
branch: "master"
|
|
@@ -130,8 +130,8 @@ footer:
|
|
|
130
130
|
# PWA Configuration
|
|
131
131
|
pwa:
|
|
132
132
|
enabled: false
|
|
133
|
-
name: "
|
|
134
|
-
shortName: "
|
|
133
|
+
name: "React Docs UI"
|
|
134
|
+
shortName: "ReactDocsUI"
|
|
135
135
|
description: "Beautiful documentation websites made simple"
|
|
136
136
|
themeColor: "#ffffff"
|
|
137
137
|
backgroundColor: "#ffffff"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# 网站基本配置
|
|
2
2
|
site:
|
|
3
|
-
title: "
|
|
4
|
-
description: "基于
|
|
3
|
+
title: "React Docs UI 示例项目"
|
|
4
|
+
description: "基于 React Docs UI 构建的文档网站示例"
|
|
5
5
|
# logo支持以下格式:
|
|
6
6
|
# 1. emoji: "🤖"
|
|
7
7
|
# 2. 图片URL: "https://example.com/logo.png"
|
|
@@ -10,7 +10,7 @@ site:
|
|
|
10
10
|
logo:
|
|
11
11
|
light: "/images/favicon.svg"
|
|
12
12
|
dark: "/images/favicon-dark.svg"
|
|
13
|
-
author: "
|
|
13
|
+
author: "React Docs UI Team"
|
|
14
14
|
|
|
15
15
|
# 顶部导航配置
|
|
16
16
|
navbar:
|
|
@@ -25,7 +25,7 @@ navbar:
|
|
|
25
25
|
link: "/guide"
|
|
26
26
|
actions:
|
|
27
27
|
- type: "github"
|
|
28
|
-
link: "https://github.com/shenjianZ/
|
|
28
|
+
link: "https://github.com/shenjianZ/React-docs-ui"
|
|
29
29
|
enabled: true
|
|
30
30
|
|
|
31
31
|
# 侧边栏导航配置
|
|
@@ -73,7 +73,7 @@ toc:
|
|
|
73
73
|
# Footer Configuration
|
|
74
74
|
footer:
|
|
75
75
|
enabled: true
|
|
76
|
-
copyright: "© 2024
|
|
76
|
+
copyright: "© 2024 React Docs UI. All rights reserved."
|
|
77
77
|
repository:
|
|
78
78
|
url: "https://github.com/your_github_id/your_repo_name"
|
|
79
79
|
branch: "master"
|
|
@@ -130,8 +130,8 @@ footer:
|
|
|
130
130
|
# PWA Configuration
|
|
131
131
|
pwa:
|
|
132
132
|
enabled: true
|
|
133
|
-
name: "
|
|
134
|
-
shortName: "
|
|
133
|
+
name: "React Docs UI"
|
|
134
|
+
shortName: "ReactDocsUI"
|
|
135
135
|
description: "Beautiful documentation websites made simple"
|
|
136
136
|
themeColor: "#ffffff"
|
|
137
137
|
backgroundColor: "#ffffff"
|
|
@@ -1,122 +1,149 @@
|
|
|
1
|
-
# Configuration File (`site.yaml`) Explained
|
|
2
|
-
|
|
3
|
-
The
|
|
4
|
-
|
|
5
|
-
## Top-
|
|
6
|
-
|
|
7
|
-
|
|
|
8
|
-
|
|
|
9
|
-
| `
|
|
10
|
-
| `
|
|
11
|
-
| `
|
|
12
|
-
| `
|
|
13
|
-
| `footer` |
|
|
14
|
-
| `
|
|
15
|
-
|
|
16
|
-
---
|
|
17
|
-
|
|
18
|
-
## `site`
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
|
23
|
-
|
|
|
24
|
-
| `
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
|
48
|
-
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
|
70
|
-
|
|
|
71
|
-
| `
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
|
76
|
-
|
|
|
77
|
-
| `
|
|
78
|
-
| `
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
| Field | Description | Example |
|
|
98
|
-
|
|
|
99
|
-
| `
|
|
100
|
-
| `
|
|
101
|
-
| `
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
|
109
|
-
|
|
|
110
|
-
| `
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
| Field | Description | Example |
|
|
119
|
-
|
|
|
120
|
-
| `
|
|
121
|
-
| `
|
|
122
|
-
|
|
1
|
+
# Configuration File (`site.yaml`) Explained
|
|
2
|
+
|
|
3
|
+
The project is configuration-driven. Most behavior is defined in `public/config/site.yaml`. This page documents every field using concise tables.
|
|
4
|
+
|
|
5
|
+
## Top-level keys
|
|
6
|
+
| Key | Purpose |
|
|
7
|
+
| :-- | :-- |
|
|
8
|
+
| `site` | Global metadata like title, description, logo, author |
|
|
9
|
+
| `navbar` | Top navigation bar (logo/title toggles, items, actions) |
|
|
10
|
+
| `sidebar` | Left navigation tree (collections/sections/children) |
|
|
11
|
+
| `theme` | Theme options (default mode, toggle) |
|
|
12
|
+
| `toc` | Article table of contents (enabled, levels, title) |
|
|
13
|
+
| `footer` | Footer links, socials, repository meta |
|
|
14
|
+
| `pwa` | Progressive Web App settings (reserved/optional) |
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## `site`
|
|
19
|
+
| Field | Type | Description | Example |
|
|
20
|
+
| :-- | :-- | :-- | :-- |
|
|
21
|
+
| `title` | string | Site title | `"React Docs UI Example"` |
|
|
22
|
+
| `description` | string | Short site description (SEO) | `"Beautiful docs made simple"` |
|
|
23
|
+
| `logo` | string or object | Logo to display. String can be emoji or image path. Object allows light/dark images. | `"📚"`, `"/images/logo.png"`, or `{ light: "/images/favicon.svg", dark: "/images/favicon-dark.svg" }` |
|
|
24
|
+
| `author` | string | Site author/organization | `"React Docs UI Team"` |
|
|
25
|
+
|
|
26
|
+
Logo formats supported:
|
|
27
|
+
- Emoji: `"🚀"`
|
|
28
|
+
- URL or public path: `"/images/logo.png"`
|
|
29
|
+
- Light/Dark object: `{ light, dark }`
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## `navbar`
|
|
34
|
+
| Field | Type | Description |
|
|
35
|
+
| :-- | :-- | :-- |
|
|
36
|
+
| `showLogo` | boolean | Show logo at top-left |
|
|
37
|
+
| `showTitle` | boolean | Show site title in navbar |
|
|
38
|
+
| `showLanguageSwitcher` | boolean | Show language switcher |
|
|
39
|
+
| `items` | array<Item> | Primary navigation links |
|
|
40
|
+
| `actions` | array<Action> | Right-side action buttons (e.g. GitHub) |
|
|
41
|
+
|
|
42
|
+
Item
|
|
43
|
+
| Field | Type | Description | Example |
|
|
44
|
+
| :-- | :-- | :-- | :-- |
|
|
45
|
+
| `title` | string | Link text | `"Guide"` |
|
|
46
|
+
| `link` | string | Path or URL. Internal paths start with `/`. | `"/guide"` |
|
|
47
|
+
| `external` | boolean (optional) | Open in new tab if true |
|
|
48
|
+
| `visible` | boolean (optional) | Conditionally hide/show |
|
|
49
|
+
|
|
50
|
+
Action
|
|
51
|
+
| Field | Type | Description | Example |
|
|
52
|
+
| :-- | :-- | :-- | :-- |
|
|
53
|
+
| `type` | `"github"` or `"custom"` (optional) | Predefined or custom action | `"github"` |
|
|
54
|
+
| `title` | string (optional) | Button text when `type` is `custom` |
|
|
55
|
+
| `link` | string | Destination URL |
|
|
56
|
+
| `icon` | string (optional) | Icon name for custom action |
|
|
57
|
+
| `enabled` | boolean (optional) | Toggle the action |
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## `sidebar`
|
|
62
|
+
| Field | Type | Description |
|
|
63
|
+
| :-- | :-- | :-- |
|
|
64
|
+
| `enabled` | boolean (optional) | Global toggle for sidebar |
|
|
65
|
+
| `collections` | record<string, Collection> | Map of top-level sections (e.g. `guide`) |
|
|
66
|
+
| `sections` | Section[] (legacy, optional) | Backward-compatible single-tree definition |
|
|
67
|
+
|
|
68
|
+
Collection
|
|
69
|
+
| Field | Type | Description |
|
|
70
|
+
| :-- | :-- | :-- |
|
|
71
|
+
| `sections` | Section[] | Grouped side-nav sections |
|
|
72
|
+
|
|
73
|
+
Section
|
|
74
|
+
| Field | Type | Description | Example |
|
|
75
|
+
| :-- | :-- | :-- | :-- |
|
|
76
|
+
| `title` | string | Section title | `"Getting Started"` |
|
|
77
|
+
| `path` | string | Base path that expands/highlights this section | `"/guide"` |
|
|
78
|
+
| `children` | Child[] (optional) | Leaf links under the section |
|
|
79
|
+
|
|
80
|
+
Child
|
|
81
|
+
| Field | Type | Description | Example |
|
|
82
|
+
| :-- | :-- | :-- | :-- |
|
|
83
|
+
| `title` | string | Link text | `"Introduction"` |
|
|
84
|
+
| `path` | string | Full page path | `"/guide/introduction"` |
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## `theme`
|
|
89
|
+
| Field | Type | Description | Options | Default |
|
|
90
|
+
| :-- | :-- | :-- | :-- | :-- |
|
|
91
|
+
| `defaultMode` | string | Default color mode | `light`, `dark`, `auto` | `auto` |
|
|
92
|
+
| `allowToggle` | boolean | Allow user theme switching | `true`/`false` | `true` |
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## `toc`
|
|
97
|
+
| Field | Type | Description | Example |
|
|
98
|
+
| :-- | :-- | :-- | :-- |
|
|
99
|
+
| `enabled` | boolean | Enable page table of contents | `true` |
|
|
100
|
+
| `maxLevel` | number (1-6) | Max heading depth to show | `3` |
|
|
101
|
+
| `title` | string | TOC panel title | `"On This Page"` |
|
|
102
|
+
|
|
103
|
+
Note: Per-page TOC visibility/anchors are also affected by page frontmatter.
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## `footer`
|
|
108
|
+
| Field | Type | Description |
|
|
109
|
+
| :-- | :-- | :-- |
|
|
110
|
+
| `enabled` | boolean | Show footer |
|
|
111
|
+
| `copyright` | string | Copyright text |
|
|
112
|
+
| `repository` | Repository (optional) | Repo info used for links like “Edit this page” |
|
|
113
|
+
| `lastUpdated` | string (optional) | Site/content last update date |
|
|
114
|
+
| `links` | Link[] (optional) | Footer link columns |
|
|
115
|
+
| `social` | Social[] (optional) | Social icon links |
|
|
116
|
+
|
|
117
|
+
Repository
|
|
118
|
+
| Field | Type | Description | Example |
|
|
119
|
+
| :-- | :-- | :-- | :-- |
|
|
120
|
+
| `url` | string | Repository URL | `"https://github.com/user/repo"` |
|
|
121
|
+
| `branch` | string | Docs branch | `"main"` |
|
|
122
|
+
|
|
123
|
+
Link
|
|
124
|
+
| Field | Type | Description |
|
|
125
|
+
| :-- | :-- | :-- |
|
|
126
|
+
| `title` | string | Link title |
|
|
127
|
+
| `link` | string | Path or URL |
|
|
128
|
+
| `external` | boolean (optional) | Open in new tab |
|
|
129
|
+
|
|
130
|
+
Social
|
|
131
|
+
| Field | Type | Description |
|
|
132
|
+
| :-- | :-- | :-- |
|
|
133
|
+
| `name` | string | Provider key (e.g. `github`, `twitter`, `bilibili`) |
|
|
134
|
+
| `url` | string | Profile or link URL |
|
|
135
|
+
| `icon` | string | Icon name |
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## `pwa` (optional)
|
|
140
|
+
| Field | Type | Description |
|
|
141
|
+
| :-- | :-- | :-- |
|
|
142
|
+
| `enabled` | boolean | Enable PWA features (reserved) |
|
|
143
|
+
| `name` | string | App name |
|
|
144
|
+
| `shortName` | string | Short app name |
|
|
145
|
+
| `description` | string | App description |
|
|
146
|
+
| `themeColor` | string | Theme color |
|
|
147
|
+
| `backgroundColor` | string | Background color |
|
|
148
|
+
|
|
149
|
+
---
|
|
@@ -1,109 +1,108 @@
|
|
|
1
|
-
# Quick Start
|
|
2
|
-
|
|
3
|
-
This guide will walk you through creating, configuring, and running your own React documentation website from scratch in 5 minutes.
|
|
4
|
-
|
|
5
|
-
## 1. Create the Project
|
|
6
|
-
|
|
7
|
-
Using the official scaffolding tool is the most efficient way. Open your terminal and run the following command:
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
# This creates a project named "my-awesome-docs"
|
|
11
|
-
npx create-react-docs-ui@latest my-awesome-docs
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
Next, enter the project directory and install the dependencies:
|
|
15
|
-
|
|
16
|
-
```bash
|
|
17
|
-
cd my-awesome-docs
|
|
18
|
-
npm install
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
## 2. Organize Your Documents
|
|
22
|
-
|
|
23
|
-
All your documentation content is stored as Markdown files in the `public/docs/` directory.
|
|
24
|
-
|
|
25
|
-
- Open the `public/docs/en/` directory.
|
|
26
|
-
- You can modify the existing `index.md` and files under the `guide` directory, or create new `.md` files.
|
|
27
|
-
|
|
28
|
-
For example, let's create a new page. Create a new file named `about.md` in `public/docs/en/`:
|
|
29
|
-
|
|
30
|
-
```markdown
|
|
31
|
-
---
|
|
32
|
-
title: About Us
|
|
33
|
-
description: This is a page about our team.
|
|
34
|
-
---
|
|
35
|
-
|
|
36
|
-
# About Us
|
|
37
|
-
|
|
38
|
-
We love open source and creation!
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
1
|
+
# Quick Start
|
|
2
|
+
|
|
3
|
+
This guide will walk you through creating, configuring, and running your own React documentation website from scratch in 5 minutes.
|
|
4
|
+
|
|
5
|
+
## 1. Create the Project
|
|
6
|
+
|
|
7
|
+
Using the official scaffolding tool is the most efficient way. Open your terminal and run the following command:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
# This creates a project named "my-awesome-docs"
|
|
11
|
+
npx create-react-docs-ui@latest my-awesome-docs
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Next, enter the project directory and install the dependencies:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
cd my-awesome-docs
|
|
18
|
+
npm install
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## 2. Organize Your Documents
|
|
22
|
+
|
|
23
|
+
All your documentation content is stored as Markdown files in the `public/docs/` directory.
|
|
24
|
+
|
|
25
|
+
- Open the `public/docs/en/` directory.
|
|
26
|
+
- You can modify the existing `index.md` and files under the `guide` directory, or create new `.md` files.
|
|
27
|
+
|
|
28
|
+
For example, let's create a new page. Create a new file named `about.md` in `public/docs/en/`:
|
|
29
|
+
|
|
30
|
+
```markdown
|
|
31
|
+
---
|
|
32
|
+
title: About Us
|
|
33
|
+
description: This is a page about our team.
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
# About Us
|
|
37
|
+
|
|
38
|
+
We love open source and creation!
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
## 3. Configure the Website
|
|
43
|
+
|
|
44
|
+
Now, let's display the newly created page by modifying the configuration file.
|
|
45
|
+
|
|
46
|
+
Open the core configuration file `public/config/site.yaml`.
|
|
47
|
+
|
|
48
|
+
### a. Modify Site Information
|
|
49
|
+
|
|
50
|
+
Update the `site` section to give your website a new title and logo.
|
|
51
|
+
|
|
52
|
+
```yaml
|
|
53
|
+
site:
|
|
54
|
+
title: "My Awesome Docs"
|
|
55
|
+
description: "A website built with React Docs UI"
|
|
56
|
+
logo: "🚀" # You can use an emoji or an image path
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### b. Add to the Navbar
|
|
60
|
+
|
|
61
|
+
In the `navbar.items` array, add a link for the "About" page. Remember to update the links for the English version.
|
|
62
|
+
|
|
63
|
+
```yaml
|
|
64
|
+
navbar:
|
|
65
|
+
items:
|
|
66
|
+
- title: "Home"
|
|
67
|
+
link: "/en/"
|
|
68
|
+
- title: "Guide"
|
|
69
|
+
link: "/en/guide/introduction"
|
|
70
|
+
- title: "About" # New
|
|
71
|
+
link: "/en/about" # New
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### c. Add to the Sidebar
|
|
75
|
+
|
|
76
|
+
To make the "About" page visible in the sidebar, we'll add a new entry in `sidebar.collections.guide.sections`. Make sure to use English paths.
|
|
77
|
+
|
|
78
|
+
```yaml
|
|
79
|
+
sidebar:
|
|
80
|
+
collections:
|
|
81
|
+
guide:
|
|
82
|
+
sections:
|
|
83
|
+
- title: "Getting Started"
|
|
84
|
+
path: "/en/guide"
|
|
85
|
+
children:
|
|
86
|
+
- title: "Introduction"
|
|
87
|
+
path: "/en/guide/introduction"
|
|
88
|
+
- title: "Installation"
|
|
89
|
+
path: "/en/guide/installation"
|
|
90
|
+
- title: "Quick Start"
|
|
91
|
+
path: "/en/guide/quick-start"
|
|
92
|
+
# You can create a new section for the "About" page
|
|
93
|
+
- title: "About Us"
|
|
94
|
+
path: "/en/about"
|
|
95
|
+
children:
|
|
96
|
+
- title: "About"
|
|
97
|
+
path: "/en/about"
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## 4. Launch the Website
|
|
101
|
+
|
|
102
|
+
Save all your changes and run the following command in your terminal:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
npm run dev
|
|
106
|
+
```
|
|
107
|
+
|
|
109
108
|
Your website should now be running at `http://localhost:5173`. Visit it, and you will see the updated title, logo, and the new "About" link in the navbar and sidebar. Congratulations, you have successfully mastered the basic workflow of React Docs UI!
|
|
@@ -1,122 +1,150 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
|
|
|
8
|
-
|
|
|
9
|
-
| `
|
|
10
|
-
| `
|
|
11
|
-
| `
|
|
12
|
-
| `
|
|
13
|
-
| `footer` |
|
|
14
|
-
| `
|
|
15
|
-
|
|
16
|
-
---
|
|
17
|
-
|
|
18
|
-
## `site`
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
|
23
|
-
|
|
|
24
|
-
| `
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
|
48
|
-
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
|
70
|
-
|
|
|
71
|
-
| `
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
|
76
|
-
|
|
|
77
|
-
| `
|
|
78
|
-
| `
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
| 字段 | 说明 | 示例 |
|
|
98
|
-
|
|
|
99
|
-
| `
|
|
100
|
-
| `
|
|
101
|
-
| `
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
|
109
|
-
|
|
|
110
|
-
| `
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
| 字段 | 说明 | 示例 |
|
|
119
|
-
|
|
|
120
|
-
| `
|
|
121
|
-
| `
|
|
122
|
-
|
|
1
|
+
# 配置文件(`site.yaml`)字段说明
|
|
2
|
+
|
|
3
|
+
项目遵循“配置驱动”。绝大多数行为由 `public/config/site.yaml` 决定。下面用表格逐项说明所有字段。
|
|
4
|
+
|
|
5
|
+
## 顶级键
|
|
6
|
+
| 键 | 作用 |
|
|
7
|
+
| :-- | :-- |
|
|
8
|
+
| `site` | 全局元信息(标题、描述、Logo、作者) |
|
|
9
|
+
| `navbar` | 顶部导航(开关、导航项、操作按钮) |
|
|
10
|
+
| `sidebar` | 左侧导航树(集合/分组/子项) |
|
|
11
|
+
| `theme` | 主题配置(默认模式、是否允许切换) |
|
|
12
|
+
| `toc` | 文章右侧目录(开关、层级、标题) |
|
|
13
|
+
| `footer` | 页脚(链接、社交、仓库信息) |
|
|
14
|
+
| `pwa` | PWA 设置(预留/可选) |
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## `site`
|
|
19
|
+
| 字段 | 类型 | 说明 | 示例 |
|
|
20
|
+
| :-- | :-- | :-- | :-- |
|
|
21
|
+
| `title` | string | 网站标题 | `"React Docs UI 示例"` |
|
|
22
|
+
| `description` | string | 简短网站描述(SEO) | `"简单漂亮的文档站"` |
|
|
23
|
+
| `logo` | string 或 object | 网站 Logo。字符串可为 emoji 或图片路径;对象可分别设置亮/暗图标 | `"📚"`、`"/images/logo.png"`、或 `{ light: "/images/favicon.svg", dark: "/images/favicon-dark.svg" }` |
|
|
24
|
+
| `author` | string | 作者或组织 | `"React Docs UI Team"` |
|
|
25
|
+
|
|
26
|
+
Logo 支持:
|
|
27
|
+
- Emoji:`"🚀"`
|
|
28
|
+
- 公共路径或 URL:`"/images/logo.png"`
|
|
29
|
+
- 明/暗主题对象:`{ light, dark }`
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## `navbar`
|
|
34
|
+
| 字段 | 类型 | 说明 |
|
|
35
|
+
| :-- | :-- | :-- |
|
|
36
|
+
| `showLogo` | boolean | 是否显示左上角 Logo |
|
|
37
|
+
| `showTitle` | boolean | 是否显示站点标题 |
|
|
38
|
+
| `showLanguageSwitcher` | boolean | 是否显示语言切换 |
|
|
39
|
+
| `items` | array<Item> | 主导航链接 |
|
|
40
|
+
| `actions` | array<Action> | 右侧操作按钮(如 GitHub) |
|
|
41
|
+
|
|
42
|
+
Item
|
|
43
|
+
| 字段 | 类型 | 说明 | 示例 |
|
|
44
|
+
| :-- | :-- | :-- | :-- |
|
|
45
|
+
| `title` | string | 链接文字 | `"指南"` |
|
|
46
|
+
| `link` | string | 路径或 URL。内部路径以 `/` 开头 | `"/guide"` |
|
|
47
|
+
| `external` | boolean(可选) | 外部链接新开标签 |
|
|
48
|
+
| `visible` | boolean(可选) | 条件展示 |
|
|
49
|
+
|
|
50
|
+
Action
|
|
51
|
+
| 字段 | 类型 | 说明 | 示例 |
|
|
52
|
+
| :-- | :-- | :-- | :-- |
|
|
53
|
+
| `type` | `"github"`/`"custom"`(可选) | 预设或自定义动作 | `"github"` |
|
|
54
|
+
| `title` | string(可选) | 自定义动作按钮文案 |
|
|
55
|
+
| `link` | string | 目标链接 |
|
|
56
|
+
| `icon` | string(可选) | 自定义动作图标名 |
|
|
57
|
+
| `enabled` | boolean(可选) | 是否启用 |
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## `sidebar`
|
|
62
|
+
| 字段 | 类型 | 说明 |
|
|
63
|
+
| :-- | :-- | :-- |
|
|
64
|
+
| `enabled` | boolean(可选) | 全局开启/关闭侧边栏 |
|
|
65
|
+
| `collections` | record<string, Collection> | 顶级集合映射(如 `guide`) |
|
|
66
|
+
| `sections` | Section[] (兼容,可选) | 旧版单树结构 |
|
|
67
|
+
|
|
68
|
+
Collection
|
|
69
|
+
| 字段 | 类型 | 说明 |
|
|
70
|
+
| :-- | :-- | :-- |
|
|
71
|
+
| `sections` | Section[] | 一组可折叠分组 |
|
|
72
|
+
|
|
73
|
+
Section
|
|
74
|
+
| 字段 | 类型 | 说明 | 示例 |
|
|
75
|
+
| :-- | :-- | :-- | :-- |
|
|
76
|
+
| `title` | string | 分组标题 | `"快速开始"` |
|
|
77
|
+
| `path` | string | 访问该前缀将自动展开/高亮 | `"/guide"` |
|
|
78
|
+
| `children` | Child[](可选) | 该分组下的子链接 |
|
|
79
|
+
|
|
80
|
+
Child
|
|
81
|
+
| 字段 | 类型 | 说明 | 示例 |
|
|
82
|
+
| :-- | :-- | :-- | :-- |
|
|
83
|
+
| `title` | string | 子链接文字 | `"介绍"` |
|
|
84
|
+
| `path` | string | 完整页面路径 | `"/guide/introduction"` |
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## `theme`
|
|
89
|
+
| 字段 | 类型 | 说明 | 可选值 | 默认值 |
|
|
90
|
+
| :-- | :-- | :-- | :-- | :-- |
|
|
91
|
+
| `defaultMode` | string | 默认主题模式 | `light`/`dark`/`auto` | `auto` |
|
|
92
|
+
| `allowToggle` | boolean | 是否允许用户切换主题 | `true`/`false` | `true` |
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## `toc`
|
|
97
|
+
| 字段 | 类型 | 说明 | 示例 |
|
|
98
|
+
| :-- | :-- | :-- | :-- |
|
|
99
|
+
| `enabled` | boolean | 是否启用页面目录 | `true` |
|
|
100
|
+
| `maxLevel` | number (1-6) | 展示的最大标题层级 | `3` |
|
|
101
|
+
| `title` | string | 目录标题 | `"本页内容"` |
|
|
102
|
+
|
|
103
|
+
说明:具体锚点与是否显示也可能受页面 Frontmatter 影响。
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## `footer`
|
|
108
|
+
| 字段 | 类型 | 说明 |
|
|
109
|
+
| :-- | :-- | :-- |
|
|
110
|
+
| `enabled` | boolean | 是否显示页脚 |
|
|
111
|
+
| `copyright` | string | 版权文案 |
|
|
112
|
+
| `repository` | Repository(可选) | 仓库信息(如“在 GitHub 上编辑此页”) |
|
|
113
|
+
| `lastUpdated` | string(可选) | 站点/内容最近更新时间 |
|
|
114
|
+
| `links` | Link[](可选) | 页脚链接列 |
|
|
115
|
+
| `social` | Social[](可选) | 社交图标链接 |
|
|
116
|
+
|
|
117
|
+
Repository
|
|
118
|
+
| 字段 | 类型 | 说明 | 示例 |
|
|
119
|
+
| :-- | :-- | :-- | :-- |
|
|
120
|
+
| `url` | string | 仓库地址 | `"https://github.com/user/repo"` |
|
|
121
|
+
| `branch` | string | 文档所在分支 | `"main"` |
|
|
122
|
+
|
|
123
|
+
Link
|
|
124
|
+
| 字段 | 类型 | 说明 |
|
|
125
|
+
| :-- | :-- | :-- |
|
|
126
|
+
| `title` | string | 链接标题 |
|
|
127
|
+
| `link` | string | 路径或 URL |
|
|
128
|
+
| `external` | boolean(可选) | 新开标签 |
|
|
129
|
+
|
|
130
|
+
Social
|
|
131
|
+
| 字段 | 类型 | 说明 |
|
|
132
|
+
| :-- | :-- | :-- |
|
|
133
|
+
| `name` | string | 平台名称(如 `github`/`twitter`/`bilibili`) |
|
|
134
|
+
| `url` | string | 个人页或链接 |
|
|
135
|
+
| `icon` | string | 图标名 |
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## `pwa`(可选)
|
|
140
|
+
| 字段 | 类型 | 说明 |
|
|
141
|
+
| :-- | :-- | :-- |
|
|
142
|
+
| `enabled` | boolean | 是否启用 PWA(预留) |
|
|
143
|
+
| `name` | string | 应用名 |
|
|
144
|
+
| `shortName` | string | 应用短名 |
|
|
145
|
+
| `description` | string | 应用描述 |
|
|
146
|
+
| `themeColor` | string | 主题色 |
|
|
147
|
+
| `backgroundColor` | string | 背景色 |
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
@@ -1,109 +1,108 @@
|
|
|
1
|
-
# 快速上手
|
|
2
|
-
|
|
3
|
-
本指南将引导你在 5 分钟内,从零开始创建、配置并运行一个属于你自己的 React 文档网站。
|
|
4
|
-
|
|
5
|
-
## 1. 创建项目
|
|
6
|
-
|
|
7
|
-
使用官方脚手架是最高效的方式。打开你的终端,运行以下命令:
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
# 这会创建一个名为 "my-awesome-docs" 的项目
|
|
11
|
-
npx create-react-docs-ui@latest my-awesome-docs
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
然后,进入项目目录并安装依赖:
|
|
15
|
-
|
|
16
|
-
```bash
|
|
17
|
-
cd my-awesome-docs
|
|
18
|
-
npm install
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
## 2. 组织你的文档
|
|
22
|
-
|
|
23
|
-
所有的文档内容都以 Markdown 文件的形式存放在 `public/docs/` 目录下。
|
|
24
|
-
|
|
25
|
-
- 打开 `public/docs/zh-cn/` 目录。
|
|
26
|
-
- 你可以修改现有的 `index.md` 和 `guide` 目录下的文件,或者创建新的 `.md` 文件。
|
|
27
|
-
|
|
28
|
-
例如,我们来创建一个新页面。在 `public/docs/zh-cn/` 下新建一个 `about.md` 文件:
|
|
29
|
-
|
|
30
|
-
```markdown
|
|
31
|
-
---
|
|
32
|
-
title: 关于我们
|
|
33
|
-
description: 这是一个关于我们团队的页面。
|
|
34
|
-
---
|
|
35
|
-
|
|
36
|
-
# 关于我们
|
|
37
|
-
|
|
38
|
-
我们热爱开源和创造!
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
1
|
+
# 快速上手
|
|
2
|
+
|
|
3
|
+
本指南将引导你在 5 分钟内,从零开始创建、配置并运行一个属于你自己的 React 文档网站。
|
|
4
|
+
|
|
5
|
+
## 1. 创建项目
|
|
6
|
+
|
|
7
|
+
使用官方脚手架是最高效的方式。打开你的终端,运行以下命令:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
# 这会创建一个名为 "my-awesome-docs" 的项目
|
|
11
|
+
npx create-react-docs-ui@latest my-awesome-docs
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
然后,进入项目目录并安装依赖:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
cd my-awesome-docs
|
|
18
|
+
npm install
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## 2. 组织你的文档
|
|
22
|
+
|
|
23
|
+
所有的文档内容都以 Markdown 文件的形式存放在 `public/docs/` 目录下。
|
|
24
|
+
|
|
25
|
+
- 打开 `public/docs/zh-cn/` 目录。
|
|
26
|
+
- 你可以修改现有的 `index.md` 和 `guide` 目录下的文件,或者创建新的 `.md` 文件。
|
|
27
|
+
|
|
28
|
+
例如,我们来创建一个新页面。在 `public/docs/zh-cn/` 下新建一个 `about.md` 文件:
|
|
29
|
+
|
|
30
|
+
```markdown
|
|
31
|
+
---
|
|
32
|
+
title: 关于我们
|
|
33
|
+
description: 这是一个关于我们团队的页面。
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
# 关于我们
|
|
37
|
+
|
|
38
|
+
我们热爱开源和创造!
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
## 3. 配置网站
|
|
43
|
+
|
|
44
|
+
现在,让我们通过修改配置文件来展示新创建的页面。
|
|
45
|
+
|
|
46
|
+
打开核心配置文件 `public/config/site.yaml`。
|
|
47
|
+
|
|
48
|
+
### a. 修改网站信息
|
|
49
|
+
|
|
50
|
+
更新 `site` 部分,给你的网站一个新标题和 Logo。
|
|
51
|
+
|
|
52
|
+
```yaml
|
|
53
|
+
site:
|
|
54
|
+
title: "我的超赞文档"
|
|
55
|
+
description: "一个使用 React Docs UI 构建的网站"
|
|
56
|
+
logo: "🚀" # 你可以使用 emoji 或图片路径
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### b. 添加到导航栏
|
|
60
|
+
|
|
61
|
+
在 `navbar.items` 数组中,为“关于”页面添加一个链接。
|
|
62
|
+
|
|
63
|
+
```yaml
|
|
64
|
+
navbar:
|
|
65
|
+
items:
|
|
66
|
+
- title: "首页"
|
|
67
|
+
link: "/zh-cn/"
|
|
68
|
+
- title: "指南"
|
|
69
|
+
link: "/zh-cn/guide/introduction"
|
|
70
|
+
- title: "关于" # 新增
|
|
71
|
+
link: "/zh-cn/about" # 新增
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### c. 添加到侧边栏
|
|
75
|
+
|
|
76
|
+
为了让“关于”页面在侧边栏也可见,我们在 `sidebar.collections.guide.sections` 中添加一个新条目。
|
|
77
|
+
|
|
78
|
+
```yaml
|
|
79
|
+
sidebar:
|
|
80
|
+
collections:
|
|
81
|
+
guide:
|
|
82
|
+
sections:
|
|
83
|
+
- title: "快速开始"
|
|
84
|
+
path: "/zh-cn/guide"
|
|
85
|
+
children:
|
|
86
|
+
- title: "介绍"
|
|
87
|
+
path: "/zh-cn/guide/introduction"
|
|
88
|
+
- title: "安装"
|
|
89
|
+
path: "/zh-cn/guide/installation"
|
|
90
|
+
- title: "快速上手"
|
|
91
|
+
path: "/zh-cn/guide/quick-start"
|
|
92
|
+
# 你可以为 "关于" 页面创建一个新的 section
|
|
93
|
+
- title: "关于我们"
|
|
94
|
+
path: "/zh-cn/about"
|
|
95
|
+
children:
|
|
96
|
+
- title: "关于"
|
|
97
|
+
path: "/zh-cn/about"
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## 4. 启动网站
|
|
101
|
+
|
|
102
|
+
保存你的所有修改,然后在终端运行:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
npm run dev
|
|
106
|
+
```
|
|
107
|
+
|
|
109
108
|
你的网站现在应该运行在 `http://localhost:5173` 上了。访问它,你会看到更新后的标题、Logo,以及导航栏和侧边栏中新增的“关于”链接。恭喜你,你已经成功掌握了 React Docs UI 的基本工作流程!
|