Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/smart-rivers-smash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@alauda/doom": minor
---

feat: add llms and sitemap support
2 changes: 1 addition & 1 deletion .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
# copy the pdf to the tempdir
cp -r ./dist/*.pdf $tempdir
# then build the docs with pdf download link
yarn docs:build -a -d -R
yarn docs:build -a -d -R -S
# copy the pdf back to the dist folder
cp -r $tempdir/*.pdf ./dist
# remove the tempdir
Expand Down
3 changes: 2 additions & 1 deletion docs/en/start.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sourceSHA: 946151a530ef59d66a096d2509b68a25f5a7951ba51158cff08ae746756b9f10
sourceSHA: e31a32d16aad2cdb01d351735f58941fd13ae5e5ec7ca53922a524c102850d8f
---

# Start \{#start}
Expand Down Expand Up @@ -102,6 +102,7 @@ Options:
-r, --redirect <enum> Whether to redirect to the locale closest to `navigator.language` when the user visits the site, could be `auto`, `never` or `only-default-lang` (default: "only-default-lang")
-R, --edit-repo [boolean|url] Whether to enable or override the `editRepoBaseUrl` config feature, `https://github.com/` prefix could be omitted (default: false)
-a, --algolia Whether to enable Algolia search (default: false)
-S, --site-url Whether to enable the siteUrl for sitemap generation (default: false)
-n, --no-open [boolean] Do not open the browser after starting the server
-h, --help display help for command

Expand Down
12 changes: 10 additions & 2 deletions docs/en/usage/configuration.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
description: Configure `doom` documentation tool
weight: 1
sourceSHA: 99d5505366bd7c2a066dd673ddb80b0c0b17420a9ad29f8a71b6cb7f66b495f3
sourceSHA: c2b69e517f964f8b758654e4b634cfa2dd2089227f8b83c13cb3673e0dcbc400
---

# Configuration {#configuration}
Expand Down Expand Up @@ -210,7 +210,7 @@ The final output should only include the results from the last step, and previou
<%= userPrompt %>

<%= additionalPrompts %>
userPrompt: # optional, used to fill in the global parameters of the `ejs` template in `systemPrompt`.
userPrompt: # optional, used to fill in the global parameters of the `ejs` template in `systemPrompt`
```

## Edit Documentation in Code Repository {#edit-repo}
Expand All @@ -234,3 +234,11 @@ algolia:
apiKey: # Algolia API Key
indexName: # Algolia index name
```

Please use `public/robots.txt` for Algolia Crawler Verification.

## Sitemap Configuration {#sitemap}

```yaml
siteUrl: https://docs.alauda.cn # Optional, site URL used for generating sitemap, only effective when the `-S, --site-url` command line flag is enabled.
```
1 change: 1 addition & 0 deletions docs/zh/start.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ Options:
-r, --redirect <enum> Whether to redirect to the locale closest to `navigator.language` when the user visits the site, could be `auto`, `never` or `only-default-lang` (default: "only-default-lang")
-R, --edit-repo [boolean|url] Whether to enable or override the `editRepoBaseUrl` config feature, `https://github.com/` prefix could be omitted (default: false)
-a, --algolia Whether to enable Algolia search (default: false)
-S, --site-url Whether to enable the siteUrl for sitemap generation (default: false)
-n, --no-open [boolean] Do not open the browser after starting the server
-h, --help display help for command

Expand Down
42 changes: 25 additions & 17 deletions docs/zh/usage/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ description: 配置 `doom` 文档工具
weight: 1
---

# 配置 \{#configuration}
# 配置 {#configuration}

## 配置文件 \{#config-file}
## 配置文件 {#config-file}

大部分情况下,我们只需要使用静态 `yaml` 配置文件即可,支持 `doom.config.yaml` 或 `doom.config.yml`,对于复杂场景,比如需要动态配置或自定义 `rspress` 插件时,可以使用 `js/ts` 配置文件,支持 `.js/.ts/.mjs/.mts/.cjs/.cts` 多种文件格式。

Expand All @@ -17,7 +17,7 @@ import { defineConfig } from '@alauda/doom/config'
export default defineConfig({})
```

## 基础配置 \{#basic}
## 基础配置 {#basic}

- `lang`:默认文档语言,为方便大部分项目使用,我们默认支持中英文文档,默认语言为 `en`,如果当前文档项目不需要多语言支持,可以将此项配置为 `null` 或 `undefined`
- `title`:文档标题,会显示在浏览器标签页上
Expand All @@ -27,7 +27,7 @@ export default defineConfig({})
- `base`:文档基础路径,用于部署到非根路径,如 `product-docs`,默认为 `/`
- `outDir`:构建产物目录,默认为 `dist/{base}/{version}`,如果指定此项,则变更为 `dist/{outDir}/{version}`,其中 `version` 可选,参考[多版本构建](./deploy#多版本构建)

## API 文档配置 \{#api}
## API 文档配置 {#api}

```yaml
api:
Expand All @@ -47,7 +47,7 @@ api:

文档编写参考 [API 文档](./api)

## 权限说明文档配置 \{#permission}
## 权限说明文档配置 {#permission}

```yaml
# 以下资源文件路径,相对于 doom.config.* 所在目录,支持 glob 匹配,json/yaml 文件
Expand All @@ -62,7 +62,7 @@ permission:

文档编写参考[权限说明文档](./permission)

## 引用文档配置 \{#reference}
## 引用文档配置 {#reference}

```yaml
reference:
Expand All @@ -88,7 +88,7 @@ reference:

文档编写参考[引用文档](./reference#reference)

## 发行说明配置 \{#release-notes}
## 发行说明配置 {#release-notes}

```yaml
releaseNotes:
Expand All @@ -107,21 +107,21 @@ releaseNotes:

以上述 `template=fixed&project=DevOps` 为例,`fixed` 为 `queryTemplates` 中定义的模板名称,剩余的 `query` 参数 `project=DevOps` 将作为 [`ejs`](https://github.com/mde/ejs) 模板参数传递给 `fixed` 模板处理后作为 jira [`jql`](https://www.atlassian.com/zh/software/jira/guides/jql/overview#what-is-jql) 发起 `https://jira.alauda.cn/rest/api/2/search?jql=<jql>` 请求,此 API 要求鉴权,须提供 `JIRA_USERNAME` 和 `JIRA_PASSWORD` 环境变量才能预览生效

## 左导航配置 \{#sidebar}
## 左导航配置 {#sidebar}

```yaml
sidebar:
collapsed: false # 可选,是否默认折叠左导航,默认折叠,文档内容不多时可以考虑设置为 false
```

## 内部文档路由配置 \{#internal-routes}
## 内部文档路由配置 {#internal-routes}

```yaml
internalRoutes: # 可选,支持 glob 匹配,相对于 docs 目录,在 cli 启用 `-i, --ignore` 选项时匹配到的路由/文件会被忽略
- '*/internal/**'
```

## 仅包含文档路由配置 \{#only-include-routes}
## 仅包含文档路由配置 {#only-include-routes}

```yaml
onlyIncludeRoutes: # 可选,支持 glob 匹配,相对于 docs 目录,在 cli 启用 `-i, --ignore` 选项时只有此配置下的路由/文件会被启用,可同时配合 `internalRoutes` 进一步排除其中的部分路由
Expand All @@ -130,7 +130,7 @@ internalRoutes:
- '*/internal/overview.mdx'
```

## 语言高亮插件配置 \{#highlight}
## 语言高亮插件配置 {#highlight}

```yaml
shiki:
Expand All @@ -143,7 +143,7 @@ shiki:
未配置的语言将在命令行提示告警,并回退到 `plaintext` 渲染
:::

