diff --git a/docs.json b/docs.json index 207f6d7..b20ffdb 100644 --- a/docs.json +++ b/docs.json @@ -191,6 +191,97 @@ ] } ] + }, + { + "language": "cn", + "tabs": [ + { + "tab": "指南", + "groups": [ + { + "group": "入门", + "pages": [ + "docs/cn/index", + "docs/cn/quickstart", + "docs/cn/development" + ] + }, + { + "group": "自定义", + "pages": [ + "docs/cn/essentials/settings", + "docs/cn/essentials/navigation" + ] + }, + { + "group": "编写内容", + "pages": [ + "docs/cn/essentials/markdown", + "docs/cn/essentials/code", + "docs/cn/essentials/images", + "docs/cn/essentials/reusable-snippets" + ] + }, + { + "group": "AI 工具", + "pages": [ + "docs/cn/ai-tools/cursor", + "docs/cn/ai-tools/claude-code", + "docs/cn/ai-tools/windsurf" + ] + }, + { + "group": "实施练习", + "pages": [ + "docs/cn/implementation-exercises/signed-webhooks", + "docs/cn/implementation-exercises/async-export-jobs", + "docs/cn/implementation-exercises/team-feature-flags" + ] + } + ] + }, + { + "tab": "API 参考", + "groups": [ + { + "group": "API 文档", + "pages": [ + "docs/cn/api-reference/introduction" + ] + }, + { + "group": "OpenAPI 参考测试", + "pages": [ + "docs/cn/api-reference/openapi-test/index", + "docs/cn/api-reference/openapi-test/relative", + "docs/cn/api-reference/openapi-test/absolute", + "docs/cn/api-reference/openapi-test/same-dir", + "docs/cn/api-reference/openapi-test/remote" + ] + }, + { + "group": "端点示例", + "pages": [ + "docs/cn/api-reference/endpoint/get", + "docs/cn/api-reference/endpoint/create", + "docs/cn/api-reference/endpoint/delete", + "docs/cn/api-reference/endpoint/webhook", + "docs/cn/api-reference/endpoint/search", + "docs/cn/api-reference/endpoint/change-location", + "docs/cn/api-reference/endpoint/hierarchy", + "docs/cn/api-reference/endpoint/get-asset-proof", + "docs/cn/api-reference/endpoint/get-pots" + ] + }, + { + "group": "AsyncAPI 文档", + "asyncapi": { + "source": "docs/api-reference/asyncapi.json" + } + } + ] + } + ] } ], "global": { diff --git a/docs/cn/ai-tools/claude-code.mdx b/docs/cn/ai-tools/claude-code.mdx new file mode 100644 index 0000000..7a76b52 --- /dev/null +++ b/docs/cn/ai-tools/claude-code.mdx @@ -0,0 +1,76 @@ +--- +title: "Claude Code 设置" +description: "为您的文档工作流程配置 Claude Code" +icon: "asterisk" +--- + +Claude Code 是 Anthropic 官方的 CLI 工具。本指南将帮助您设置 Claude Code 以帮助您编写和维护文档。 + +## 前置条件 + +- 有效的 Claude 订阅(Pro、Max 或 API 访问权限) + +## 设置 + +1. 全局安装 Claude Code: + + ```bash + npm install -g @anthropic-ai/claude-code +``` + +2. 进入您的文档目录。 +3. (可选)将下面的 `CLAUDE.md` 文件添加到您的项目中。 +4. 运行 `claude` 启动。 + +## 创建 `CLAUDE.md` + +在您的文档仓库根目录中创建一个 `CLAUDE.md` 文件,以训练 Claude Code 遵循您特定的文档标准: + +````markdown +# Mintlify documentation + +## Working relationship +- You can push back on ideas-this can lead to better documentation. Cite sources and explain your reasoning when you do so +- ALWAYS ask for clarification rather than making assumptions +- NEVER lie, guess, or make up information + +## Project context +- Format: MDX files with YAML frontmatter +- Config: docs.json for navigation, theme, settings +- Components: Mintlify components + +## Content strategy +- Document just enough for user success - not too much, not too little +- Prioritize accuracy and usability of information +- Make content evergreen when possible +- Search for existing information before adding new content. Avoid duplication unless it is done for a strategic reason +- Check existing patterns for consistency +- Start by making the smallest reasonable changes + +## Frontmatter requirements for pages +- title: Clear, descriptive page title +- description: Concise summary for SEO/navigation + +## Writing standards +- Second-person voice ("you") +- Prerequisites at start of procedural content +- Test all code examples before publishing +- Match style and formatting of existing pages +- Include both basic and advanced use cases +- Language tags on all code blocks +- Alt text on all images +- Relative paths for internal links + +## Git workflow +- NEVER use --no-verify when committing +- Ask how to handle uncommitted changes before starting +- Create a new branch when no clear branch exists for changes +- Commit frequently throughout development +- NEVER skip or disable pre-commit hooks + +## Do not +- Skip frontmatter on any MDX file +- Use absolute URLs for internal links +- Include untested code examples +- Make assumptions - always ask for clarification +```` diff --git a/docs/cn/ai-tools/cursor.mdx b/docs/cn/ai-tools/cursor.mdx new file mode 100644 index 0000000..2897455 --- /dev/null +++ b/docs/cn/ai-tools/cursor.mdx @@ -0,0 +1,420 @@ +--- +title: "Cursor 设置" +description: "为您的文档工作流程配置 Cursor" +icon: "arrow-pointer" +--- + +使用 Cursor 来帮助编写和维护您的文档。本指南展示了如何配置 Cursor,以在技术写作任务和使用 Mintlify 组件时获得更好的结果。 + +## 前置条件 + +- 已安装 Cursor 编辑器 +- 可访问您的文档仓库 + +## 项目规则 + +创建所有团队成员都可以使用的项目规则。在您的文档仓库根目录中: + +```bash +mkdir -p .cursor +``` + +创建 `.cursor/rules.md`: + +````markdown +# Mintlify technical writing rule + +You are an AI writing assistant specialized in creating exceptional technical documentation using Mintlify components and following industry-leading technical writing practices. + +## Core writing principles + +### Language and style requirements + +- Use clear, direct language appropriate for technical audiences +- Write in second person ("you") for instructions and procedures +- Use active voice over passive voice +- Employ present tense for current states, future tense for outcomes +- Avoid jargon unless necessary and define terms when first used +- Maintain consistent terminology throughout all documentation +- Keep sentences concise while providing necessary context +- Use parallel structure in lists, headings, and procedures + +### Content organization standards + +- Lead with the most important information (inverted pyramid structure) +- Use progressive disclosure: basic concepts before advanced ones +- Break complex procedures into numbered steps +- Include prerequisites and context before instructions +- Provide expected outcomes for each major step +- Use descriptive, keyword-rich headings for navigation and SEO +- Group related information logically with clear section breaks + +### User-centered approach + +- Focus on user goals and outcomes rather than system features +- Anticipate common questions and address them proactively +- Include troubleshooting for likely failure points +- Write for scannability with clear headings, lists, and white space +- Include verification steps to confirm success + +## Mintlify component reference + +### Callout components + +#### Note - Additional helpful information + + +Supplementary information that supports the main content without interrupting flow + + +#### Tip - Best practices and pro tips + + +Expert advice, shortcuts, or best practices that enhance user success + + +#### Warning - Important cautions + + +Critical information about potential issues, breaking changes, or destructive actions + + +#### Info - Neutral contextual information + + +Background information, context, or neutral announcements + + +#### Check - Success confirmations + + +Positive confirmations, successful completions, or achievement indicators + + +### Code components + +#### Single code block + +Example of a single code block: + +```javascript config.js +const apiConfig = { + baseURL: 'https://api.example.com', + timeout: 5000, + headers: { + 'Authorization': `Bearer ${process.env.API_TOKEN}` + } +}; +``` + +#### Code group with multiple languages + +Example of a code group: + + +```javascript Node.js +const response = await fetch('/api/endpoint', { + headers: { Authorization: `Bearer ${apiKey}` } +}); +``` + +```python Python +import requests +response = requests.get('/api/endpoint', + headers={'Authorization': f'Bearer {api_key}'}) +``` + +```curl cURL +curl -X GET '/api/endpoint' \ + -H 'Authorization: Bearer YOUR_API_KEY' +``` + + +#### Request/response examples + +Example of request/response documentation: + + +```bash cURL +curl -X POST 'https://api.example.com/users' \ + -H 'Content-Type: application/json' \ + -d '{"name": "John Doe", "email": "john@example.com"}' +``` + + + +```json Success +{ + "id": "user_123", + "name": "John Doe", + "email": "john@example.com", + "created_at": "2024-01-15T10:30:00Z" +} +``` + + +### Structural components + +#### Steps for procedures + +Example of step-by-step instructions: + + + + Run `npm install` to install required packages. + + + Verify installation by running `npm list`. + + + + + Create a `.env` file with your API credentials. + + ```bash + API_KEY=your_api_key_here + ``` + + + Never commit API keys to version control. + + + + +#### Tabs for alternative content + +Example of tabbed content: + + + + ```bash + brew install node + npm install -g package-name + ``` + + + + ```powershell + choco install nodejs + npm install -g package-name + ``` + + + + ```bash + sudo apt install nodejs npm + npm install -g package-name + ``` + + + +#### Accordions for collapsible content + +Example of accordion groups: + + + + - **Firewall blocking**: Ensure ports 80 and 443 are open + - **Proxy configuration**: Set HTTP_PROXY environment variable + - **DNS resolution**: Try using 8.8.8.8 as DNS server + + + + ```javascript + const config = { + performance: { cache: true, timeout: 30000 }, + security: { encryption: 'AES-256' } + }; + ``` + + + +### Cards and columns for emphasizing information + +Example of cards and card groups: + + +Complete walkthrough from installation to your first API call in under 10 minutes. + + + + + Learn how to authenticate requests using API keys or JWT tokens. + + + + Understand rate limits and best practices for high-volume usage. + + + +### API documentation components + +#### Parameter fields + +Example of parameter documentation: + + +Unique identifier for the user. Must be a valid UUID v4 format. + + + +User's email address. Must be valid and unique within the system. + + + +Maximum number of results to return. Range: 1-100. + + + +Bearer token for API authentication. Format: `Bearer YOUR_API_KEY` + + +#### Response fields + +Example of response field documentation: + + +Unique identifier assigned to the newly created user. + + + +ISO 8601 formatted timestamp of when the user was created. + + + +List of permission strings assigned to this user. + + +#### Expandable nested fields + +Example of nested field documentation: + + +Complete user object with all associated data. + + + + User profile information including personal details. + + + + User's first name as entered during registration. + + + + URL to user's profile picture. Returns null if no avatar is set. + + + + + + +### Media and advanced components + +#### Frames for images + +Wrap all images in frames: + + +Main dashboard showing analytics overview + + + +Analytics dashboard with charts + + +#### Videos + +Use the HTML video element for self-hosted video content: + + + +Embed YouTube videos using iframe elements: + + + +#### Tooltips + +Example of tooltip usage: + + +API + + +#### Updates + +Use updates for changelogs: + + +## New features +- Added bulk user import functionality +- Improved error messages with actionable suggestions + +## Bug fixes +- Fixed pagination issue with large datasets +- Resolved authentication timeout problems + + +## Required page structure + +Every documentation page must begin with YAML frontmatter: + +```yaml +--- +title: "Clear, specific, keyword-rich title" +description: "Concise description explaining page purpose and value" +--- +``` + +## Content quality standards + +### Code examples requirements + +- Always include complete, runnable examples that users can copy and execute +- Show proper error handling and edge case management +- Use realistic data instead of placeholder values +- Include expected outputs and results for verification +- Test all code examples thoroughly before publishing +- Specify language and include filename when relevant +- Add explanatory comments for complex logic +- Never include real API keys or secrets in code examples + +### API documentation requirements + +- Document all parameters including optional ones with clear descriptions +- Show both success and error response examples with realistic data +- Include rate limiting information with specific limits +- Provide authentication examples showing proper format +- Explain all HTTP status codes and error handling +- Cover complete request/response cycles + +### Accessibility requirements + +- Include descriptive alt text for all images and diagrams +- Use specific, actionable link text instead of "click here" +- Ensure proper heading hierarchy starting with H2 +- Provide keyboard navigation considerations +- Use sufficient color contrast in examples and visuals +- Structure content for easy scanning with headers and lists + +## Component selection logic + +- Use **Steps** for procedures and sequential instructions +- Use **Tabs** for platform-specific content or alternative approaches +- Use **CodeGroup** when showing the same concept in multiple programming languages +- Use **Accordions** for progressive disclosure of information +- Use **RequestExample/ResponseExample** specifically for API endpoint documentation +- Use **ParamField** for API parameters, **ResponseField** for API responses +- Use **Expandable** for nested object properties or hierarchical information +```` diff --git a/docs/cn/ai-tools/windsurf.mdx b/docs/cn/ai-tools/windsurf.mdx new file mode 100644 index 0000000..6701fb0 --- /dev/null +++ b/docs/cn/ai-tools/windsurf.mdx @@ -0,0 +1,96 @@ +--- +title: "Windsurf 设置" +description: "为您的文档工作流程配置 Windsurf" +icon: "water" +--- + +配置 Windsurf 的 Cascade AI 助手,以帮助您编写和维护文档。本指南展示了如何专门为您的 Mintlify 文档工作流程设置 Windsurf。 + +## 前置条件 + +- 已安装 Windsurf 编辑器 +- 可访问您的文档仓库 + +## 工作区规则 + +创建工作区规则,为 Windsurf 提供有关您文档项目和标准的上下文。 + +在项目根目录中创建 `.windsurf/rules.md`: + +````markdown +# Mintlify technical writing rule + +## Project context + +- This is a documentation project on the Mintlify platform +- We use MDX files with YAML frontmatter +- Navigation is configured in `docs.json` +- We follow technical writing best practices + +## Writing standards + +- Use second person ("you") for instructions +- Write in active voice and present tense +- Start procedures with prerequisites +- Include expected outcomes for major steps +- Use descriptive, keyword-rich headings +- Keep sentences concise but informative + +## Required page structure + +Every page must start with frontmatter: + +```yaml +--- +title: "Clear, specific title" +description: "Concise description for SEO and navigation" +--- +``` + +## Mintlify components + +### Callouts + +- `` for helpful supplementary information +- `` for important cautions and breaking changes +- `` for best practices and expert advice +- `` for neutral contextual information +- `` for success confirmations + +### Code examples + +- When appropriate, include complete, runnable examples +- Use `` for multiple language examples +- Specify language tags on all code blocks +- Include realistic data, not placeholders +- Use `` and `` for API docs + +### Procedures + +- Use `` component for sequential instructions +- Include verification steps with `` components when relevant +- Break complex procedures into smaller steps + +### Content organization + +- Use `` for platform-specific content +- Use `` for progressive disclosure +- Use `` and `` for highlighting content +- Wrap images in `` components with descriptive alt text + +## API documentation requirements + +- Document all parameters with `` +- Show response structure with `` +- Include both success and error examples +- Use `` for nested object properties +- Always include authentication examples + +## Quality standards + +- Test all code examples before publishing +- Use relative paths for internal links +- Include alt text for all images +- Ensure proper heading hierarchy (start with h2) +- Check existing patterns for consistency +```` diff --git a/docs/cn/api-reference/async-api/lighting-measured.mdx b/docs/cn/api-reference/async-api/lighting-measured.mdx new file mode 100644 index 0000000..0a26888 --- /dev/null +++ b/docs/cn/api-reference/async-api/lighting-measured.mdx @@ -0,0 +1,4 @@ +--- +title: '光照测量' +asyncapi: 'api-reference/asyncapi.json lightingMeasured' +--- diff --git a/docs/cn/api-reference/endpoint/change-location.mdx b/docs/cn/api-reference/endpoint/change-location.mdx new file mode 100644 index 0000000..8e53301 --- /dev/null +++ b/docs/cn/api-reference/endpoint/change-location.mdx @@ -0,0 +1,4 @@ +--- +title: '更改位置' +openapi: 'PUT /plants/{id}/location' +--- \ No newline at end of file diff --git a/docs/cn/api-reference/endpoint/create-bulk.mdx b/docs/cn/api-reference/endpoint/create-bulk.mdx new file mode 100644 index 0000000..40c3a4c --- /dev/null +++ b/docs/cn/api-reference/endpoint/create-bulk.mdx @@ -0,0 +1,6 @@ +--- +title: '批量创建植物' +openapi: 'POST /plants/bulk' +--- + +这是批量创建端点的一些自定义 Markdown 内容。 diff --git a/docs/cn/api-reference/endpoint/create.mdx b/docs/cn/api-reference/endpoint/create.mdx new file mode 100644 index 0000000..b6db3b2 --- /dev/null +++ b/docs/cn/api-reference/endpoint/create.mdx @@ -0,0 +1,8 @@ +--- +title: '创建植物' +openapi: 'openapi/openapi.json POST /plants' +de_link: "https://developers.example.de/docs/api-reference/endpoint/create" +fr_link: "https://developers.example.fr/docs/api-reference/endpoint/create" +--- + +这是创建端点的一些自定义 Markdown 内容。 diff --git a/docs/cn/api-reference/endpoint/delete.mdx b/docs/cn/api-reference/endpoint/delete.mdx new file mode 100644 index 0000000..eeb7947 --- /dev/null +++ b/docs/cn/api-reference/endpoint/delete.mdx @@ -0,0 +1,4 @@ +--- +title: '删除植物' +openapi: 'DELETE /plants/{id}' +--- diff --git a/docs/cn/api-reference/endpoint/get-asset-proof.mdx b/docs/cn/api-reference/endpoint/get-asset-proof.mdx new file mode 100644 index 0000000..4b05f79 --- /dev/null +++ b/docs/cn/api-reference/endpoint/get-asset-proof.mdx @@ -0,0 +1,5 @@ +--- +title: "获取资产证明" +openapi: "POST /getAssetProof" +description: "检索压缩 Solana NFT 或代币的加密 Merkle 证明。" +--- \ No newline at end of file diff --git a/docs/cn/api-reference/endpoint/get-pots.mdx b/docs/cn/api-reference/endpoint/get-pots.mdx new file mode 100644 index 0000000..7c9109f --- /dev/null +++ b/docs/cn/api-reference/endpoint/get-pots.mdx @@ -0,0 +1,4 @@ +--- +title: 获取花盆列表 +openapi: "GET /pots" +--- \ No newline at end of file diff --git a/docs/cn/api-reference/endpoint/get.mdx b/docs/cn/api-reference/endpoint/get.mdx new file mode 100644 index 0000000..4797ac6 --- /dev/null +++ b/docs/cn/api-reference/endpoint/get.mdx @@ -0,0 +1,7 @@ +--- +title: '获取植物列表' +openapi: 'GET /plants' +de_link: "https://developers.example.de/docs/api-reference/endpoint/get" +fr_link: "https://developers.example.fr/docs/api-reference/endpoint/get" +es_link: "https://developers.example.es/docs/api-reference/endpoint/get" +--- diff --git a/docs/cn/api-reference/endpoint/hierarchy.mdx b/docs/cn/api-reference/endpoint/hierarchy.mdx new file mode 100644 index 0000000..9916b35 --- /dev/null +++ b/docs/cn/api-reference/endpoint/hierarchy.mdx @@ -0,0 +1,5 @@ +--- +title: "获取植物层级结构" +openapi: "GET /plants/{id}/hierarchy" +description: "获取展示父子关系的植物层级结构" +--- \ No newline at end of file diff --git a/docs/cn/api-reference/endpoint/search.mdx b/docs/cn/api-reference/endpoint/search.mdx new file mode 100644 index 0000000..83939fb --- /dev/null +++ b/docs/cn/api-reference/endpoint/search.mdx @@ -0,0 +1,4 @@ +--- +title: '搜索植物' +openapi: 'POST /plants/search' +--- diff --git a/docs/cn/api-reference/endpoint/webhook.mdx b/docs/cn/api-reference/endpoint/webhook.mdx new file mode 100644 index 0000000..b5f2434 --- /dev/null +++ b/docs/cn/api-reference/endpoint/webhook.mdx @@ -0,0 +1,6 @@ +--- +title: '新植物' +openapi: 'WEBHOOK /plant/webhook' +--- + +这是 webhook 端点的一些自定义 Markdown 内容。 diff --git a/docs/cn/api-reference/introduction.mdx b/docs/cn/api-reference/introduction.mdx new file mode 100644 index 0000000..c65c724 --- /dev/null +++ b/docs/cn/api-reference/introduction.mdx @@ -0,0 +1,35 @@ +--- +title: '简介 (Reed Docs)' +description: '用于展示 API 端点的示例章节' +de_link: "https://developers.example.de/docs/api-reference/introduction" +fr_link: "https://developers.example.fr/docs/api-reference/introduction" +es_link: "https://developers.example.es/docs/api-reference/introduction" +--- + + + 如果您不打算构建 API 参考文档,可以通过删除 api-reference 文件夹来移除此章节。 + + +## 欢迎 + +构建 API 文档有两种方式:[OpenAPI](https://mintlify.com/docs/api-playground/openapi/setup) 和 [MDX 组件](https://mintlify.com/docs/api-playground/mdx/configuration)。对于此初学者套件,我们使用以下 OpenAPI 规范。 + + + 查看 OpenAPI 规范文件 + + +## 身份验证 + +所有 API 端点都使用 Bearer 令牌进行身份验证,并从规范文件中读取。 + +```json +"security": [ + { + "bearerAuth": [] + } +] +``` diff --git a/docs/cn/api-reference/openapi-test/absolute.mdx b/docs/cn/api-reference/openapi-test/absolute.mdx new file mode 100644 index 0000000..f52fa5e --- /dev/null +++ b/docs/cn/api-reference/openapi-test/absolute.mdx @@ -0,0 +1,7 @@ +--- +title: '绝对路径引用' +description: '使用从仓库根目录开始的绝对路径引用规范' +openapi: '/openapi/openapi-example.json GET /users' +--- + +引用 `/openapi/openapi-example.json` —— 从仓库根目录开始的绝对路径(带前导斜杠)。 diff --git a/docs/cn/api-reference/openapi-test/index.mdx b/docs/cn/api-reference/openapi-test/index.mdx new file mode 100644 index 0000000..908e788 --- /dev/null +++ b/docs/cn/api-reference/openapi-test/index.mdx @@ -0,0 +1,11 @@ +--- +title: 'OpenAPI 引用测试' +description: '针对不同 OpenAPI 规范引用方式的测试集' +--- + +本节用于测试 OpenAPI 规范的引用方式: + +- **相对路径** – `openapi/openapi-example.json`(相对于项目根目录的路径) +- **绝对路径** – `/openapi/openapi-example.json`(从仓库根目录开始的绝对路径) +- **同目录** – `docs/api-reference/openapi-test/local-spec.json`(与 MDX 文件位于同一目录的规范) +- **远程地址** – `https://petstore3.swagger.io/api/v3/openapi.json`(托管的 URL) diff --git a/docs/cn/api-reference/openapi-test/relative.mdx b/docs/cn/api-reference/openapi-test/relative.mdx new file mode 100644 index 0000000..9c90791 --- /dev/null +++ b/docs/cn/api-reference/openapi-test/relative.mdx @@ -0,0 +1,7 @@ +--- +title: '相对路径引用' +description: '使用相对于项目根目录的路径引用规范' +openapi: 'openapi/openapi-example.json GET /users' +--- + +引用 `openapi/openapi-example.json` —— 相对于项目根目录的路径(无前导斜杠)。 diff --git a/docs/cn/api-reference/openapi-test/remote.mdx b/docs/cn/api-reference/openapi-test/remote.mdx new file mode 100644 index 0000000..8c6dbaf --- /dev/null +++ b/docs/cn/api-reference/openapi-test/remote.mdx @@ -0,0 +1,7 @@ +--- +title: '远程引用' +description: '通过远程 URL 引用 OpenAPI 规范' +openapi: 'https://petstore3.swagger.io/api/v3/openapi.json GET /pets' +--- + +通过 URL 引用 Swagger Petstore 规范:`https://petstore3.swagger.io/api/v3/openapi.json`。 diff --git a/docs/cn/api-reference/openapi-test/same-dir.mdx b/docs/cn/api-reference/openapi-test/same-dir.mdx new file mode 100644 index 0000000..2cc2b89 --- /dev/null +++ b/docs/cn/api-reference/openapi-test/same-dir.mdx @@ -0,0 +1,7 @@ +--- +title: '同目录引用' +description: '引用与该 MDX 文件位于同一目录的规范' +openapi: 'local-spec.json GET /items' +--- + +引用与当前页面位于同一目录的 `local-spec.json`。从项目根目录起的路径为:`docs/api-reference/openapi-test/local-spec.json`。 diff --git a/docs/cn/development.mdx b/docs/cn/development.mdx new file mode 100644 index 0000000..963285a --- /dev/null +++ b/docs/cn/development.mdx @@ -0,0 +1,93 @@ +--- +title: "开发" +description: "在本地预览更改以更新您的文档" +--- + + + **前置条件**: + + - Node.js 版本 19 或更高 + - 包含 `docs.json` 文件的文档仓库 + + +按照以下步骤,在您选择的操作系统上安装并运行 Mintlify。我们同时支持 Windows 和 macOS。 + + + + ```bash + npm i -g mint + ``` + + + 进入您 `docs.json` 文件所在的文档目录,然后运行以下命令: + + ```bash + mint dev + ``` + + 您的文档本地预览将可在 `http://localhost:3000` 访问。 + + + +## 自定义端口 + +默认情况下,Mintlify 使用端口 3000。您可以使用 `--port` 标志自定义 Mintlify 运行的端口。例如,要在端口 3333 上运行 Mintlify,请使用以下命令: + +```bash +mint dev --port 3333 +``` + +如果您尝试在已被占用的端口上运行 Mintlify,它将使用下一个可用的端口: + +```md +Port 3000 is already in use. Trying 3001 instead. +``` + +## Mintlify 版本 + +请注意,每个 CLI 版本都与特定版本的 Mintlify 相关联。如果您的本地预览与生产版本不一致,请更新 CLI: + +```bash +npm mint update +``` + +## 验证链接 + +CLI 可以协助验证您文档中的链接。要识别任何失效链接,请使用以下命令: + +```bash +mint broken-links +``` + +## 部署 + +如果部署成功,您应该会看到以下内容: + + + 显示 All checks have passed 部署确认消息的截图。 + + +## 代码格式化 + +我们建议在您的 IDE 上使用扩展来识别和格式化 MDX。如果您是 VSCode 用户,可以考虑使用 [MDX VSCode 扩展](https://marketplace.visualstudio.com/items?itemName=unifiedjs.vscode-mdx)进行语法高亮,以及使用 [Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) 进行代码格式化。 + +## 故障排除 + + + + 这可能是由于 node 版本过旧造成的。请尝试以下操作: + + 1. 移除当前安装的 CLI 版本:`npm remove -g mint` + 2. 升级到 Node v19 或更高版本。 + 3. 重新安装 CLI:`npm i -g mint` + + + 解决方案:进入设备的根目录并删除 `~/.mintlify` 文件夹。然后再次运行 `mint dev`。 + + + +想了解最新 CLI 版本有哪些变化?请查看 [CLI 更新日志](https://www.npmjs.com/package/mintlify?activeTab=versions)。 diff --git a/docs/cn/essentials/code.mdx b/docs/cn/essentials/code.mdx new file mode 100644 index 0000000..61e1867 --- /dev/null +++ b/docs/cn/essentials/code.mdx @@ -0,0 +1,35 @@ +--- +title: '代码块' +description: '展示行内代码与代码块' +icon: 'code' +--- + +## 行内代码 + +要将某个`单词`或`短语`标记为代码,请使用反引号 (`) 包裹。 + +``` +To denote a `word` or `phrase` as code, enclose it in backticks (`). +``` + +## 代码块 + +使用[围栏代码块](https://www.markdownguide.org/extended-syntax/#fenced-code-blocks),即用三个反引号包裹代码,并在起始反引号后写上代码片段所用的编程语言,即可获得语法高亮。您也可以选择在编程语言之后写上代码的名称。 + +```java HelloWorld.java +class HelloWorld { + public static void main(String[] args) { + System.out.println("Hello, World!"); + } +} +``` + +````md +```java HelloWorld.java +class HelloWorld { + public static void main(String[] args) { + System.out.println("Hello, World!"); + } +} +``` +```` diff --git a/docs/cn/essentials/images.mdx b/docs/cn/essentials/images.mdx new file mode 100644 index 0000000..7ddd862 --- /dev/null +++ b/docs/cn/essentials/images.mdx @@ -0,0 +1,59 @@ +--- +title: '图片与嵌入' +description: '添加图片、视频以及其他 HTML 元素' +icon: 'image' +--- + + + +## 图片 + +### 使用 Markdown + +[Markdown 语法](https://www.markdownguide.org/basic-syntax/#images)允许您通过以下代码添加图片: + +```md +![title](/path/image.jpg) +``` + +请注意,图片文件大小必须小于 5MB。否则,我们建议将其托管在 [Cloudinary](https://cloudinary.com/) 或 [S3](https://aws.amazon.com/s3/) 等服务上。然后您可以使用对应的 URL 进行嵌入。 + +### 使用嵌入 + +若要获得对图片更丰富的自定义能力,您也可以使用[嵌入](/writing-content/embed)来添加图片: + +```html + +``` + +## 嵌入与 HTML 元素 + + + +
+ + + +Mintlify 支持 [Markdown 中的 HTML 标签](https://www.markdownguide.org/basic-syntax/#html)。如果您偏好使用 HTML 标签而非 Markdown 语法,这将非常有用,并能让您以无限的灵活性创建文档。 + + + +### iFrames + +在文档中加载另一个 HTML 页面。最常用于嵌入视频。 + +```html + +``` diff --git a/docs/cn/essentials/markdown.mdx b/docs/cn/essentials/markdown.mdx new file mode 100644 index 0000000..41d30a0 --- /dev/null +++ b/docs/cn/essentials/markdown.mdx @@ -0,0 +1,88 @@ +--- +title: 'Markdown 语法' +description: '使用标准 Markdown 编排文本、标题和样式' +icon: 'text-size' +--- + +## 标题 + +最适合用作章节标题。 + +```md +## Titles +``` + +### 子标题 + +最适合用作子章节标题。 + +```md +### Subtitles +``` + + + +每个**标题**和**子标题**都会生成一个锚点,并出现在右侧的目录中。 + + + +## 文本格式 + +我们支持大多数 Markdown 格式。只需在文本两侧添加 `**`、`_` 或 `~` 即可设置格式。 + +| 样式 | 写法 | 效果 | +| ---------- | ----------------- | --------------- | +| 加粗 | `**bold**` | **bold** | +| 斜体 | `_italic_` | _italic_ | +| 删除线 | `~strikethrough~` | ~strikethrough~ | + +您可以将它们组合使用。例如,写 `**_bold and italic_**` 可以得到 **_bold and italic_** 文本。 + +要书写上标和下标文本,需使用 HTML,即在文本两侧添加 `` 或 ``。 + +| 文本尺寸 | 写法 | 效果 | +| ----------- | ------------------------ | ---------------------- | +| 上标 | `superscript` | superscript | +| 下标 | `subscript` | subscript | + +## 链接到页面 + +您可以通过将文本包裹在 `[]()` 中来添加链接。书写 `[link to google](https://google.com)` 即可生成 [link to google](https://google.com)。 + +文档内部页面链接需要使用根相对路径。基本上,您应当包含完整的文件夹路径。例如,`[link to text](/writing-content/text)` 会链接到我们组件章节中的 "Text" 页面。 + +诸如 `[link to text](../text)` 的相对链接打开速度会较慢,因为我们无法轻易对其进行优化。 + +## 引用块 + +### 单行 + +要创建引用块,请在段落前添加 `>`。 + +> Dorothy followed her through many of the beautiful rooms in her castle. + +```md +> Dorothy followed her through many of the beautiful rooms in her castle. +``` + +### 多行 + +> Dorothy followed her through many of the beautiful rooms in her castle. +> +> The Witch bade her clean the pots and kettles and sweep the floor and keep the fire fed with wood. + +```md +> Dorothy followed her through many of the beautiful rooms in her castle. +> +> The Witch bade her clean the pots and kettles and sweep the floor and keep the fire fed with wood. +``` + +### LaTeX + +Mintlify 通过 Latex 组件支持 [LaTeX](https://www.latex-project.org)。 + +8 x (vk x H1 - H2) = (0,1) + +```md +8 x (vk x H1 - H2) = (0,1) +``` diff --git a/docs/cn/essentials/navigation.mdx b/docs/cn/essentials/navigation.mdx new file mode 100644 index 0000000..275caad --- /dev/null +++ b/docs/cn/essentials/navigation.mdx @@ -0,0 +1,87 @@ +--- +title: '导航' +description: 'docs.json 中的 navigation 字段定义了导航菜单中显示的页面' +icon: 'map' +--- + +导航菜单是每个网站上显示的链接列表。 + +每当您新增页面时,通常都需要更新 `docs.json`。页面不会自动出现。 + +## 导航语法 + +我们的导航语法是递归的,这意味着您可以创建嵌套的导航分组。页面名称中无需包含 `.mdx`。 + + + +```json Regular Navigation +"navigation": { + "tabs": [ + { + "tab": "Docs", + "groups": [ + { + "group": "Getting Started", + "pages": ["quickstart"] + } + ] + } + ] +} +``` + +```json Nested Navigation +"navigation": { + "tabs": [ + { + "tab": "Docs", + "groups": [ + { + "group": "Getting Started", + "pages": [ + "quickstart", + { + "group": "Nested Reference Pages", + "pages": ["nested-reference-page"] + } + ] + } + ] + } + ] +} +``` + + + +## 文件夹 + +只需将 MDX 文件放入文件夹中,并在 `docs.json` 中更新路径即可。 + +例如,要让页面位于 `https://yoursite.com/your-folder/your-page`,您需要创建一个名为 `your-folder` 的文件夹,并在其中放置名为 `your-page.mdx` 的 MDX 文件。 + + + +您不能将文件夹命名为 `api`,除非将其嵌套在另一个文件夹内。Mintlify 使用 Next.js,而 Next.js 将顶层 `api` 文件夹保留用于内部服务器调用。诸如 `api-reference` 这样的文件夹名称则是被允许的。 + + + +```json Navigation With Folder +"navigation": { + "tabs": [ + { + "tab": "Docs", + "groups": [ + { + "group": "Group Name", + "pages": ["your-folder/your-page"] + } + ] + } + ] +} +``` + +## 隐藏页面 + +未包含在 `docs.json` 中的 MDX 文件不会显示在侧边栏中,但仍可通过搜索栏访问,也可通过直接链接到这些页面来访问。 diff --git a/docs/cn/essentials/reusable-snippets.mdx b/docs/cn/essentials/reusable-snippets.mdx new file mode 100644 index 0000000..14b9142 --- /dev/null +++ b/docs/cn/essentials/reusable-snippets.mdx @@ -0,0 +1,108 @@ +--- +title: "可复用代码片段" +description: "可复用的自定义片段,让内容保持同步" +icon: "recycle" +--- + +import SnippetIntro from '/snippets/snippet-intro.mdx'; + + + +## 创建自定义片段 + +**前置条件**:您必须在 `snippets` 目录中创建片段文件。 + + + `snippets` 目录中的任何页面都将被视作片段,且不会 + 作为独立页面渲染。如果您想从片段创建独立页面,请 + 将片段导入到另一个文件中,并以组件形式使用它。 + + +### 默认导出 + +1. 将您希望在多个位置复用的内容添加到片段文件中。可选地,您可以添加变量, + 在导入片段时通过 props 填充这些变量。 + +```mdx snippets/my-snippet.mdx +Hello world! This is my content I want to reuse across pages. My keyword of the +day is {word}. +``` + + + 您希望复用的内容必须位于 `snippets` 目录内, + 否则导入将无法生效。 + + +2. 将片段导入到目标文件中。 + +```mdx destination-file.mdx +--- +title: My title +description: My Description +--- + +import MySnippet from '/snippets/path/to/my-snippet.mdx'; + +## Header + +Lorem impsum dolor sit amet. + + +``` + +### 可复用变量 + +1. 从片段文件中导出变量: + +```mdx snippets/path/to/custom-variables.mdx +export const myName = 'my name'; + +export const myObject = { fruit: 'strawberries' }; +``` + +2. 在目标文件中导入该片段并使用变量: + +```mdx destination-file.mdx +--- +title: My title +description: My Description +--- + +import { myName, myObject } from '/snippets/path/to/custom-variables.mdx'; + +Hello, my name is {myName} and I like {myObject.fruit}. +``` + +### 可复用组件 + +1. 在片段文件内,通过以箭头函数形式导出组件来创建一个接收 props 的 + 组件。 + +```mdx snippets/custom-component.mdx +export const MyComponent = ({ title }) => ( +
+

{title}

+

... snippet content ...

+
+); +``` + + + MDX 不会在箭头函数体内编译。请尽可能坚持使用 HTML + 语法,或者在需要使用 MDX 时改用默认导出。 + + +2. 将片段导入到目标文件中并传入 props + +```mdx destination-file.mdx +--- +title: My title +description: My Description +--- + +import { MyComponent } from '/snippets/custom-component.mdx'; + +Lorem ipsum dolor sit amet. + + +``` diff --git a/docs/cn/essentials/settings.mdx b/docs/cn/essentials/settings.mdx new file mode 100644 index 0000000..66ca984 --- /dev/null +++ b/docs/cn/essentials/settings.mdx @@ -0,0 +1,317 @@ +--- +title: '全局设置' +description: 'Mintlify 通过 docs.json 文件让您完全掌控文档的外观与风格' +icon: 'gear' +--- + +每个 Mintlify 站点都需要一个包含核心配置的 `docs.json` 文件。在下方了解更多[属性](#properties)。 + +## 属性 + + +项目名称。用作全局标题。 + +示例:`mintlify` + + + + + 包含所有分组及其页面的数组 + + + 分组名称。 + + 示例:`Settings` + + + + 作为页面的 Markdown 文件的相对路径。 + + 示例:`["customization", "page"]` + + + + + + + + Logo 图片的路径,或包含 "light" 和 "dark" 模式 logo 图片路径的对象 + + + 浅色模式下 logo 的路径 + + + 深色模式下 logo 的路径 + + + 点击 logo 后跳转的链接地址 + + + + + + 网站图标(favicon)的路径 + + + + 全局主题的十六进制颜色代码 + + + 主色调。在浅色模式下,最常用于高亮内容、章节 + 标题与点缀 + + + 深色模式下的主色调。最常用于高亮内容、章节标题与 + 点缀(深色模式) + + + 用于重要按钮的主色调 + + + 浅色与深色模式下的背景颜色 + + + 浅色模式下背景的十六进制颜色代码 + + + 深色模式下背景的十六进制颜色代码 + + + + + + + + 要在顶栏中显示的链接的 `name` 与 `url` 数组 + + + 按钮名称。 + + 示例:`Contact us` + + + 点击按钮后跳转的 URL。示例:`https://mintlify.com/docs` + + + + + + + + + Link 显示为一个按钮。GitHub 将显示给定 URL 处的仓库信息,包括 GitHub Star 数量。 + + + 若为 `link`:按钮链接的地址。 + + 若为 `github`:用于加载 GitHub 信息的仓库链接。 + + + 按钮内的文字。仅当 `type` 为 `link` 时必填。 + + + + + + + 版本名称数组。仅当您希望在导航栏中通过下拉菜单 + 展示不同版本的文档时使用。 + + + + 锚点数组,包含 `icon`、`color` 与 `url`。 + + + 用于展示锚点的 [Font Awesome](https://fontawesome.com/search?q=heart) 图标。 + + 示例:`comments` + + + 锚点标签的名称。 + + 示例:`Community` + + + 用于标识哪些页面属于该锚点的 URL 起始部分。通常即您存放页面的文件夹名称。 + + + 锚点图标背景的十六进制颜色。也可以传入包含 `from` 与 `to`(均为十六进制颜色)属性的对象以使用渐变色。 + + + 用于在选中正确的文档版本之前隐藏锚点。 + + + 若希望仅当通过直接链接进入其中的文档时才显示该锚点,请传入 `true`。 + + + 取值之一:"brands"、"duotone"、"light"、"sharp-solid"、"solid" 或 "thin" + + + + + + + 覆盖最顶部锚点的默认配置。 + + + 最顶部锚点的名称 + + + Font Awesome 图标。 + + + 取值之一:"brands"、"duotone"、"light"、"sharp-solid"、"solid" 或 "thin" + + + + + + 导航标签页数组。 + + + 标签页标签的名称。 + + + 用于标识哪些页面属于该标签页的 URL 起始部分。通常即您存放 + 页面的文件夹名称。 + + + + + + API 设置的配置。在 [API 组件](/api-playground/demo)中了解更多关于 API 页面的信息。 + + + 所有 API 端点的基础 URL。如果 `baseUrl` 是一个数组,则会启用多个基础 URL + 选项,用户可在它们之间切换。 + + + + + + 用于所有 API 端点的认证策略。 + + + 在 API 演练场中使用的认证参数名称。 + + 如果 method 为 `basic`,格式应为 `[usernameName]:[passwordName]` + + + 作为认证输入框前缀的默认值。 + + 例如,将 `inputPrefix` 设为 `AuthKey` 后,认证字段的默认输入结果会以 `AuthKey` 作为前缀。 + + + + + + API 演练场的配置 + + + + 演练场是显示、隐藏,还是仅展示端点而不提供用户交互(`simple`) + + 在[演练场指南](/api-playground/demo)中了解更多 + + + + + + 启用该标志可确保 OpenAPI 页面中的键顺序与 OpenAPI 文件中定义的键顺序保持一致。 + + 此行为很快将默认启用,届时该字段将被弃用。 + + + + + + + 指向您 OpenAPI 文件的 URL 或相对路径,可以是字符串或字符串数组。 + + 示例: + + ```json Absolute + "openapi": "https://example.com/openapi.json" + ``` + ```json Relative + "openapi": "/openapi.json" + ``` + ```json Multiple + "openapi": ["https://example.com/openapi1.json", "/openapi2.json", "/openapi3.json"] + ``` + + + + + + 社交媒体账户对象,键值对分别表示社交平台与账户 URL。 + + 示例: + ```json + { + "x": "https://x.com/mintlify", + "website": "https://mintlify.com" + } + ``` + + + 以下取值之一:`website`、`facebook`、`x`、`discord`、`slack`、`github`、`linkedin`、`instagram`、`hacker-news` + + 示例:`x` + + + 指向社交平台的 URL。 + + 示例:`https://x.com/mintlify` + + + + + + 启用反馈按钮的配置 + + + + 启用按钮,允许用户通过 pull request 建议修改 + + + 启用按钮,允许用户对文档提交 issue + + + + + + 自定义深色模式切换。 + + + 如果希望对新用户始终展示浅色或深色模式,请进行设置。未设置时, + 默认与用户操作系统的模式一致。 + + + 设为 true 可隐藏深色/浅色模式切换。您可以将 `isHidden` 与 `default` 结合使用,强制文档仅使用浅色或深色模式。例如: + + + ```json Only Dark Mode + "modeToggle": { + "default": "dark", + "isHidden": true + } + ``` + + ```json Only Light Mode + "modeToggle": { + "default": "light", + "isHidden": true + } + ``` + + + + + + + + + 在每个页面背后显示的背景图片。可参考 + [Infisical](https://infisical.com/docs) 与 [FRPC](https://frpc.io) 的示例。 + diff --git a/docs/cn/implementation-exercises/async-export-jobs.mdx b/docs/cn/implementation-exercises/async-export-jobs.mdx new file mode 100644 index 0000000..95546db --- /dev/null +++ b/docs/cn/implementation-exercises/async-export-jobs.mdx @@ -0,0 +1,117 @@ +--- +title: "实现异步导出任务" +description: "为工作区数据构建基于任务的 CSV 导出流程。" +icon: "file-arrow-down" +--- + +当您希望编码代理为虚构的 Acorn Analytics 产品添加后台导出任务时,请使用本指南。 + +## 需要构建的内容 + +- `POST /api/exports`:创建新的导出任务 +- `GET /api/exports/:id`:轮询任务状态 +- `GET /api/exports/:id/download`:获取已完成的文件 +- 用于生成 CSV 导出的后台工作进程 + +## 创建导出任务 + +`POST /api/exports` + +请求体: + +```json +{ + "resource": "events", + "format": "csv", + "filters": { + "project_id": "proj_123", + "from": "2026-04-01T00:00:00Z", + "to": "2026-04-06T00:00:00Z" + } +} +``` + +行为: + +- 校验过滤条件与资源类型 +- 创建一条新的导出任务记录 +- 将任务加入后台处理队列 +- 立即返回 `202 Accepted` +- 如果调用方在 10 秒内未收到响应,应当安全地重试该请求 + +响应: + +```json +{ + "id": "exp_4821", + "status": "queued", + "status_url": "/api/exports/exp_4821" +} +``` + +## 任务生命周期 + +任务会经历以下状态: + +- `queued` +- `running` +- `completed` +- `failed` + +状态响应: + +```json +{ + "id": "exp_4821", + "status": "running", + "progress": 42 +} +``` + +当导出完成时,返回: + +```json +{ + "id": "exp_4821", + "status": "completed", + "download_url": "/api/exports/exp_4821/download", + "expires_at": "2026-04-07T18:24:11Z" +} +``` + +## 工作进程要求 + +- 在创建任务时对所提交的过滤条件负载做快照 +- 将数据行流式写入 CSV 文件,而非将整份导出缓存在内存中 +- 随着数据块写入更新 `progress` +- 如果生成意外中断,将任务标记为 `failed` 并附带错误信息 +- 已完成的导出产物保留 24 小时 + +## 下载端点 + +`GET /api/exports/:id/download` + +- 要求请求用户与任务属于同一工作区 +- 如果任务未完成,返回 `404` +- 如果产物已过期,返回 `410` +- 以 `text/csv` 流式返回文件 + +## 建议的数据库结构 + +```sql +create table export_jobs ( + id text primary key, + workspace_id text not null, + requested_by text not null, + resource text not null, + format text not null, + filters jsonb not null, + status text not null, + progress integer not null default 0, + artifact_path text, + error_message text, + expires_at timestamptz, + created_at timestamptz not null default now(), + updated_at timestamptz not null default now() +); +``` diff --git a/docs/cn/implementation-exercises/signed-webhooks.mdx b/docs/cn/implementation-exercises/signed-webhooks.mdx new file mode 100644 index 0000000..3cebf87 --- /dev/null +++ b/docs/cn/implementation-exercises/signed-webhooks.mdx @@ -0,0 +1,97 @@ +--- +title: "实现带签名的 Webhook" +description: "为计费事件添加入站 webhook 验证。" +icon: "shield-check" +--- + +当您希望编码代理为虚构的 Acorn Billing API 添加带签名的 webhook 支持时,请使用本指南。 + +## 需要构建的内容 + +- 一个 `POST /api/webhooks/acorn-billing` 端点 +- 在任何业务逻辑运行之前进行签名验证 +- 支持 `invoice.paid`、`invoice.failed` 与 `subscription.canceled` +- 使用投递 ID 请求头进行投递去重 + +## 请求格式 + +Acorn Billing 发送 JSON webhook,包含以下请求头: + +- `x-acorn-delivery-id`:本次投递尝试的唯一 ID +- `x-acorn-timestamp`:Unix 时间戳(秒) +- `x-acorn-signature`:HMAC SHA-256 的十六进制摘要 + +请求体格式如下: + +```json +{ + "id": "evt_9f2c0c0d", + "type": "invoice.paid", + "created_at": "2026-04-01T18:24:11Z", + "data": { + "invoice_id": "inv_4821", + "customer_id": "cus_1942", + "amount": 12900, + "currency": "usd" + } +} +``` + +## 验证流程 + +1. 解析 JSON 请求体。 +2. 构造签名负载 `${timestamp}.${JSON.stringify(body)}`。 +3. 使用 HMAC SHA-256 与 `ACORN_WEBHOOK_SECRET` 计算预期摘要。 +4. 使用常量时间比较法将预期摘要与 `x-acorn-signature` 进行比对。 +5. 当时间戳超过 5 分钟时拒绝请求。 + +```ts +import { createHmac, timingSafeEqual } from 'node:crypto'; + +export function verifyAcornSignature(body: unknown, timestamp: string, signature: string) { + const payload = `${timestamp}.${JSON.stringify(body)}`; + const expected = createHmac('sha256', process.env.ACORN_WEBHOOK_SECRET!) + .update(payload) + .digest('hex'); + + return timingSafeEqual(Buffer.from(signature), Buffer.from(expected)); +} +``` + +## 处理器行为 + +- 签名校验通过且事件已入队后,立即返回 `200 OK`。 +- 存储 `x-acorn-delivery-id`,以便忽略重复投递。 +- 按 `type` 路由事件。 +- 不要让 webhook 响应阻塞在下游 API 调用上。 + +## 事件处理规则 + +### `invoice.paid` + +- 将发票标记为已支付 +- 添加一条付款时间线记录 +- 向客户发送收据邮件 + +### `invoice.failed` + +- 将发票标记为逾期 +- 安排重试通知工作流 + +### `subscription.canceled` + +- 记录取消时间 +- 在计费周期结束时撤销高级访问权限 + +## 本地测试 + +测试时可使用以下负载并配合本地签名器: + +```bash +curl -X POST http://localhost:3000/api/webhooks/acorn-billing \ + -H "content-type: application/json" \ + -H "x-acorn-delivery-id: del_123" \ + -H "x-acorn-timestamp: 1712426400" \ + -H "x-acorn-signature: " \ + -d '{"id":"evt_9f2c0c0d","type":"invoice.paid","data":{"invoice_id":"inv_4821"}}' +``` diff --git a/docs/cn/implementation-exercises/team-feature-flags.mdx b/docs/cn/implementation-exercises/team-feature-flags.mdx new file mode 100644 index 0000000..6f03e9c --- /dev/null +++ b/docs/cn/implementation-exercises/team-feature-flags.mdx @@ -0,0 +1,97 @@ +--- +title: "实现团队功能开关" +description: "添加支持环境定向的团队级功能开关。" +icon: "toggle-on" +--- + +当您希望编码代理为虚构的 Acorn Workspace 产品添加团队级功能开关时,请使用本指南。 + +## 需要构建的内容 + +- 带有工作区级默认值的功能开关模型 +- 可选的团队特定覆盖 +- 针对 `development`、`staging` 与 `production` 的可选环境特定覆盖 +- 类似 `isFeatureEnabled(flagKey, context)` 的辅助函数 +- 支持渐进式发布的百分比灰度 + +## 数据模型 + +使用类似如下的结构: + +```ts +type FeatureFlag = { + key: string; + enabled: boolean; + rolloutPercentage?: number; + environment?: 'development' | 'staging' | 'production'; + teamId?: string; +}; +``` + +只要每条记录针对的作用域不同,您可以为同一个 `key` 存储多条记录。 + +## 评估上下文 + +辅助函数应当接受: + +```ts +type EvaluationContext = { + workspaceId: string; + teamId?: string; + environment: 'development' | 'staging' | 'production'; + userId: string; +}; +``` + +## 评估规则 + +1. 从工作区级开关开始。 +2. 检查同一 key 是否存在针对环境的开关。 +3. 检查同一 key 是否存在针对团队的开关。 +4. 如果匹配到的开关设有 `rolloutPercentage`,将 `userId` 哈希为 `0` 到 `99` 之间的桶号。 +5. 当用户落在灰度窗口内时返回 `true`。 + +## 管理员行为 + +- 产品管理员可以创建和编辑开关 +- 团队负责人可以编辑本团队的团队特定覆盖 +- 变更应当无需重启服务器即可生效 +- 审计日志应记录谁在何时修改了开关 + +## API 形态 + +### 创建开关 + +`POST /api/feature-flags` + +```json +{ + "key": "new-sidebar", + "enabled": true, + "environment": "production", + "teamId": "team_design" +} +``` + +### 评估开关 + +`POST /api/feature-flags/evaluate` + +```json +{ + "key": "new-sidebar", + "context": { + "workspaceId": "ws_123", + "teamId": "team_design", + "environment": "production", + "userId": "user_42" + } +} +``` + +## 实现要点 + +- 对于相同的用户和开关,保持评估辅助函数具有确定性 +- 在短时间内缓存生效中的开关集合,以减少数据库读取 +- 在评估端点同时返回布尔结果与匹配到的开关记录 +- 围绕灰度边界与缺失的团队 ID 添加单元测试 diff --git a/docs/cn/index.mdx b/docs/cn/index.mdx new file mode 100644 index 0000000..519eeb0 --- /dev/null +++ b/docs/cn/index.mdx @@ -0,0 +1,100 @@ +--- +title: "简介" +description: "欢迎来到您文档的新家" +de_link: "https://developers.example.de/docs" +fr_link: "https://developers.example.fr/docs" +es_link: "https://developers.example.es/docs" +--- + +## 开始设置 + +只需几分钟即可启动并运行您的文档站点 + + + 跟随我们三步快速入门指南 + + +## 打造专属风格 + +设计一个看起来很棒并能赋能用户的文档站点。 + + + + 在本地编辑文档并实时预览效果。 + + + 自定义站点的设计和颜色以匹配您的品牌。 + + + 组织您的文档,帮助用户找到所需内容并成功使用您的产品。 + + + 根据 OpenAPI 规范自动生成 API 文档。 + + + +## 创建精美页面 + +创建世界级文档所需的一切。 + + + + 使用 MDX 为您的文档页面设置样式。 + + + 添加示例代码以演示如何使用您的产品。 + + + 显示图片和其他媒体。 + + + 一次编写,在整个文档中重复使用。 + + + +## 需要灵感? + + + 浏览我们出色的文档站点展示。 + diff --git a/docs/cn/quickstart.mdx b/docs/cn/quickstart.mdx new file mode 100644 index 0000000..abd2dd3 --- /dev/null +++ b/docs/cn/quickstart.mdx @@ -0,0 +1,158 @@ +--- +title: "快速入门" +description: "几分钟内开始构建精彩的文档" +timestamp: "true" +mode: "frame" +de_link: "https://developers.example.de/docs/quickstart" +fr_link: "https://developers.example.fr/docs/quickstart" +es_link: "https://developers.example.es/docs/quickstart" +--- + +## 三步快速上手 + +在本地运行您的文档站点以进行更改。最好的方法是按顺序完成每一步;在这里打好基础将带来长远的回报。在进入下一步之前,请确保您对每一步都有充分的理解。 + +### 第 1 步:设置本地环境 + + + + 在入门流程中,如果您还没有 GitHub 仓库,您已经创建了一个包含文档内容的 GitHub 仓库。您可以在[控制台](https://dashboard.mintlify.com)中找到此仓库的链接。 + + 要将仓库克隆到本地以便进行修改和预览文档,请按照 GitHub 文档中的[克隆仓库](https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository)指南进行操作。 + + + 1. 安装 Mintlify CLI:`npm i -g mint` + 2. 进入您的文档目录并运行:`mint dev` + 3. 打开 `http://localhost:3000` 查看您的实时文档! + + + 在您编辑文件时,预览会自动更新。 + + + + +### 第 2 步:部署您的更改 + + + + 从您的[控制台](https://dashboard.mintlify.com/settings/organization/github-app)安装 Mintlify GitHub 应用。 + + 我们的 GitHub 应用会自动将您的更改部署到文档站点,因此您无需自行管理部署。 + + + 作为第一个更改,让我们来更新您文档站点的名称和颜色。 + + 1. 在编辑器中打开 `docs.json`。 + 2. 将 `"name"` 字段更改为您的项目名称。 + 3. 更新 `"colors"` 以匹配您的品牌。 + 4. 保存后立即在 `http://localhost:3000` 查看您的更改。 + + + 尝试更改主色调以查看立竿见影的效果! + + + + +### 第 3 步:上线发布 + + + 1. 提交并推送您的更改。 + 2. 您的文档将在片刻之内更新并上线! + + +hello hello hello + +## 后续步骤 + +现在您已经运行了文档,请探索这些关键功能: + +| 功能 | 描述 | 链接 | +| ----------- | --------------- | -------------------------------------------------------- | +| 编写内容 | 学习 MDX 语法 | [/essentials/markdown](/essentials/markdown) | +| 自定义样式 | 匹配您的品牌 | [/essentials/settings](/essentials/settings) | +| 代码示例 | 语法高亮 | [/essentials/code](/essentials/code) | +| API 文档 | OpenAPI 集成 | [/api-reference/introduction](/api-reference/introduction) | + + + **示例 XML 提要**: + 下载 feed.xml + + 以查看静态 XML 文件是如何提供服务的。 + + + + + 学习 MDX 语法并开始编写您的文档。 + + + 让您的文档与品牌完美匹配。 + + + 包含语法高亮的代码块。 + + + 根据 OpenAPI 规范自动生成 API 文档。 + + + 查看 Get Plants 端点文档。 + + + 查看用户 API 文档。 + + + +## 核心功能 + + + + - 创建和组织 MDX 文件 + - 使用 frontmatter 管理元数据 + - 添加图片和资源 + - 使用标题和章节进行结构化 + + + - 配置站点颜色和品牌 + - 自定义导航结构 + - 添加自定义 CSS 和组件 + - 设置搜索功能 + + + - 热重载预览服务器 + - 通过 GitHub 自动部署 + - 版本控制集成 + - 用于常见任务的 CLI 命令 + + + - 语法高亮的代码块 + - 交互式 API 文档 + - 搜索和导航 + - 移动端响应式设计 + + + +## 快速提示 + + + + - 全局安装 Mintlify CLI + - 在本地克隆您的仓库 + - 运行 `mint dev` 进行预览 + - 进行更改并立即查看更新 + + + - 将内容有条理地放在文件夹中 + - 使用描述性的文件名 + - 编写清晰、简洁的文档 + - 先在本地测试您的更改 + + + - 检查您的 `docs.json` 配置 + - 验证文件路径和链接 + - 查看控制台中的错误 + - 查阅 Mintlify 文档 + + + + + **需要帮助?** 请查看我们的[完整文档](https://mintlify.com/docs)或加入我们的[社区](https://mintlify.com/community)。 + diff --git a/docs/cn/snippets/snippet-intro.mdx b/docs/cn/snippets/snippet-intro.mdx new file mode 100644 index 0000000..f47319b --- /dev/null +++ b/docs/cn/snippets/snippet-intro.mdx @@ -0,0 +1,3 @@ +软件开发的核心原则之一是 DRY(Don't Repeat +Yourself,不要重复自己)。这一原则同样适用于文档编写。如果您发现自己在多个地方重复相同的内容, +您应该考虑创建一个自定义代码片段,以保持您的内容同步。