Skip to content

Commit ab8f238

Browse files
authored
fix: export entry should be relative to docs directory instead (#102)
1 parent b7f0072 commit ab8f238

File tree

6 files changed

+81
-83
lines changed

6 files changed

+81
-83
lines changed

.changeset/silly-zebras-itch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@alauda/doom": patch
3+
---
4+
5+
fix: export entry should be relative to docs directory instead

docs/en/start.mdx

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
sourceSHA: 66020a9ebd1f1f108b82b1bf05e1e8b3e51c7b35cb482a48a6e26a2c0bb74316
2+
sourceSHA: ae0b93052a9ac54c78d33e4bd8516f66409fb0355f52e0ce069d53cf0138a992
33
---
44

55
# Getting Started \{#start}
@@ -12,7 +12,7 @@ First, you can create a new directory with the following command:
1212
mkdir my-docs && cd my-docs
1313
```
1414

15-
Run `npm init -y` to initialize a project. You can install doom using npm, yarn, or pnpm:
15+
Run `npm init -y` to initialize a project. You can use npm, yarn, or pnpm to install doom:
1616

1717
<PackageManagerTabs command="install -D @alauda/doom typescript" />
1818

@@ -24,7 +24,7 @@ mkdir docs/en && echo '# Hello World' > docs/en/index.md
2424
mkdir docs/zh && echo '# 你好世界' > docs/zh/index.md
2525
```
2626

27-
Add the following scripts to your `package.json`:
27+
Add the following scripts to `package.json`:
2828

2929
```json
3030
{
@@ -45,7 +45,7 @@ Then initialize a configuration file `doom.config.yml`:
4545
title: My Docs
4646
```
4747
48-
Also create a `tsconfig.json` file with the following content:
48+
Also create `tsconfig.json` with the following content:
4949

5050
```jsonc
5151
{
@@ -121,7 +121,7 @@ For more configuration, please refer to [Configuration](./usage/configuration)
121121
122122
### Starting the Development Server \{#dev}
123123
124-
Run `yarn dev` to start the development server, the browser will automatically open the documentation homepage.
124+
Run `yarn dev` to start the development server; the browser will automatically open the documentation homepage.
125125

126126
```sh
127127
doom dev -h
@@ -148,7 +148,7 @@ Run `yarn build` to build the production code. After building, static files will
148148

149149
### Local Preview \{#serve}
150150

151-
Run `yarn serve` to preview the built static files. Note that if you used `-b`, `-p` parameters during build, you also need to use `-b`, `-p` parameters during preview.
151+
Run `yarn serve` to preview the built static files. Note that if you used `-b` or `-p` parameters during build, you need to use the same `-b` and `-p` parameters during preview.
152152

153153
### Using Scaffolding Templates \{#new}
154154

@@ -175,20 +175,20 @@ Options:
175175
-h, --help display help for command
176176
```
177177

178-
- The `-g, --glob` parameter is required and can specify the directories or paths of files to translate, supporting `glob` syntax. Note that the parameter value must be quoted, otherwise it may be parsed unexpectedly by the command line. Examples:
178+
- The `-g, --glob` parameter is required. You can specify the directories or paths of files to translate, supporting `glob` syntax. Note that the parameter value must be quoted to avoid unexpected behavior from the command line parser. Examples:
179179
1. `yarn translate -g abc xyz` will translate all documents under `<root>/<source>/abc` and `<root>/<source>/xyz` to `<root>/<target>/abc` and `<root>/<target>/xyz` respectively.
180-
2. `yarn translate -g '*'` will translate all documents under `<root>/<source>`.
181-
- The `-C, --copy` parameter is optional. It determines whether to copy local asset files to the target directory when the target file does not exist. The default is `false`, which means changing the asset file reference path to the source path. Examples:
182-
- When enabled:
183-
1. When translating `/<source>/abc.jpg`, it will copy `<root>/public/<source>/abc.jpg` to `<root>/public/<target>/abc.jpg` and update the document reference path to `/<target>/abc.jpg`.
184-
2. In `<root>/<source>/abc.mdx`, if the document references `./assets/xyz.jpg`, it will copy `<root>/<source>/assets/xyz.jpg` to `<root>/<target>/assets/xyz.jpg`, and the image reference path remains unchanged.
185-
3. In `<root>/<source>/abc.mdx`, if the document references `./assets/<source>/xyz.jpg`, it will copy `<root>/<source>/assets/<source>/xyz.jpg` to `<root>/<target>/assets/<target>/xyz.jpg` and update the document reference path to `./assets/<target>/xyz.jpg`.
186-
- When not enabled:
187-
1. When translating `/<source>/abc.jpg`, if `<root>/public/<target>/abc.jpg` exists, the document reference path will be updated to `/<target>/abc.jpg`; otherwise, the image reference path remains unchanged.
188-
2. In `<root>/<source>/abc.mdx`, if the document references `./assets/<source>/xyz.jpg`, and `<root>/<target>/assets/<target>/xyz.jpg` exists, the reference path will be updated to `./assets/<target>/xyz.jpg`; otherwise, it will be changed to `../<source>/assets/<target>/xyz.jpg`.
180+
2. `yarn translate -g '*'` will translate all document files under `<root>/<source>`.
181+
- The `-C, --copy` parameter is optional. It controls whether to copy local asset files to the target directory when the target file does not exist. The default is `false`, which means changing the asset reference paths to the source paths. Examples:
182+
- When this parameter is enabled:
183+
1. When translating `/<source>/abc.jpg`, it will copy `<root>/public/<source>/abc.jpg` to `<root>/public/<target>/abc.jpg` and modify the reference path in the document to `/<target>/abc.jpg`.
184+
2. In `<root>/<source>/abc.mdx`, when translating `./assets/xyz.jpg`, it will copy `<root>/<source>/assets/xyz.jpg` to `<root>/<target>/assets/xyz.jpg`, and the image reference path remains unchanged.
185+
3. In `<root>/<source>/abc.mdx`, when translating `./assets/<source>/xyz.jpg`, it will copy `<root>/<source>/assets/<source>/xyz.jpg` to `<root>/<target>/assets/<target>/xyz.jpg` and modify the reference path in the document to `./assets/<target>/xyz.jpg`.
186+
- When this parameter is not enabled:
187+
1. When translating `/<source>/abc.jpg`, if `<root>/public/<target>/abc.jpg` exists, the reference path in the document will be changed to `/<target>/abc.jpg`; otherwise, the image reference path remains unchanged.
188+
2. In `<root>/<source>/abc.mdx`, when translating `./assets/<source>/xyz.jpg`, if `<root>/<target>/assets/<target>/xyz.jpg` exists, the reference path will be changed to `./assets/<target>/xyz.jpg`; otherwise, it will be changed to `../<source>/assets/<target>/xyz.jpg`.
189189

190190
:::warning
191-
Specially, if you use `-g '*'` for full translation, the file lists of `source` and `target` directories will be compared, and unmatched `target` files except for `internalRoutes` will be automatically deleted.
191+
Specifically, if you use `-g '*'` for full translation, the file lists of `source` and `target` directories will be compared, and unmatched `target` files except for `internalRoutes` will be automatically deleted.
192192
:::
193193

194194
:::tip
@@ -211,7 +211,7 @@ For more configuration, please refer to [Translation Configuration](./usage/conf
211211
### Exporting PDF \{#export}
212212
213213
:::warning
214-
Please run `yarn build` before performing the export operation.
214+
Please run `yarn build` to build the project before exporting.
215215
:::
216216

217217
```sh
@@ -231,17 +231,15 @@ Options:
231231
-h, --help display help for command
232232
```
233233

234-
Run `yarn export` to export the documentation as a PDF file. Note that if you used `-b`, `-p` parameters during build, you also need to use `-b`, `-p` parameters during export.
234+
Run `yarn export` to export the documentation as PDF files. Note that if you used `-b` or `-p` parameters during build, you need to use the same `-b` and `-p` parameters during export.
235235

236-
The export feature depends on [`playwright`](https://playwright.dev). For CI pipelines, please use `build-harbor.alauda.cn/frontend/playwright-runner:doom` as the base image for dependency installation and documentation building.
237-
238-
Locally, you can set the following environment variable to speed up downloads:
236+
The export feature depends on [`playwright`](https://playwright.dev). For CI pipelines, please use `build-harbor.alauda.cn/frontend/playwright-runner:doom` as the base image for dependency installation and documentation building. Locally, you can set the following environment variable to speed up downloads:
239237

240238
```dotenv title=".env.yarn"
241239
PLAYWRIGHT_DOWNLOAD_HOST="https://cdn.npmmirror.com/binaries/playwright"
242240
```
243241

244-
For more configuration, please refer to [Documentation Export Configuration](./usage/configuration#export)
242+
Besides exporting a unified full-site PDF, `doom` also supports exporting a single PDF file for a specified entry. For more configuration, please refer to [Documentation Export Configuration](./usage/configuration#export)
245243

246244
### Documentation Linting \{#lint}
247245

@@ -276,7 +274,7 @@ Options:
276274
export { default } from '@alauda/doom/cspell'
277275
```
278276
279-
We also conventionally use the `.cspell` folder in the current working directory (`CWD`) to store CSpell dictionary files. For example, you can create `.cspell/k8s.txt`:
277+
We also conventionally use the `.cspell` folder under the current working directory (`CWD`) to store CSpell dictionary files. For example, you can create `.cspell/k8s.txt`:
280278
281279
```txt
282280
k8s

0 commit comments

Comments
 (0)