Skip to content

Commit 1b7e361

Browse files
authored
docs(website): generate description for all documentations (#1537)
1 parent c6a8a76 commit 1b7e361

128 files changed

Lines changed: 572 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
---
2+
name: rspress-description-generator
3+
description: Generate and maintain description frontmatter for Rspress documentation files (.md/.mdx). Use when a user wants to add SEO descriptions, improve search engine snippets, generate llms.txt metadata, prepare docs for AI summarization, or batch-update frontmatter across an Rspress doc site. Also use when adding new documentation pages to an Rspress project — every new doc file needs a description.
4+
---
5+
6+
# Rspress Description Generator
7+
8+
The `description` field in Rspress frontmatter generates `<meta name="description" content="...">` tags, which are used for search engine snippets, social media previews, and AI-oriented formats like llms.txt.
9+
10+
## Step 1 — Locate the docs root
11+
12+
1. Find the Rspress config file. Search for `rspress.config.ts`, `.js`, `.mjs`, or `.cjs`. It may be at the project root or inside a subdirectory like `website/`.
13+
2. Read the config and extract the `root` option.
14+
- The value might be a plain string (`root: 'docs'`) or a JS expression (`root: path.join(__dirname, 'docs')`). In either case, determine the resolved directory path.
15+
- If `root` is set, resolve it relative to the config file's directory.
16+
- If `root` is not set, default to `docs` relative to the config file's directory.
17+
3. Confirm the directory exists. If neither `docs` nor the configured root exists, check for `doc` as a fallback.
18+
19+
## Step 2 — Detect i18n structure
20+
21+
Rspress i18n projects place language subdirectories (e.g., `en/`, `zh/`) directly under the docs root:
22+
23+
```
24+
docs/
25+
├── en/
26+
│ ├── guide/
27+
│ └── index.md
28+
└── zh/
29+
├── guide/
30+
└── index.md
31+
```
32+
33+
Check if the docs root contains language subdirectories (two-letter codes like `en`, `zh`, `ja`, `ko`, etc.). If so, process each language directory separately — the description language should match the content language.
34+
35+
If there are no language subdirectories, treat the entire docs root as a single-language site.
36+
37+
## Step 3 — Scan and process files
38+
39+
Glob for `**/*.md` and `**/*.mdx` under the docs root. Exclude:
40+
41+
- `node_modules`, build output (`doc_build`, `.rspress`, `dist`)
42+
- `_meta.json` / `_nav.json` (sidebar/nav config files, not doc pages)
43+
- `**/shared/**` directories (reusable snippets included via `@import`, not standalone pages)
44+
45+
For each file:
46+
47+
1. **Read the file.**
48+
2. **Check for existing `description` in frontmatter.** If it exists and is non-empty, skip.
49+
3. **Check `pageType` in frontmatter.** For `home` pages, derive the description from the `hero.text` / `hero.tagline` fields or the features list, not from body content.
50+
4. **Generate a description** following the writing guidelines below.
51+
5. **Insert `description` into frontmatter:**
52+
- If the file has frontmatter with a `title` field, insert `description` on the line after `title`.
53+
- If the file has frontmatter without `title`, insert `description` as the first field.
54+
- If the file has no frontmatter block, add one:
55+
56+
```yaml
57+
---
58+
description: Your generated description here
59+
---
60+
```
61+
62+
### YAML formatting
63+
64+
Most descriptions can be bare YAML strings:
65+
66+
```yaml
67+
description: Step-by-step guide to setting up your first Rspress site
68+
```
69+
70+
If the description contains colons, quotes, or other special YAML characters, wrap in double quotes:
71+
72+
```yaml
73+
description: 'API reference for Rspress configuration: plugins, themes, and build options'
74+
```
75+
76+
## Step 4 — Batch processing
77+
78+
For sites with many files, use parallel agent calls to process independent files simultaneously. Group by directory (e.g., all files in `guide/`, then all in `api/`) to maintain focus and consistency within each section.
79+
80+
After processing all files, do a quick scan to ensure no files were missed — re-glob and check for any remaining files without `description`.
81+
82+
## Description Writing Guidelines
83+
84+
The description serves three audiences: search engines (Google snippet), AI systems (llms.txt, summarization), and humans (scanning search results). A good description helps all three.
85+
86+
### Rules
87+
88+
- **Length**: 50–160 characters. Under 50 is too vague for search engines; over 160 gets truncated in snippets.
89+
- **Language**: Match the document content. Chinese docs get Chinese descriptions, English docs get English descriptions.
90+
- **Be direct**: State what the page covers. Avoid starting with "This document", "This page", "Learn about" — jump straight to the substance.
91+
- **Be specific**: Mention concrete technologies, APIs, or concepts the page covers. "Configure Rspress plugins for search, analytics, and internationalization" beats "How to use plugins."
92+
- **No markdown**: Plain text only, no formatting syntax.
93+
94+
### Examples
95+
96+
**Good:**
97+
98+
| Content | Description |
99+
| -------------------------- | ---------------------------------------------------------------------------- |
100+
| Plugin development guide | Create custom Rspress plugins using the Node.js plugin API and runtime hooks |
101+
| MDX component usage | Import and use React components in MDX documentation files |
102+
| Rspress 快速开始 | 从安装到本地预览,搭建 Rspress 文档站点的完整流程 |
103+
| 主题配置 | 自定义 Rspress 主题的导航栏、侧边栏、页脚和暗色模式 |
104+
| Home page (pageType: home) | Rspress documentation framework — fast, MDX-powered static site generator |
105+
106+
**Bad:**
107+
108+
| Description | Why |
109+
| ------------------------------------------------------- | ------------------------------------------------ |
110+
| "About plugins" | Too vague — which plugins? what about them? |
111+
| "This page explains how to configure the Rspress theme" | Wastes characters on "This page explains how to" |
112+
| "Learn everything about Rspress!" | Marketing fluff, says nothing specific |
113+
114+
## Documentation
115+
116+
- Frontmatter fields: <https://rspress.rs/api/config/config-frontmatter>
117+
- Basic config (`root` option): <https://rspress.rs/api/config/config-basic>
118+
- Full Rspress docs: <https://rspress.rs/llms.txt>

skills-lock.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"version": 1,
3+
"skills": {
4+
"rspress-description-generator": {
5+
"source": "rstackjs/agent-skills",
6+
"sourceType": "github",
7+
"computedHash": "ca2693ca055d1b4e5903bdfacab522f46ca0e13cbc5db59e6c9589fdc8efc6ad"
8+
}
9+
}
10+
}

