|
| 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> |
0 commit comments