## `sites.yaml` 配置 \{#sites}
## `sites.yaml` 配置 {#sites}

`sites.yaml` 配置文件用于配置当前文档站点关联的子站点信息,[引用外部站点组件](./mdx#externalsite)和构建单版本文档时会用到此处定义的信息。

Expand All @@ -162,7 +162,7 @@ shiki:
image: devops/connectors-docs # 站点构建镜像,用于构建全站点时拉取镜像
```

## 翻译配置 \{#translate}
## 翻译配置 {#translate}

```yaml
translate:
Expand Down Expand Up @@ -212,24 +212,32 @@ translate:
userPrompt: # 可选,用于填充到 `systemPrompt` 中的 `ejs` 模板全局参数
```

## 在代码仓库编辑文档 \{#edit-repo}
## 在代码仓库编辑文档 {#edit-repo}

```yaml
editRepoBaseUrl: alauda/doom/tree/main/docs # https://github.com/ 前缀可以省略,仅当启用 `-R, --edit-repo` 命令行标志符时生效
```

## 文档检查配置 \{#lint}
## 文档检查配置 {#lint}

```yaml
lint:
cspellOptions: # 可选,cspell 配置项,参考 https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell-eslint-plugin#options
```

## Algolia 搜索配置 \{#algolia}
## Algolia 搜索配置 {#algolia}

```yaml
algolia:
algolia: # 可选,Algolia 搜索配置,仅当启用 `-a, --algolia` 命令行标志符时生效
appId: # Algolia 应用 ID
apiKey: # Algolia API Key
indexName: # Algolia 索引名称
```

请使用 `public/robots.txt` 进行 Algolia 爬虫验证

## Sitemap 配置 {#sitemap}

```yaml
siteUrl: https://docs.alauda.cn # 可选,站点 URL,用于生成 sitemap,仅当启用 `-S, --site-url` 命令行标志符时生效
```
1 change: 1 addition & 0 deletions doom.config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ algolia:
appId: USO7A9NBAD
apiKey: 44896d7bbb41e9c1e807699d1dbb7cee
indexName: doom_js_org_uso7a9nbad_pages
siteUrl: https://doom.js.org
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,12 @@
"@rsbuild/plugin-yaml": "^1.0.2",
"@rspress/core": "2.0.0-beta.8",
"@rspress/plugin-algolia": "2.0.0-beta.8",
"@rspress/plugin-llms": "^2.0.0-beta.8",
"@shikijs/transformers": "^3.4.2",
"chokidar": "^4.0.3",
"cli-progress": "^3.12.0",
"clsx": "^2.1.1",
"commander": "^14.0.0",
"commander": "^13.1.0",
"ejs": "^3.1.10",
"es-toolkit": "^1.38.0",
"eslint": "^9.27.0",
Expand Down Expand Up @@ -112,7 +113,7 @@
"@total-typescript/ts-reset": "^0.6.1",
"@types/cli-progress": "^3.11.6",
"@types/ejs": "^3.1.5",
"@types/node": "^22.15.23",
"@types/node": "^22.15.24",
"@types/picomatch": "^4.0.0",
"@types/react": "^19.1.6",
"@types/react-dom": "^19.1.5",
Expand Down
6 changes: 6 additions & 0 deletions src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ program
parseBoolean,
false,
)
.option(
'-S, --site-url',
'Whether to enable the siteUrl for sitemap generation',
parseBoolean,
false,
)
.option(
'-n, --no-open [boolean]',
'Do not open the browser after starting the server',
Expand Down
23 changes: 20 additions & 3 deletions src/cli/load-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {
type LocaleConfig,
type UserConfig,
} from '@rspress/core'
import { pluginAlgolia } from '@rspress/plugin-algolia'
import { pluginLlms } from '@rspress/plugin-llms'
import { logger } from '@rspress/shared/logger'
import {
transformerMetaHighlight,
Expand All @@ -27,17 +29,18 @@ import { difference } from 'es-toolkit'
import rehypeRaw from 'rehype-raw'
import { cyan } from 'yoctocolors'

import { autoTocPlugin } from '../plugins/auto-toc/index.js'
import {
apiPlugin,
autoSidebarPlugin,
autoTocPlugin,
createTransformerCallouts,
directivesPlugin,
globalPlugin,
mermaidPlugin,
permissionPlugin,
rehypeFix,
replacePlugin,
sitemapPlugin,
} from '../plugins/index.js'
import {
isExplicitlyUnversioned,
Expand Down Expand Up @@ -115,6 +118,7 @@ const getCommonConfig = async ({
redirect,
editRepo,
algolia,
siteUrl,
}: {
config: UserConfig
configFilePath?: string
Expand All @@ -132,6 +136,7 @@ const getCommonConfig = async ({
redirect?: 'auto' | 'never' | 'only-default-lang'
editRepo?: boolean | string
algolia?: boolean
siteUrl?: boolean
}): Promise<UserConfig> => {
const fallbackToZh = 'lang' in config && !config.lang
root = resolveDocRoot(CWD, root, config.root)
Expand Down Expand Up @@ -207,6 +212,8 @@ const getCommonConfig = async ({

const { editLink, ...zhLocale } = KNOWN_LOCALE_CONFIGS.zh!

const algoliaOptions = algolia ? config.algolia : undefined

return {
userBase,
root,
Expand Down Expand Up @@ -261,6 +268,9 @@ const getCommonConfig = async ({
: { locales }),
},
plugins: [
algoliaOptions && pluginAlgolia(),
pluginLlms(),

apiPlugin({
localBasePath,
}),
Expand All @@ -277,7 +287,13 @@ const getCommonConfig = async ({
localBasePath,
force,
}),
],
siteUrl &&
config.siteUrl &&
sitemapPlugin({
domain: config.siteUrl,
}),
].filter(Boolean),
search: algoliaOptions ? false : undefined,
builderConfig: {
dev: {
lazyCompilation: lazy,
Expand All @@ -288,7 +304,6 @@ const getCommonConfig = async ({
},
tools: {
rspack(rspackConfig, { mergeConfig, rspack }) {
const algoliaOptions = algolia ? config.algolia : undefined
return mergeConfig(rspackConfig, {
resolve: {
extensionAlias: {
Expand Down Expand Up @@ -342,6 +357,7 @@ export async function loadConfig(
redirect,
editRepo,
algolia,
siteUrl,
}: GlobalCliOptions = {},
): Promise<{
config: UserConfig
Expand Down Expand Up @@ -422,6 +438,7 @@ export async function loadConfig(
redirect,
editRepo,
algolia,
siteUrl,
})

base = commonConfig.base!
Expand Down
2 changes: 1 addition & 1 deletion src/cli/translate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export const translate = async ({
},
],
model: 'gpt-4o-mini',
temperature: 0.1,
temperature: 0.2,
})

const { content, refusal } = choices[0].message
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
export * from './api/index.js'
export * from './auto-sidebar/index.js'
export * from './auto-toc/index.js'
export * from './directives/index.js'
export * from './global/index.js'
export * from './mermaid/index.js'
export * from './permission/index.js'
export * from './replace/index.js'
export * from './shiki/index.js'
export * from './sitemap/index.js'
Loading