website/docs/en/api/javascript-api/core.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
---
2+
description: 'Use Rslib core APIs such as createRslib, loadConfig, defineConfig, and environment loading in JavaScript workflows.'
3+
---
4+
15
# Rslib core
26

37
This chapter introduces some of the core methods provided by Rslib.

website/docs/en/api/javascript-api/instance.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
---
2+
description: 'Use the Rslib instance API for builds, Module Federation dev servers, config inspection, and lifecycle control.'
3+
---
4+
15
# Rslib instance
26

37
This section describes all the properties and methods on the Rslib instance object.

website/docs/en/api/javascript-api/types.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
---
2+
description: 'Reference the TypeScript types exported by Rslib for configs, APIs, instance methods, plugins, and Rsbuild or Rspack types.'
3+
---
4+
15
# Rslib types
26

37
This section describes some of the type definitions provided by the Rslib.

website/docs/en/api/start/index.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
---
2+
description: 'Get started with the Rslib JavaScript API in Node.js, Deno, or Bun using createRslib and instance methods.'
3+
---
4+
15
# JavaScript API
26

37
Rslib provides a comprehensive JavaScript API for developers to directly use Rslib's capabilities in JavaScript or TypeScript code.

website/docs/en/blog/index.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
title: Overview
3+
description: 'Browse Rslib release announcements, project updates, and articles about library development with Rspack and Rsbuild.'
34
sidebar: false
45
---
56

website/docs/en/blog/introducing-rslib.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
---
2+
description: 'Learn why Rslib was built on Rspack and Rsbuild, and how it delivers multiple output formats, ecosystem reuse, and performance.'
23
date: 2025-05-14 10:00:00
34
sidebar: false
45
---

website/docs/en/config/index.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
---
2+
description: 'Browse the Rslib configuration overview, including lib options, inherited Rsbuild settings, and links to every reference page.'
23
pageType: doc-wide
34
outline: false
45
---

website/docs/en/config/lib/auto-extension.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
---
2+
description: 'Configure lib.autoExtension to derive output file extensions from the selected library format and output mode.'
3+
---
4+
15
# lib.autoExtension
26

37
- **Type:** `boolean`

0 commit comments

Comments
 (0)