zengen 0.2.0 → 0.2.1
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/.zen/meta.json +59 -77
- package/.zen/src/en-US/01d04f7c17b4a541ead9d759d877b30b403e15b849182a49eb1f62bd29ecd18c.md +23 -23
- package/.zen/src/en-US/1b798c44a4f353e47296ca83d5905e37e6aba3e90bbd9bc3b3d34fc12059a2ca.md +2 -2
- package/.zen/src/en-US/1e96be58d76c60056b708eb5bd8b8b81d7b5845d9cfe0b879d85068a5f11df3a.md +3 -3
- package/.zen/src/en-US/80ae9bed74fc6348a7c1fe9f33e86b65f5d919169721f77bcf0e1bc29fbdb4f9.md +3 -3
- package/.zen/src/en-US/f0c2799126931ccd113a0c45b1e623870b0d4f4f400becf6dd877da8f1011517.md +2 -3
- package/.zen/src/en-US/fdfca9b960d0eaa8b2b96fe988ead7481d2c0b16f66ebc94fb477139b4178cdc.md +5 -5
- package/.zen/src/zh-Hans/6124ea88edec5bde737b26b21f71ecfeffe4e73151784856edf813ee231a4baa.md +10 -0
- package/.zen/src/zh-Hans/f0c2799126931ccd113a0c45b1e623870b0d4f4f400becf6dd877da8f1011517.md +3 -4
- package/.zen/src/zh-Hans/fdfca9b960d0eaa8b2b96fe988ead7481d2c0b16f66ebc94fb477139b4178cdc.md +2 -2
- package/dist/build/pipeline.d.ts.map +1 -1
- package/dist/build/pipeline.js +13 -12
- package/dist/build/pipeline.js.map +1 -1
- package/dist/process/extractMetadataByAI.d.ts.map +1 -1
- package/dist/process/extractMetadataByAI.js +3 -3
- package/dist/process/extractMetadataByAI.js.map +1 -1
- package/package.json +1 -1
- package/src/build/pipeline.ts +48 -42
- package/src/process/extractMetadataByAI.ts +14 -12
- package/.zen/src/zh-Hans/6ad8db715a1b60613fe934fefb29fa981ecad9b63145593accff144d73b44bde.md +0 -175
- package/.zen/src/zh-Hans/a1580f71c6c6c1ff4a314be72d410a8507af2f087d56360c7f5048d349c21953.md +0 -48
- package/.zen/src/zh-Hans/d49012f98c4367b34034063400e2f7826bf0615952210c82396920172d468e2c.md +0 -107
package/.zen/meta.json
CHANGED
|
@@ -18,8 +18,7 @@
|
|
|
18
18
|
"completion": 124,
|
|
19
19
|
"total": 774
|
|
20
20
|
}
|
|
21
|
-
}
|
|
22
|
-
"lastUpdated": "2026-01-05T17:52:25.773Z"
|
|
21
|
+
}
|
|
23
22
|
},
|
|
24
23
|
{
|
|
25
24
|
"hash": "5ec990146b35e00de2630559126ee07f7cdcddeb23b0e8cab3d85b4181353e26",
|
|
@@ -34,73 +33,7 @@
|
|
|
34
33
|
"completion": 120,
|
|
35
34
|
"total": 584
|
|
36
35
|
}
|
|
37
|
-
}
|
|
38
|
-
"lastUpdated": "2026-01-05T17:52:30.439Z"
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
"hash": "f0c2799126931ccd113a0c45b1e623870b0d4f4f400becf6dd877da8f1011517",
|
|
42
|
-
"path": "docs/getting-started.md",
|
|
43
|
-
"metadata": {
|
|
44
|
-
"title": "快速开始指南",
|
|
45
|
-
"summary": "本文档介绍了ZEN文档生成器的快速入门方法,包括安装步骤、基本使用流程和主要特性,帮助用户快速上手。",
|
|
46
|
-
"tags": [
|
|
47
|
-
"ZEN文档生成器",
|
|
48
|
-
"快速开始",
|
|
49
|
-
"安装",
|
|
50
|
-
"基本用法",
|
|
51
|
-
"特性",
|
|
52
|
-
"Markdown",
|
|
53
|
-
"AI辅助",
|
|
54
|
-
"多语言支持"
|
|
55
|
-
],
|
|
56
|
-
"inferred_lang": "zh-Hans",
|
|
57
|
-
"tokens_used": {
|
|
58
|
-
"prompt": 373,
|
|
59
|
-
"completion": 102,
|
|
60
|
-
"total": 475
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
"lastUpdated": "2026-01-05T17:52:38.265Z"
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
"hash": "fdfca9b960d0eaa8b2b96fe988ead7481d2c0b16f66ebc94fb477139b4178cdc",
|
|
67
|
-
"path": "docs/guides/index.md",
|
|
68
|
-
"metadata": {
|
|
69
|
-
"title": "ZEN 文档站点示例",
|
|
70
|
-
"summary": "介绍 ZEN 文档构建工具,一个极简主义的 Markdown 文档站点生成器,包括特性如极简配置、内容优先、智能导航和多语言支持,以及快速开始指南和代码示例。",
|
|
71
|
-
"tags": [
|
|
72
|
-
"ZEN",
|
|
73
|
-
"文档构建工具",
|
|
74
|
-
"Markdown",
|
|
75
|
-
"站点生成器",
|
|
76
|
-
"极简主义",
|
|
77
|
-
"快速开始",
|
|
78
|
-
"多语言支持"
|
|
79
|
-
],
|
|
80
|
-
"inferred_lang": "zh-Hans",
|
|
81
|
-
"tokens_used": {
|
|
82
|
-
"prompt": 567,
|
|
83
|
-
"completion": 119,
|
|
84
|
-
"total": 686
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
"lastUpdated": "2026-01-05T17:52:50.656Z"
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
"hash": "6124ea88edec5bde737b26b21f71ecfeffe4e73151784856edf813ee231a4baa",
|
|
91
|
-
"path": "docs/testing/test-document.md",
|
|
92
|
-
"metadata": {
|
|
93
|
-
"title": "Test Document",
|
|
94
|
-
"summary": "这是一个测试文档,内容为空,仅包含标题。",
|
|
95
|
-
"tags": ["测试", "文档", "示例"],
|
|
96
|
-
"inferred_lang": "en-US",
|
|
97
|
-
"tokens_used": {
|
|
98
|
-
"prompt": 265,
|
|
99
|
-
"completion": 58,
|
|
100
|
-
"total": 323
|
|
101
|
-
}
|
|
102
|
-
},
|
|
103
|
-
"lastUpdated": "2026-01-05T17:52:52.971Z"
|
|
36
|
+
}
|
|
104
37
|
},
|
|
105
38
|
{
|
|
106
39
|
"hash": "01d04f7c17b4a541ead9d759d877b30b403e15b849182a49eb1f62bd29ecd18c",
|
|
@@ -115,8 +48,22 @@
|
|
|
115
48
|
"completion": 106,
|
|
116
49
|
"total": 1197
|
|
117
50
|
}
|
|
118
|
-
}
|
|
119
|
-
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"hash": "f0c2799126931ccd113a0c45b1e623870b0d4f4f400becf6dd877da8f1011517",
|
|
55
|
+
"path": "docs/getting-started.md",
|
|
56
|
+
"metadata": {
|
|
57
|
+
"title": "快速开始指南",
|
|
58
|
+
"summary": "本文档介绍如何快速开始使用 ZEN 文档生成器,包括安装步骤、基本用法和主要特性。",
|
|
59
|
+
"tags": ["ZEN 文档生成器", "快速开始", "安装", "基本用法", "特性", "Markdown", "构建命令"],
|
|
60
|
+
"inferred_lang": "zh-Hans",
|
|
61
|
+
"tokens_used": {
|
|
62
|
+
"prompt": 373,
|
|
63
|
+
"completion": 94,
|
|
64
|
+
"total": 467
|
|
65
|
+
}
|
|
66
|
+
}
|
|
120
67
|
},
|
|
121
68
|
{
|
|
122
69
|
"hash": "1e96be58d76c60056b708eb5bd8b8b81d7b5845d9cfe0b879d85068a5f11df3a",
|
|
@@ -131,8 +78,7 @@
|
|
|
131
78
|
"completion": 116,
|
|
132
79
|
"total": 1398
|
|
133
80
|
}
|
|
134
|
-
}
|
|
135
|
-
"lastUpdated": "2026-01-06T01:26:58.919Z"
|
|
81
|
+
}
|
|
136
82
|
},
|
|
137
83
|
{
|
|
138
84
|
"hash": "80ae9bed74fc6348a7c1fe9f33e86b65f5d919169721f77bcf0e1bc29fbdb4f9",
|
|
@@ -147,9 +93,45 @@
|
|
|
147
93
|
"completion": 109,
|
|
148
94
|
"total": 778
|
|
149
95
|
}
|
|
150
|
-
}
|
|
151
|
-
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"hash": "fdfca9b960d0eaa8b2b96fe988ead7481d2c0b16f66ebc94fb477139b4178cdc",
|
|
100
|
+
"path": "docs/guides/index.md",
|
|
101
|
+
"metadata": {
|
|
102
|
+
"title": "ZEN 文档站点示例",
|
|
103
|
+
"summary": "介绍 ZEN 文档构建工具,一个极简主义的 Markdown 文档站点生成器,包括特性、快速开始指南、代码示例和下一步学习资源。",
|
|
104
|
+
"tags": [
|
|
105
|
+
"ZEN",
|
|
106
|
+
"文档构建工具",
|
|
107
|
+
"Markdown",
|
|
108
|
+
"站点生成器",
|
|
109
|
+
"快速开始",
|
|
110
|
+
"代码示例",
|
|
111
|
+
"多语言支持"
|
|
112
|
+
],
|
|
113
|
+
"inferred_lang": "zh-Hans",
|
|
114
|
+
"tokens_used": {
|
|
115
|
+
"prompt": 567,
|
|
116
|
+
"completion": 108,
|
|
117
|
+
"total": 675
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"hash": "6124ea88edec5bde737b26b21f71ecfeffe4e73151784856edf813ee231a4baa",
|
|
123
|
+
"path": "docs/testing/test-document.md",
|
|
124
|
+
"metadata": {
|
|
125
|
+
"title": "Test Document",
|
|
126
|
+
"summary": "这是一个测试文档,内容为空,仅包含标题。",
|
|
127
|
+
"tags": ["测试", "文档", "示例"],
|
|
128
|
+
"inferred_lang": "en-US",
|
|
129
|
+
"tokens_used": {
|
|
130
|
+
"prompt": 265,
|
|
131
|
+
"completion": 58,
|
|
132
|
+
"total": 323
|
|
133
|
+
}
|
|
134
|
+
}
|
|
152
135
|
}
|
|
153
|
-
]
|
|
154
|
-
"timestamp": "2026-01-07T09:59:57.948Z"
|
|
136
|
+
]
|
|
155
137
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: GitHub Pages Deployment Configuration
|
|
3
|
-
summary: This document describes the GitHub Pages deployment configuration for the ZEN project documentation site, including workflow,
|
|
3
|
+
summary: This document describes the GitHub Pages deployment configuration for the ZEN project documentation site, including workflow, trigger conditions, build steps, custom configuration, troubleshooting, and manual trigger methods.
|
|
4
4
|
tags:
|
|
5
5
|
- GitHub Pages
|
|
6
6
|
- Deployment Configuration
|
|
@@ -21,7 +21,7 @@ This directory contains the GitHub Pages deployment configuration for the ZEN pr
|
|
|
21
21
|
|
|
22
22
|
This workflow automatically builds the ZEN project documentation site and deploys it to GitHub Pages.
|
|
23
23
|
|
|
24
|
-
**
|
|
24
|
+
**Trigger Conditions:**
|
|
25
25
|
|
|
26
26
|
- Push to the `main` branch (when changes occur in `demo/src/`, `package.json`, or workflow files)
|
|
27
27
|
- Pull Request targeting the `main` branch
|
|
@@ -29,20 +29,20 @@ This workflow automatically builds the ZEN project documentation site and deploy
|
|
|
29
29
|
|
|
30
30
|
**Workflow Steps:**
|
|
31
31
|
|
|
32
|
-
1. **Checkout code**:
|
|
33
|
-
2. **
|
|
34
|
-
3. **Install dependencies**:
|
|
35
|
-
4. **Build zengen**:
|
|
36
|
-
5. **Install zengen**:
|
|
37
|
-
6. **Test zengen CLI**:
|
|
38
|
-
7. **Build documentation site**:
|
|
39
|
-
8. **Configure Pages**:
|
|
40
|
-
9. **Upload artifact**:
|
|
41
|
-
10. **Deploy to GitHub Pages**: Automatically
|
|
32
|
+
1. **Checkout code**: Check out code from the remote branch to ensure code synchronization.
|
|
33
|
+
2. **Set up Node.js**: Configure the Node.js 20.x environment.
|
|
34
|
+
3. **Install dependencies**: Install project dependencies using `npm ci`.
|
|
35
|
+
4. **Build zengen**: Build the local zengen package.
|
|
36
|
+
5. **Install zengen**: Install the locally built zengen as a global tool.
|
|
37
|
+
6. **Test zengen CLI**: Verify the CLI tool functions correctly.
|
|
38
|
+
7. **Build documentation site**: Build the documentation using `cd demo/src && zengen build`, outputting to the `.zen/dist` directory.
|
|
39
|
+
8. **Configure Pages**: Set up GitHub Pages.
|
|
40
|
+
9. **Upload artifact**: Upload the built documentation site as a Pages artifact.
|
|
41
|
+
10. **Deploy to GitHub Pages**: Automatically deploy to GitHub Pages.
|
|
42
42
|
|
|
43
43
|
## Accessing the Documentation Site
|
|
44
44
|
|
|
45
|
-
After successful deployment, the documentation site will be accessible at:
|
|
45
|
+
After successful deployment, the documentation site will be accessible at the following URL:
|
|
46
46
|
|
|
47
47
|
```
|
|
48
48
|
https://[username].github.io/[repository-name]/
|
|
@@ -55,7 +55,7 @@ https://[username].github.io/[repository-name]/
|
|
|
55
55
|
If a custom domain is needed, you can add a CNAME file after the build step:
|
|
56
56
|
|
|
57
57
|
```yaml
|
|
58
|
-
# Create CNAME file (if custom domain is needed)
|
|
58
|
+
# Create CNAME file (if a custom domain is needed)
|
|
59
59
|
echo "docs.example.com" > docs-dist/CNAME
|
|
60
60
|
```
|
|
61
61
|
|
|
@@ -70,10 +70,10 @@ zengen build --verbose
|
|
|
70
70
|
|
|
71
71
|
Available options:
|
|
72
72
|
|
|
73
|
-
- `--verbose`:
|
|
73
|
+
- `--verbose`: Show verbose output.
|
|
74
74
|
- `--watch`: Watch mode (not suitable for CI/CD).
|
|
75
|
-
- `--template`:
|
|
76
|
-
- `--config`:
|
|
75
|
+
- `--template`: Specify a custom template file.
|
|
76
|
+
- `--config`: Specify a configuration file.
|
|
77
77
|
|
|
78
78
|
### Environment Variables
|
|
79
79
|
|
|
@@ -84,24 +84,24 @@ The workflow uses the following environment variables:
|
|
|
84
84
|
|
|
85
85
|
## Troubleshooting
|
|
86
86
|
|
|
87
|
-
### Build
|
|
87
|
+
### Build Failure
|
|
88
88
|
|
|
89
89
|
1. **Check Node.js version**: Ensure a supported Node.js version is used.
|
|
90
90
|
2. **Verify dependency installation**: Ensure `npm ci` executes successfully.
|
|
91
91
|
3. **Check build output**: Review the verbose output of `zengen build`.
|
|
92
92
|
4. **CLI output directory issue**: ZEN now forces output to the `.zen/dist` directory and no longer supports the `--out` parameter.
|
|
93
93
|
|
|
94
|
-
### Deployment
|
|
94
|
+
### Deployment Failure
|
|
95
95
|
|
|
96
96
|
1. **Check permissions**: Ensure the workflow has correct write permissions for Pages.
|
|
97
97
|
2. **Verify artifact**: Ensure the `.zen/dist` directory contains valid HTML files.
|
|
98
98
|
3. **Review logs**: Check GitHub Actions logs for detailed error messages.
|
|
99
99
|
|
|
100
|
-
### Documentation Not
|
|
100
|
+
### Documentation Not Updated
|
|
101
101
|
|
|
102
|
-
1. **Check
|
|
103
|
-
2. **Wait for deployment**: GitHub Pages deployment may take a few minutes.
|
|
104
|
-
3. **Clear browser cache**: The browser
|
|
102
|
+
1. **Check trigger conditions**: Ensure files in the `demo/src/` directory were modified.
|
|
103
|
+
2. **Wait for deployment completion**: GitHub Pages deployment may take a few minutes.
|
|
104
|
+
3. **Clear browser cache**: The browser may be caching an old version.
|
|
105
105
|
|
|
106
106
|
## Manual Trigger
|
|
107
107
|
|
|
@@ -29,10 +29,10 @@ Life is short, I use AI translation. Stay connected with the world.
|
|
|
29
29
|
## Core Features
|
|
30
30
|
|
|
31
31
|
1. **Static Site Generation**
|
|
32
|
-
- Build any folder containing Markdown files
|
|
32
|
+
- Build a static HTML site from any folder containing Markdown files.
|
|
33
33
|
|
|
34
34
|
2. **Intelligent Navigation**
|
|
35
|
-
- Generate site maps and navigation without needing to
|
|
35
|
+
- Generate site maps and navigation without needing to preserve the original directory structure of the Markdown source files.
|
|
36
36
|
|
|
37
37
|
3. **Incremental i18n Translation**
|
|
38
38
|
- Use LLM for incremental i18n translation, allowing users to write Markdown in their native language while supporting multilingual audiences.
|
|
@@ -23,7 +23,7 @@ This document introduces best practices for building documentation sites using Z
|
|
|
23
23
|
1. **Primary Language First**: Write the complete documentation in your native language first.
|
|
24
24
|
2. **Incremental Translation**: Only translate modified parts after each update.
|
|
25
25
|
3. **Terminology Consistency**: Create a glossary to maintain translation consistency.
|
|
26
|
-
4. **Human
|
|
26
|
+
4. **Human Review**: It is recommended to perform human review after AI translation.
|
|
27
27
|
|
|
28
28
|
## Performance Optimization
|
|
29
29
|
|
|
@@ -31,7 +31,7 @@ This document introduces best practices for building documentation sites using Z
|
|
|
31
31
|
|
|
32
32
|
1. **Incremental Builds**: Use `--watch` mode for development.
|
|
33
33
|
2. **Cache Utilization**: ZEN automatically caches processing results.
|
|
34
|
-
3. **Parallel Processing**:
|
|
34
|
+
3. **Parallel Processing**: Files are automatically processed in parallel on multi-core CPUs.
|
|
35
35
|
|
|
36
36
|
### Development Workflow
|
|
37
37
|
|
|
@@ -144,7 +144,7 @@ rm -rf .zen/cache
|
|
|
144
144
|
|
|
145
145
|
- Provide context to the AI translator.
|
|
146
146
|
- Create a glossary to improve consistency.
|
|
147
|
-
- Perform human
|
|
147
|
+
- Perform human review for critical content.
|
|
148
148
|
- Adjust translation prompts.
|
|
149
149
|
|
|
150
150
|
### Complex Navigation Structure
|
|
@@ -44,9 +44,9 @@ npx zengen
|
|
|
44
44
|
|
|
45
45
|
**Important Notes:**
|
|
46
46
|
|
|
47
|
-
- ZEN enforces the use of the current directory as the source directory, outputting to the `.zen/dist` directory
|
|
48
|
-
- Specifying source and output directories via command-line arguments is no longer supported
|
|
49
|
-
- When using `--watch` mode, modifying files triggers automatic rebuilds
|
|
47
|
+
- ZEN enforces the use of the current directory as the source directory, outputting to the `.zen/dist` directory.
|
|
48
|
+
- Specifying source and output directories via command-line arguments is no longer supported.
|
|
49
|
+
- When using `--watch` mode, modifying files triggers automatic rebuilds.
|
|
50
50
|
|
|
51
51
|
### Command Line Options
|
|
52
52
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Quick Start Guide
|
|
3
|
-
summary: This document introduces
|
|
3
|
+
summary: This document introduces how to quickly get started with the ZEN documentation generator, including installation steps, basic usage, and main features.
|
|
4
4
|
tags:
|
|
5
5
|
- ZEN Documentation Generator
|
|
6
6
|
- Quick Start
|
|
@@ -8,8 +8,7 @@ tags:
|
|
|
8
8
|
- Basic Usage
|
|
9
9
|
- Features
|
|
10
10
|
- Markdown
|
|
11
|
-
-
|
|
12
|
-
- Multi-language Support
|
|
11
|
+
- Build Command
|
|
13
12
|
inferred_lang: en-US
|
|
14
13
|
---
|
|
15
14
|
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: ZEN Documentation Site Example
|
|
3
|
-
summary: Introducing ZEN documentation builder, a minimalist Markdown documentation site generator, including features
|
|
3
|
+
summary: Introducing ZEN documentation builder, a minimalist Markdown documentation site generator, including features, quick start guide, code examples, and next-step learning resources.
|
|
4
4
|
tags:
|
|
5
5
|
- ZEN
|
|
6
6
|
- Documentation Builder
|
|
7
7
|
- Markdown
|
|
8
8
|
- Site Generator
|
|
9
|
-
- Minimalism
|
|
10
9
|
- Quick Start
|
|
11
|
-
-
|
|
10
|
+
- Code Examples
|
|
11
|
+
- Multi-language Support
|
|
12
12
|
inferred_lang: en-US
|
|
13
13
|
---
|
|
14
14
|
|
|
@@ -20,8 +20,8 @@ Welcome to the ZEN documentation builder! This is a minimalist Markdown document
|
|
|
20
20
|
|
|
21
21
|
- **Minimal Configuration**: No complex configuration files required
|
|
22
22
|
- **Content-First**: Focus on writing, not tool configuration
|
|
23
|
-
- **
|
|
24
|
-
- **
|
|
23
|
+
- **Smart Navigation**: Automatically generates site maps and navigation
|
|
24
|
+
- **Multi-language Support**: Supports incremental i18n translation
|
|
25
25
|
|
|
26
26
|
## Quick Start
|
|
27
27
|
|
package/.zen/src/zh-Hans/f0c2799126931ccd113a0c45b1e623870b0d4f4f400becf6dd877da8f1011517.md
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: 快速开始指南
|
|
3
|
-
summary:
|
|
3
|
+
summary: 本文档介绍如何快速开始使用 ZEN 文档生成器,包括安装步骤、基本用法和主要特性。
|
|
4
4
|
tags:
|
|
5
|
-
- ZEN文档生成器
|
|
5
|
+
- ZEN 文档生成器
|
|
6
6
|
- 快速开始
|
|
7
7
|
- 安装
|
|
8
8
|
- 基本用法
|
|
9
9
|
- 特性
|
|
10
10
|
- Markdown
|
|
11
|
-
-
|
|
12
|
-
- 多语言支持
|
|
11
|
+
- 构建命令
|
|
13
12
|
inferred_lang: zh-Hans
|
|
14
13
|
---
|
|
15
14
|
|
package/.zen/src/zh-Hans/fdfca9b960d0eaa8b2b96fe988ead7481d2c0b16f66ebc94fb477139b4178cdc.md
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: ZEN 文档站点示例
|
|
3
|
-
summary: 介绍 ZEN 文档构建工具,一个极简主义的 Markdown
|
|
3
|
+
summary: 介绍 ZEN 文档构建工具,一个极简主义的 Markdown 文档站点生成器,包括特性、快速开始指南、代码示例和下一步学习资源。
|
|
4
4
|
tags:
|
|
5
5
|
- ZEN
|
|
6
6
|
- 文档构建工具
|
|
7
7
|
- Markdown
|
|
8
8
|
- 站点生成器
|
|
9
|
-
- 极简主义
|
|
10
9
|
- 快速开始
|
|
10
|
+
- 代码示例
|
|
11
11
|
- 多语言支持
|
|
12
12
|
inferred_lang: zh-Hans
|
|
13
13
|
---
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../src/build/pipeline.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../src/build/pipeline.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AA4LxC;;GAEG;AACH,wBAAsB,SAAS,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAgBpE"}
|
package/dist/build/pipeline.js
CHANGED
|
@@ -132,14 +132,14 @@ async function storeNativeFiles() {
|
|
|
132
132
|
*/
|
|
133
133
|
async function processTranslations() {
|
|
134
134
|
const { files, options: { langs = [], verbose }, } = metadata_1.MetaData;
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
135
|
+
await Promise.all(files.flatMap(async (file) => {
|
|
136
|
+
return Promise.all(langs.map(async (lang) => {
|
|
137
|
+
if (verbose)
|
|
138
|
+
console.info(`📄 Processing file for translation: ${file.path}`);
|
|
139
|
+
if (!file.metadata) {
|
|
140
|
+
console.warn(`⚠️ Missing metadata for file: ${file.path}, skipping translation.`);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
143
|
if (verbose)
|
|
144
144
|
console.log(`🌐 Translating to ${lang}...`);
|
|
145
145
|
// 存储翻译文件到 .zen/src/{lang}
|
|
@@ -150,7 +150,7 @@ async function processTranslations() {
|
|
|
150
150
|
if (file.metadata.inferred_lang === lang) {
|
|
151
151
|
if (verbose)
|
|
152
152
|
console.log(`ℹ️ Skipping translation for ${file.path}, already in target language`);
|
|
153
|
-
|
|
153
|
+
return;
|
|
154
154
|
}
|
|
155
155
|
else {
|
|
156
156
|
// 翻译
|
|
@@ -159,7 +159,7 @@ async function processTranslations() {
|
|
|
159
159
|
if (exists) {
|
|
160
160
|
if (verbose)
|
|
161
161
|
console.log(`ℹ️ Translation already exists for ${file.path} in ${lang}`);
|
|
162
|
-
|
|
162
|
+
return;
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
165
|
const translatedContent = await (0, translateMarkdown_1.translateMarkdown)(content, lang);
|
|
@@ -171,8 +171,8 @@ async function processTranslations() {
|
|
|
171
171
|
catch (error) {
|
|
172
172
|
console.error(`❌ Failed to translate to ${lang}:`, error);
|
|
173
173
|
}
|
|
174
|
-
}
|
|
175
|
-
}
|
|
174
|
+
}));
|
|
175
|
+
}));
|
|
176
176
|
}
|
|
177
177
|
/**
|
|
178
178
|
* 构建管道(函数组合)
|
|
@@ -183,6 +183,7 @@ async function buildPipeline(options) {
|
|
|
183
183
|
// 清理输出目录
|
|
184
184
|
await fs.rm(paths_1.ZEN_DIST_DIR, { recursive: true, force: true });
|
|
185
185
|
// 确保 .zen/.gitignore 文件
|
|
186
|
+
await fs.mkdir(paths_1.ZEN_DIR, { recursive: true });
|
|
186
187
|
await fs.writeFile(path.join(paths_1.ZEN_DIR, '.gitignore'), 'dist\n', 'utf-8');
|
|
187
188
|
// 扫描源文件
|
|
188
189
|
await scanSourceFiles();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline.js","sourceRoot":"","sources":["../../src/build/pipeline.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"pipeline.js","sourceRoot":"","sources":["../../src/build/pipeline.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwMA,8BAgBC;AAxND,gDAAkC;AAClC,2CAA6B;AAC7B,+DAA4D;AAC5D,gDAAqD;AACrD,0CAAmE;AACnE,oCAAyE;AACzE,wEAAqE;AACrE,kDAAsD;AACtD,yCAAkD;AAElD,sDAAyD;AAEzD;;GAEG;AACH,KAAK,UAAU,cAAc,CAAC,OAAqB;IACjD,MAAM,EAAE,OAAO,GAAG,KAAK,EAAE,GAAG,OAAO,CAAC;IAEpC,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC;QACxC,OAAO,CAAC,GAAG,CAAC,gBAAgB,OAAO,CAAC,OAAO,IAAI,WAAW,EAAE,CAAC,CAAC;QAC9D,IAAI,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC9C,OAAO,CAAC,GAAG,CAAC,wBAAwB,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAClE,CAAC;QACD,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;IACzC,CAAC;IAED,mBAAQ,CAAC,OAAO,GAAG,OAAO,CAAC;AAC7B,CAAC;AAED;;GAEG;AACH,KAAK,UAAU,eAAe;IAC5B,OAAO,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAC;IAC/C,MAAM,aAAa,GAAG,MAAM,IAAA,iCAAmB,EAAC,iBAAS,CAAC,CAAC;IAC3D,MAAM,MAAM,GAAG,IAAI,GAAG,EAAU,CAAC;IAEjC,KAAK,MAAM,YAAY,IAAI,aAAa,EAA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,CAAC;IACd,CAAC;YAAS,CAAC;QACT,MAAM,IAAA,uBAAY,GAAE,CAAC;IACvB,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extractMetadataByAI.d.ts","sourceRoot":"","sources":["../../src/process/extractMetadataByAI.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"extractMetadataByAI.d.ts","sourceRoot":"","sources":["../../src/process/extractMetadataByAI.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC,CAuBzD"}
|
|
@@ -12,11 +12,11 @@ async function extractMetadataByAI() {
|
|
|
12
12
|
if (metadata_1.MetaData.options.verbose)
|
|
13
13
|
console.log(`🤖 Running AI metadata extraction...`);
|
|
14
14
|
console.log(`🤖 Processing ${files.length} files with AI...`);
|
|
15
|
-
|
|
15
|
+
await Promise.all(files.map(async (file) => {
|
|
16
16
|
try {
|
|
17
17
|
if (file.metadata) {
|
|
18
18
|
console.info(`ℹ️ Skipping ${file.path}, already has metadata`);
|
|
19
|
-
|
|
19
|
+
return;
|
|
20
20
|
}
|
|
21
21
|
const content = await (0, promises_1.readFile)(file.path, 'utf-8');
|
|
22
22
|
file.metadata = await (0, extractMetadataFromMarkdown_1.extractMetadataFromMarkdown)(content);
|
|
@@ -25,7 +25,7 @@ async function extractMetadataByAI() {
|
|
|
25
25
|
catch (error) {
|
|
26
26
|
console.error(`⚠️ Failed to process file ${file.path}:`, error);
|
|
27
27
|
}
|
|
28
|
-
}
|
|
28
|
+
}));
|
|
29
29
|
console.log(`✅ AI processing completed for ${files.length} files`);
|
|
30
30
|
}
|
|
31
31
|
//# sourceMappingURL=extractMetadataByAI.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extractMetadataByAI.js","sourceRoot":"","sources":["../../src/process/extractMetadataByAI.ts"],"names":[],"mappings":";;AAOA,
|
|
1
|
+
{"version":3,"file":"extractMetadataByAI.js","sourceRoot":"","sources":["../../src/process/extractMetadataByAI.ts"],"names":[],"mappings":";;AAOA,kDAuBC;AA9BD,0CAAuC;AACvC,mFAAgF;AAChF,0CAAuC;AAEvC;;GAEG;AACI,KAAK,UAAU,mBAAmB;IACvC,MAAM,EAAE,KAAK,EAAE,GAAG,mBAAQ,CAAC;IAE3B,IAAI,mBAAQ,CAAC,OAAO,CAAC,OAAO;QAAE,OAAO,CAAC,GAAG,CAAC,sCAAsC,CAAC,CAAC;IAClF,OAAO,CAAC,GAAG,CAAC,iBAAiB,KAAK,CAAC,MAAM,mBAAmB,CAAC,CAAC;IAE9D,MAAM,OAAO,CAAC,GAAG,CACf,KAAK,CAAC,GAAG,CAAC,KAAK,EAAC,IAAI,EAAC,EAAE;QACrB,IAAI,CAAC;YACH,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;gBAClB,OAAO,CAAC,IAAI,CAAC,eAAe,IAAI,CAAC,IAAI,wBAAwB,CAAC,CAAC;gBAC/D,OAAO;YACT,CAAC;YACD,MAAM,OAAO,GAAG,MAAM,IAAA,mBAAQ,EAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YACnD,IAAI,CAAC,QAAQ,GAAG,MAAM,IAAA,yDAA2B,EAAC,OAAO,CAAC,CAAC;YAC3D,OAAO,CAAC,GAAG,CAAC,+BAA+B,IAAI,CAAC,IAAI,EAAE,EAAE,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QACrF,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,6BAA6B,IAAI,CAAC,IAAI,GAAG,EAAE,KAAK,CAAC,CAAC;QAClE,CAAC;IACH,CAAC,CAAC,CACH,CAAC;IAEF,OAAO,CAAC,GAAG,CAAC,iCAAiC,KAAK,CAAC,MAAM,QAAQ,CAAC,CAAC;AACrE,CAAC"}
|
package/package.json
CHANGED
package/src/build/pipeline.ts
CHANGED
|
@@ -115,49 +115,54 @@ async function processTranslations(): Promise<void> {
|
|
|
115
115
|
options: { langs = [], verbose },
|
|
116
116
|
} = MetaData;
|
|
117
117
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
// 存储翻译文件到 .zen/src/{lang}
|
|
127
|
-
const sourcePath = path.join(ZEN_SRC_DIR, file.metadata.inferred_lang, file.hash + '.md'); // 使用已经加强的母语文件路径
|
|
128
|
-
const targetPath = path.join(ZEN_SRC_DIR, lang, file.hash + '.md');
|
|
129
|
-
|
|
130
|
-
try {
|
|
131
|
-
const content = await fs.readFile(sourcePath, 'utf-8');
|
|
132
|
-
if (file.metadata.inferred_lang === lang) {
|
|
133
|
-
if (verbose)
|
|
134
|
-
console.log(`ℹ️ Skipping translation for ${file.path}, already in target language`);
|
|
135
|
-
continue;
|
|
136
|
-
} else {
|
|
137
|
-
// 翻译
|
|
138
|
-
// 先检查是否已经有翻译文件存在
|
|
139
|
-
|
|
140
|
-
const exists = await fs.access(targetPath).then(
|
|
141
|
-
() => true,
|
|
142
|
-
() => false
|
|
143
|
-
);
|
|
144
|
-
if (exists) {
|
|
145
|
-
if (verbose) console.log(`ℹ️ Translation already exists for ${file.path} in ${lang}`);
|
|
146
|
-
continue;
|
|
118
|
+
await Promise.all(
|
|
119
|
+
files.flatMap(async file => {
|
|
120
|
+
return Promise.all(
|
|
121
|
+
langs.map(async lang => {
|
|
122
|
+
if (verbose) console.info(`📄 Processing file for translation: ${file.path}`);
|
|
123
|
+
if (!file.metadata) {
|
|
124
|
+
console.warn(`⚠️ Missing metadata for file: ${file.path}, skipping translation.`);
|
|
125
|
+
return;
|
|
147
126
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
127
|
+
if (verbose) console.log(`🌐 Translating to ${lang}...`);
|
|
128
|
+
// 存储翻译文件到 .zen/src/{lang}
|
|
129
|
+
const sourcePath = path.join(ZEN_SRC_DIR, file.metadata.inferred_lang, file.hash + '.md'); // 使用已经加强的母语文件路径
|
|
130
|
+
const targetPath = path.join(ZEN_SRC_DIR, lang, file.hash + '.md');
|
|
131
|
+
|
|
132
|
+
try {
|
|
133
|
+
const content = await fs.readFile(sourcePath, 'utf-8');
|
|
134
|
+
if (file.metadata.inferred_lang === lang) {
|
|
135
|
+
if (verbose)
|
|
136
|
+
console.log(`ℹ️ Skipping translation for ${file.path}, already in target language`);
|
|
137
|
+
return;
|
|
138
|
+
} else {
|
|
139
|
+
// 翻译
|
|
140
|
+
// 先检查是否已经有翻译文件存在
|
|
141
|
+
|
|
142
|
+
const exists = await fs.access(targetPath).then(
|
|
143
|
+
() => true,
|
|
144
|
+
() => false
|
|
145
|
+
);
|
|
146
|
+
if (exists) {
|
|
147
|
+
if (verbose)
|
|
148
|
+
console.log(`ℹ️ Translation already exists for ${file.path} in ${lang}`);
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const translatedContent = await translateMarkdown(content, lang);
|
|
154
|
+
|
|
155
|
+
await fs.mkdir(path.dirname(targetPath), { recursive: true });
|
|
156
|
+
await fs.writeFile(targetPath, translatedContent, 'utf-8');
|
|
157
|
+
|
|
158
|
+
if (verbose) console.log(`✅ Translated file saved: ${targetPath}`);
|
|
159
|
+
} catch (error) {
|
|
160
|
+
console.error(`❌ Failed to translate to ${lang}:`, error);
|
|
161
|
+
}
|
|
162
|
+
})
|
|
163
|
+
);
|
|
164
|
+
})
|
|
165
|
+
);
|
|
161
166
|
}
|
|
162
167
|
|
|
163
168
|
/**
|
|
@@ -171,6 +176,7 @@ async function buildPipeline(options: BuildOptions): Promise<void> {
|
|
|
171
176
|
await fs.rm(ZEN_DIST_DIR, { recursive: true, force: true });
|
|
172
177
|
|
|
173
178
|
// 确保 .zen/.gitignore 文件
|
|
179
|
+
await fs.mkdir(ZEN_DIR, { recursive: true });
|
|
174
180
|
await fs.writeFile(path.join(ZEN_DIR, '.gitignore'), 'dist\n', 'utf-8');
|
|
175
181
|
|
|
176
182
|
// 扫描源文件
|
|
@@ -11,19 +11,21 @@ export async function extractMetadataByAI(): Promise<void> {
|
|
|
11
11
|
if (MetaData.options.verbose) console.log(`🤖 Running AI metadata extraction...`);
|
|
12
12
|
console.log(`🤖 Processing ${files.length} files with AI...`);
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
await Promise.all(
|
|
15
|
+
files.map(async file => {
|
|
16
|
+
try {
|
|
17
|
+
if (file.metadata) {
|
|
18
|
+
console.info(`ℹ️ Skipping ${file.path}, already has metadata`);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const content = await readFile(file.path, 'utf-8');
|
|
22
|
+
file.metadata = await extractMetadataFromMarkdown(content);
|
|
23
|
+
console.log(`✅ Extracted AI metadata for ${file.path}`, file.metadata.tokens_used);
|
|
24
|
+
} catch (error) {
|
|
25
|
+
console.error(`⚠️ Failed to process file ${file.path}:`, error);
|
|
19
26
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
console.log(`✅ Extracted AI metadata for ${file.path}`, file.metadata.tokens_used);
|
|
23
|
-
} catch (error) {
|
|
24
|
-
console.error(`⚠️ Failed to process file ${file.path}:`, error);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
+
})
|
|
28
|
+
);
|
|
27
29
|
|
|
28
30
|
console.log(`✅ AI processing completed for ${files.length} files`);
|
|
29
31
|
}
|
package/.zen/src/zh-Hans/6ad8db715a1b60613fe934fefb29fa981ecad9b63145593accff144d73b44bde.md
DELETED
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
# 最佳实践
|
|
2
|
-
|
|
3
|
-
本文档介绍使用 ZEN 构建文档站点的最佳实践。
|
|
4
|
-
|
|
5
|
-
## 多语言管理
|
|
6
|
-
|
|
7
|
-
### 翻译策略
|
|
8
|
-
|
|
9
|
-
1. **主语言优先**: 先用母语完整编写文档
|
|
10
|
-
2. **增量翻译**: 每次更新后只翻译修改部分
|
|
11
|
-
3. **术语一致**: 建立术语表保持翻译一致性
|
|
12
|
-
4. **人工校对**: AI 翻译后建议人工校对
|
|
13
|
-
|
|
14
|
-
## 性能优化
|
|
15
|
-
|
|
16
|
-
### 构建优化
|
|
17
|
-
|
|
18
|
-
1. **增量构建**: 使用 `--watch` 模式开发
|
|
19
|
-
2. **缓存利用**: ZEN 会自动缓存处理结果
|
|
20
|
-
3. **并行处理**: 多核 CPU 自动并行处理文件
|
|
21
|
-
|
|
22
|
-
### 开发工作流
|
|
23
|
-
|
|
24
|
-
```bash
|
|
25
|
-
# 开发时监听变化
|
|
26
|
-
cd docs
|
|
27
|
-
npx zengen build --watch
|
|
28
|
-
|
|
29
|
-
# 启动开发服务器
|
|
30
|
-
npx zengen build --watch --serve
|
|
31
|
-
|
|
32
|
-
# 生产构建
|
|
33
|
-
npx zengen build
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
## 部署策略
|
|
37
|
-
|
|
38
|
-
### CI/CD 集成
|
|
39
|
-
|
|
40
|
-
#### GitHub Actions 示例
|
|
41
|
-
|
|
42
|
-
```yaml
|
|
43
|
-
name: Build and Deploy Documentation
|
|
44
|
-
on:
|
|
45
|
-
push:
|
|
46
|
-
branches: [main]
|
|
47
|
-
paths:
|
|
48
|
-
- 'docs/**'
|
|
49
|
-
- '.github/workflows/docs.yml'
|
|
50
|
-
|
|
51
|
-
jobs:
|
|
52
|
-
build:
|
|
53
|
-
runs-on: ubuntu-latest
|
|
54
|
-
steps:
|
|
55
|
-
- name: Checkout repository
|
|
56
|
-
uses: actions/checkout@v4
|
|
57
|
-
|
|
58
|
-
- name: Setup Node.js
|
|
59
|
-
uses: actions/setup-node@v4
|
|
60
|
-
with:
|
|
61
|
-
node-version: '20.x'
|
|
62
|
-
|
|
63
|
-
- name: Build documentation
|
|
64
|
-
run: |
|
|
65
|
-
cd docs
|
|
66
|
-
npx zengen build --base-url /my-docs
|
|
67
|
-
|
|
68
|
-
- name: Deploy to GitHub Pages
|
|
69
|
-
uses: peaceiris/actions-gh-pages@v3
|
|
70
|
-
with:
|
|
71
|
-
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
72
|
-
publish_dir: docs/.zen/dist
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
#### 自定义部署脚本
|
|
76
|
-
|
|
77
|
-
```bash
|
|
78
|
-
#!/bin/bash
|
|
79
|
-
# deploy-docs.sh
|
|
80
|
-
|
|
81
|
-
# 切换到文档目录
|
|
82
|
-
cd docs
|
|
83
|
-
|
|
84
|
-
# 构建文档
|
|
85
|
-
npx zengen build
|
|
86
|
-
|
|
87
|
-
# 同步到服务器
|
|
88
|
-
rsync -avz .zen/dist/ user@server:/var/www/docs/
|
|
89
|
-
|
|
90
|
-
# 清理缓存
|
|
91
|
-
rm -rf .zen/cache
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
### 云部署选项
|
|
95
|
-
|
|
96
|
-
- **GitHub Pages**: 免费托管文档
|
|
97
|
-
- **Vercel**: 自动部署静态站点
|
|
98
|
-
- **Netlify**: 支持表单处理和重定向
|
|
99
|
-
- **AWS S3 + CloudFront**: 企业级静态托管
|
|
100
|
-
|
|
101
|
-
## 维护建议
|
|
102
|
-
|
|
103
|
-
### 定期更新
|
|
104
|
-
|
|
105
|
-
1. **内容审核**: 每月检查文档准确性
|
|
106
|
-
2. **链接检查**: 定期检查死链
|
|
107
|
-
3. **性能监控**: 监控页面加载速度
|
|
108
|
-
4. **用户反馈**: 收集用户反馈改进文档
|
|
109
|
-
|
|
110
|
-
### 版本控制
|
|
111
|
-
|
|
112
|
-
1. **文档版本化**: 与软件版本同步
|
|
113
|
-
2. **变更日志**: 记录文档更新历史
|
|
114
|
-
3. **回滚机制**: 支持快速回滚到旧版本
|
|
115
|
-
|
|
116
|
-
## 常见问题
|
|
117
|
-
|
|
118
|
-
### 构建速度慢
|
|
119
|
-
|
|
120
|
-
**解决方案:**
|
|
121
|
-
|
|
122
|
-
- 减少不必要的图片和资源
|
|
123
|
-
- 使用 `--watch` 模式进行增量开发
|
|
124
|
-
- 拆分大型文档为多个小文件
|
|
125
|
-
- 禁用不需要的处理器
|
|
126
|
-
|
|
127
|
-
### 翻译质量不高
|
|
128
|
-
|
|
129
|
-
**解决方案:**
|
|
130
|
-
|
|
131
|
-
- 提供上下文给 AI 翻译
|
|
132
|
-
- 建立术语表提高一致性
|
|
133
|
-
- 人工校对关键内容
|
|
134
|
-
- 调整翻译提示词
|
|
135
|
-
|
|
136
|
-
### 导航结构复杂
|
|
137
|
-
|
|
138
|
-
**解决方案:**
|
|
139
|
-
|
|
140
|
-
- 保持扁平化目录结构
|
|
141
|
-
- 使用清晰的标题层级
|
|
142
|
-
- 提供搜索功能
|
|
143
|
-
- 合理使用侧边栏导航
|
|
144
|
-
|
|
145
|
-
### 内存使用过高
|
|
146
|
-
|
|
147
|
-
**解决方案:**
|
|
148
|
-
|
|
149
|
-
- 减少同时处理的文件数量
|
|
150
|
-
- 禁用缓存(不推荐)
|
|
151
|
-
- 增加系统内存
|
|
152
|
-
- 分批处理大型文档
|
|
153
|
-
|
|
154
|
-
## 高级技巧
|
|
155
|
-
|
|
156
|
-
### 自定义模板技巧
|
|
157
|
-
|
|
158
|
-
1. **响应式设计**: 确保模板在移动设备上正常显示
|
|
159
|
-
2. **主题切换**: 实现深色/浅色主题
|
|
160
|
-
3. **代码高亮**: 集成 highlight.js 或其他高亮库
|
|
161
|
-
4. **搜索功能**: 添加客户端搜索
|
|
162
|
-
|
|
163
|
-
### 集成其他工具
|
|
164
|
-
|
|
165
|
-
1. **图片优化**: 使用 sharp 或 imagemin 优化图片
|
|
166
|
-
2. **SEO 优化**: 添加 meta 标签和结构化数据
|
|
167
|
-
3. **分析集成**: 集成 Google Analytics 或 Plausible
|
|
168
|
-
4. **CDN 加速**: 使用 CDN 加速静态资源
|
|
169
|
-
|
|
170
|
-
### 监控和日志
|
|
171
|
-
|
|
172
|
-
1. **构建日志**: 使用 `--verbose` 查看详细日志
|
|
173
|
-
2. **错误监控**: 设置错误监控和告警
|
|
174
|
-
3. **性能监控**: 监控构建时间和资源使用
|
|
175
|
-
4. **用户分析**: 分析文档使用情况
|
package/.zen/src/zh-Hans/a1580f71c6c6c1ff4a314be72d410a8507af2f087d56360c7f5048d349c21953.md
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
# 配置指南
|
|
2
|
-
|
|
3
|
-
ZEN 的设计理念是极简主义,因此配置非常简单。
|
|
4
|
-
|
|
5
|
-
## 命令行使用
|
|
6
|
-
|
|
7
|
-
### 基本命令
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
# 构建文档(推荐使用方式)
|
|
11
|
-
npx zengen build
|
|
12
|
-
|
|
13
|
-
# 实时预览(监听文件变化)
|
|
14
|
-
npx zengen build --watch
|
|
15
|
-
|
|
16
|
-
# 启动开发服务器(需要 --watch)
|
|
17
|
-
npx zengen build --watch --serve
|
|
18
|
-
|
|
19
|
-
# 自定义端口
|
|
20
|
-
npx zengen build --watch --serve --port 8080
|
|
21
|
-
|
|
22
|
-
# 显示详细日志
|
|
23
|
-
npx zengen build --verbose
|
|
24
|
-
|
|
25
|
-
# 设置基础 URL
|
|
26
|
-
npx zengen build --base-url /my-docs
|
|
27
|
-
|
|
28
|
-
# 查看帮助
|
|
29
|
-
npx zengen
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
**重要说明:**
|
|
33
|
-
|
|
34
|
-
- ZEN 强制使用当前目录作为源目录,输出到 `.zen/dist` 目录
|
|
35
|
-
- 不再支持通过命令行参数指定源目录和输出目录
|
|
36
|
-
- 使用 `--watch` 模式时,修改文件会自动重建
|
|
37
|
-
|
|
38
|
-
### 命令行选项
|
|
39
|
-
|
|
40
|
-
| 选项 | 简写 | 描述 | 默认值 |
|
|
41
|
-
| ------------ | ---- | -------------------------------- | ----------- |
|
|
42
|
-
| `--watch` | `-w` | 监听文件变化并自动重建 | `false` |
|
|
43
|
-
| `--serve` | `-s` | 启动开发服务器(需要 `--watch`) | `false` |
|
|
44
|
-
| `--port` | `-p` | 开发服务器端口 | `3000` |
|
|
45
|
-
| `--host` | | 开发服务器主机 | `localhost` |
|
|
46
|
-
| `--verbose` | `-v` | 显示详细日志 | `false` |
|
|
47
|
-
| `--base-url` | | 站点基础 URL | 无 |
|
|
48
|
-
| `--help` | `-h` | 显示帮助信息 | 无 |
|
package/.zen/src/zh-Hans/d49012f98c4367b34034063400e2f7826bf0615952210c82396920172d468e2c.md
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
# GitHub Pages 部署配置
|
|
2
|
-
|
|
3
|
-
此目录包含 ZEN 项目文档站点的 GitHub Pages 部署配置。
|
|
4
|
-
|
|
5
|
-
## 工作流程
|
|
6
|
-
|
|
7
|
-
### `pages.yml`
|
|
8
|
-
|
|
9
|
-
此工作流程会自动构建 ZEN 项目的文档站点并部署到 GitHub Pages。
|
|
10
|
-
|
|
11
|
-
**触发条件:**
|
|
12
|
-
|
|
13
|
-
- 推送到 `main` 分支(当 `demo/src/`、`package.json` 或工作流程文件发生变化时)
|
|
14
|
-
- 针对 `main` 分支的 Pull Request
|
|
15
|
-
- 手动触发
|
|
16
|
-
|
|
17
|
-
**工作流程步骤:**
|
|
18
|
-
|
|
19
|
-
1. **检出代码**:从远程分支检出代码,确保代码同步
|
|
20
|
-
2. **设置 Node.js**:配置 Node.js 20.x 环境
|
|
21
|
-
3. **安装依赖**:使用 `npm ci` 安装项目依赖
|
|
22
|
-
4. **构建 zengen**:构建本地 zengen 包
|
|
23
|
-
5. **安装 zengen**:将本地构建的 zengen 安装为全局工具
|
|
24
|
-
6. **测试 zengen CLI**:验证 CLI 工具正常工作
|
|
25
|
-
7. **构建文档站点**:使用 `cd demo/src && zengen build` 构建文档,输出到 `.zen/dist` 目录
|
|
26
|
-
8. **配置 Pages**:设置 GitHub Pages
|
|
27
|
-
9. **上传制品**:将构建的文档站点上传为 Pages 制品
|
|
28
|
-
10. **部署到 GitHub Pages**:自动部署到 GitHub Pages
|
|
29
|
-
|
|
30
|
-
## 访问文档站点
|
|
31
|
-
|
|
32
|
-
部署成功后,文档站点将可通过以下 URL 访问:
|
|
33
|
-
|
|
34
|
-
```
|
|
35
|
-
https://[用户名].github.io/[仓库名]/
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
## 自定义配置
|
|
39
|
-
|
|
40
|
-
### 自定义域名
|
|
41
|
-
|
|
42
|
-
如果需要使用自定义域名,可以在构建步骤后添加 CNAME 文件:
|
|
43
|
-
|
|
44
|
-
```yaml
|
|
45
|
-
# 创建 CNAME 文件(如果需要自定义域名)
|
|
46
|
-
echo "docs.example.com" > docs-dist/CNAME
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
### 构建选项
|
|
50
|
-
|
|
51
|
-
当前使用的构建命令:
|
|
52
|
-
|
|
53
|
-
```bash
|
|
54
|
-
cd demo/src
|
|
55
|
-
zengen build --verbose
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
可用的选项:
|
|
59
|
-
|
|
60
|
-
- `--verbose`:显示详细输出
|
|
61
|
-
- `--watch`:监听模式(不适用于 CI/CD)
|
|
62
|
-
- `--template`:指定自定义模板文件
|
|
63
|
-
- `--config`:指定配置文件
|
|
64
|
-
|
|
65
|
-
### 环境变量
|
|
66
|
-
|
|
67
|
-
工作流程使用以下环境变量:
|
|
68
|
-
|
|
69
|
-
- `GITHUB_TOKEN`:自动提供的 GitHub 令牌
|
|
70
|
-
- `NODE_VERSION`:Node.js 版本(默认为 20.x)
|
|
71
|
-
|
|
72
|
-
## 故障排除
|
|
73
|
-
|
|
74
|
-
### 构建失败
|
|
75
|
-
|
|
76
|
-
1. **检查 Node.js 版本**:确保使用支持的 Node.js 版本
|
|
77
|
-
2. **验证依赖安装**:确保 `npm ci` 成功执行
|
|
78
|
-
3. **检查构建输出**:查看 `zengen build` 的详细输出
|
|
79
|
-
4. **CLI 输出目录问题**:ZEN 现在强制输出到 `.zen/dist` 目录,不再支持 `--out` 参数。
|
|
80
|
-
|
|
81
|
-
### 部署失败
|
|
82
|
-
|
|
83
|
-
1. **检查权限**:确保工作流程有正确的 Pages 写入权限
|
|
84
|
-
2. **验证制品**:确保 `.zen/dist` 目录包含有效的 HTML 文件
|
|
85
|
-
3. **查看日志**:检查 GitHub Actions 日志获取详细错误信息
|
|
86
|
-
|
|
87
|
-
### 文档未更新
|
|
88
|
-
|
|
89
|
-
1. **检查触发条件**:确保修改了 `demo/src/` 目录下的文件
|
|
90
|
-
2. **等待部署完成**:GitHub Pages 部署可能需要几分钟
|
|
91
|
-
3. **清除浏览器缓存**:浏览器可能缓存了旧版本
|
|
92
|
-
|
|
93
|
-
## 手动触发
|
|
94
|
-
|
|
95
|
-
可以通过 GitHub Actions 界面手动触发部署:
|
|
96
|
-
|
|
97
|
-
1. 进入仓库的 "Actions" 标签页
|
|
98
|
-
2. 选择 "Deploy to GitHub Pages" 工作流程
|
|
99
|
-
3. 点击 "Run workflow" 按钮
|
|
100
|
-
4. 选择分支并运行
|
|
101
|
-
|
|
102
|
-
## 相关文件
|
|
103
|
-
|
|
104
|
-
- `demo/src/`:文档源文件(Markdown 格式)
|
|
105
|
-
- `package.json`:项目配置和依赖
|
|
106
|
-
- `src/cli.ts`:zengen CLI 工具实现
|
|
107
|
-
- `src/builder.ts`:文档构建器实现
|