create-react-docs-ui 0.1.3 → 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.
@@ -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
- **Note**: You can use `frontmatter` at the top of your Markdown files to define the page `title` and `description`.
42
-
43
- ## 3. Configure the Website
44
-
45
- Now, let's display the newly created page by modifying the configuration file.
46
-
47
- Open the core configuration file `public/config/site.yaml`.
48
-
49
- ### a. Modify Site Information
50
-
51
- Update the `site` section to give your website a new title and logo.
52
-
53
- ```yaml
54
- site:
55
- title: "My Awesome Docs"
56
- description: "A website built with React Docs UI"
57
- logo: "🚀" # You can use an emoji or an image path
58
- ```
59
-
60
- ### b. Add to the Navbar
61
-
62
- In the `navbar.items` array, add a link for the "About" page. Remember to update the links for the English version.
63
-
64
- ```yaml
65
- navbar:
66
- items:
67
- - title: "Home"
68
- link: "/en/"
69
- - title: "Guide"
70
- link: "/en/guide/introduction"
71
- - title: "About" # New
72
- link: "/en/about" # New
73
- ```
74
-
75
- ### c. Add to the Sidebar
76
-
77
- 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.
78
-
79
- ```yaml
80
- sidebar:
81
- collections:
82
- guide:
83
- sections:
84
- - title: "Getting Started"
85
- path: "/en/guide"
86
- children:
87
- - title: "Introduction"
88
- path: "/en/guide/introduction"
89
- - title: "Installation"
90
- path: "/en/guide/installation"
91
- - title: "Quick Start"
92
- path: "/en/guide/quick-start"
93
- # You can create a new section for the "About" page
94
- - title: "About Us"
95
- path: "/en/about"
96
- children:
97
- - title: "About"
98
- path: "/en/about"
99
- ```
100
-
101
- ## 4. Launch the Website
102
-
103
- Save all your changes and run the following command in your terminal:
104
-
105
- ```bash
106
- npm run dev
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
- # 配置文件 (`site.yaml`) 详解
2
-
3
- `react-docs-ui` 的核心是其**配置驱动**的理念。你几乎可以通过 `public/config/site.yaml` 这一个文件来定义整个网站的外观和行为。本文档将详细解释每个配置项。
4
-
5
- ## 顶级配置项概览
6
-
7
- | 顶级字段 | 说明 |
8
- | :--- | :--- |
9
- | `site` | 网站的全局信息,如标题、描述、Logo。 |
10
- | `navbar` | 配置网站顶部的导航栏。 |
11
- | `sidebar` | 配置网站侧边栏的导航菜单。 |
12
- | `theme` | 配置网站的主题,如颜色、浅色/深色模式。 |
13
- | `footer` | 配置网站底部的页脚信息。 |
14
- | `toc` | 配置文章页面右侧的目录(Table of Contents)。 |
15
-
16
- ---
17
-
18
- ## `site`
19
-
20
- 网站的基础元数据配置。
21
-
22
- | 字段 | 说明 | 示例 |
23
- | :--- | :--- | :--- |
24
- | `title` | 网站标题,显示在浏览器标签页上。 | `"React Docs UI"` |
25
- | `description` | 网站描述,用于搜索引擎优化 (SEO)。 | `"一个 React 文档网站构建工具"` |
26
- | `logo` | 网站 Logo,显示在导航栏左上角。 | `"📚"` 或 `"/images/logo.png"` 或一个包含 `light` 和 `dark` 模式图片路径的对象 |
27
- | `author` | 网站作者。 | `"React Docs UI Team"` |
28
-
29
- **Logo 格式说明:**
30
- 1. **Emoji**: 直接使用一个表情符号,如 `"🚀"`。
31
- 2. **本地图片**: 指向 `public` 目录下的图片路径,如 `"/images/logo.png"`。
32
- 3. **亮/暗模式图片**: 一个对象,包含 `light` 和 `dark` 两个键,分别指向不同主题下的图片路径。
33
-
34
- ---
35
-
36
- ## `navbar`
37
-
38
- 顶部导航栏配置。
39
-
40
- | 字段 | 说明 |
41
- | :--- | :--- |
42
- | `items` | 导航项数组,定义了导航栏中显示的所有链接。 |
43
- | `actions` | (可选) 导航栏右侧的操作按钮,如 GitHub 链接。 |
44
-
45
- ### `navbar.items`
46
-
47
- | 字段 | 说明 | 示例 |
48
- | :--- | :--- | :--- |
49
- | `title` | 导航项的显示文本。 | `"指南"` |
50
- | `link` | 链接地址。内部链接以 `/` 开头。 | `"/guide/introduction"` |
51
- | `external` | (可选) `true` 表示为外部链接,将在新标签页打开。 | `true` |
52
-
53
- ---
54
-
55
- ## `sidebar`
56
-
57
- 侧边栏导航配置,是文档结构的核心。它使用 `collections` 来组织不同部分的内容。
58
-
59
- | 字段 | 说明 |
60
- | :--- | :--- |
61
- | `collections` | 一个对象,键是集合的名称(通常对应一级路由,如 `guide`),值是该集合的侧边栏配置。 |
62
-
63
- ### `sidebar.collections.<name>.sections`
64
-
65
- 每个集合包含一个 `sections` 数组,每个 `section` 代表一个可折叠的菜单组。
66
-
67
- | 字段 | 说明 | 示例 |
68
- | :--- | :--- | :--- |
69
- | `title` | 区域的标题。 | `"入门指南"` |
70
- | `path` | 区域的基础路径。当用户访问的 URL 以此路径开头时,该区域会自动展开并高亮。 | `"/guide"` |
71
- | `children` | 该区域下的子链接数组。 | |
72
-
73
- ### `sidebar.collections.<name>.sections.children`
74
-
75
- | 字段 | 说明 | 示例 |
76
- | :--- | :--- | :--- |
77
- | `title` | 子链接的显示文本。 | `"介绍"` |
78
- | `path` | 子链接的完整路径,指向一个具体的 Markdown 页面。 | `"/guide/introduction"` |
79
-
80
- ---
81
-
82
- ## `theme`
83
-
84
- 主题和外观配置。
85
-
86
- | 字段 | 说明 | 可选值 | 默认值 |
87
- | :--- | :--- | :--- | :--- |
88
- | `defaultMode` | 网站的默认主题模式。 | `'light'`, `'dark'`, `'system'` | `'system'` |
89
- | `allowToggle` | 是否允许用户切换主题。 | `true`, `false` | `true` |
90
-
91
- ---
92
-
93
- ## `footer`
94
-
95
- 页脚配置。
96
-
97
- | 字段 | 说明 | 示例 |
98
- | :--- | :--- | :--- |
99
- | `copyright` | 版权信息。`{year}` 会被替换为当前年份。 | `"Copyright © {year} My Company"` |
100
- | `repository` | (可选) 仓库信息,用于显示“在 GitHub 上编辑此页”等链接。 | |
101
- | `links` | (可选) 在页脚显示的额外链接列。 | |
102
- | `social` | (可选) 在页脚显示的社交媒体图标链接。 | |
103
-
104
- ### `footer.repository`
105
-
106
- | 字段 | 说明 | 示例 |
107
- | :--- | :--- | :--- |
108
- | `url` | 仓库的 URL。 | `"https://github.com/user/repo"` |
109
- | `branch` | 文档所在的 Git 分支。 | `"main"` |
110
- | `dir` | 文档文件在仓库中的根目录。 | `"docs/src"` |
111
-
112
- ---
113
-
114
- ## `toc` (Table of Contents)
115
-
116
- 文章页面右侧的目录配置。
117
-
118
- | 字段 | 说明 | 示例 |
119
- | :--- | :--- | :--- |
120
- | `enabled` | 是否启用页面目录功能。 | `true` |
121
- | `maxLevel` | 在目录中显示的最大标题级别(h1-h6)。 | `3` |
122
- | `title` | 目录组件的标题。 | `"本页内容"` |
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
+