@clarify-labs/templates 0.8.2 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,46 @@
1
+ ---
2
+ title: 嵌入 API 端点
3
+ description: 在面向工作流的 MDX 页面中渲染 OpenAPI 操作。
4
+ ---
5
+
6
+ # 嵌入 API 端点
7
+
8
+ 当某个端点需要贴近教程、设置指南或集成流程时,可以使用嵌入式 OpenAPI 组件。
9
+
10
+ ## Markdown 描述
11
+
12
+ OpenAPI 的 `description` 字符串会在完整参考页和嵌入式操作中渲染 Markdown。这样可以把接口说明保留在 spec 中,同时支持链接、列表、强调和 `inline code`。
13
+
14
+ ```json
15
+ {
16
+ "description": "Returns **active** projects.\n\n- Use `limit` for page size.\n- Use `nextCursor` for pagination."
17
+ }
18
+ ```
19
+
20
+ ## 嵌入单个操作
21
+
22
+ ```mdx
23
+ <OpenApiOperation specPath="/api" path="/v1/projects" method="get" />
24
+ ```
25
+
26
+ <OpenApiOperation specPath="/api" path="/v1/projects" method="get" />
27
+
28
+ ## 嵌入带请求体的操作
29
+
30
+ ```mdx
31
+ <OpenApiOperation specPath="/api" path="/v1/projects" method="post" />
32
+ ```
33
+
34
+ <OpenApiOperation specPath="/api" path="/v1/projects" method="post" />
35
+
36
+ ## 嵌入完整 API 页面
37
+
38
+ 如果想在完整参考文档前添加说明文字,可以使用 `OpenApiDocument`。
39
+
40
+ ```mdx
41
+ <OpenApiDocument specPath="/api" />
42
+ ```
43
+
44
+ <Callout title="Spec path 约定">
45
+ `specPath` 是从 OpenAPI 文件名生成的路由。`api.openapi.json` 会生成 `/api`。
46
+ </Callout>
@@ -0,0 +1,319 @@
1
+ {
2
+ "openapi": "3.1.0",
3
+ "info": {
4
+ "title": "Starter API",
5
+ "summary": "A compact OpenAPI example for Clarify.",
6
+ "description": "Replace this file with your real OpenAPI description.\n\n**Markdown descriptions are supported** in API reference pages and embedded endpoints. Use `inline code`, links, lists, and tables for interface notes while keeping reusable components in MDX.\n\n| Field | Use |\n| --- | --- |\n| `limit` | Page size |\n| `cursor` | Pagination token |",
7
+ "version": "1.0.0"
8
+ },
9
+ "servers": [
10
+ {
11
+ "url": "https://api.example.com",
12
+ "description": "Production"
13
+ },
14
+ {
15
+ "url": "https://sandbox.example.com",
16
+ "description": "Sandbox"
17
+ }
18
+ ],
19
+ "tags": [
20
+ {
21
+ "name": "Projects",
22
+ "description": "Project management endpoints."
23
+ },
24
+ {
25
+ "name": "System",
26
+ "description": "Operational endpoints."
27
+ }
28
+ ],
29
+ "security": [
30
+ {
31
+ "BearerAuth": []
32
+ }
33
+ ],
34
+ "paths": {
35
+ "/v1/projects": {
36
+ "get": {
37
+ "tags": ["Projects"],
38
+ "operationId": "listProjects",
39
+ "summary": "List projects",
40
+ "description": "Returns projects visible to the current API token.\n\n- Use `limit` to control page size.\n- Pass the returned `nextCursor` to continue pagination.",
41
+ "parameters": [
42
+ {
43
+ "name": "limit",
44
+ "in": "query",
45
+ "description": "Maximum number of projects to return.\n\n| Value | Behavior |\n| --- | --- |\n| `20` | Default page size |\n| `100` | Largest allowed page |",
46
+ "schema": {
47
+ "type": "integer",
48
+ "minimum": 1,
49
+ "maximum": 100,
50
+ "default": 20
51
+ }
52
+ },
53
+ {
54
+ "name": "cursor",
55
+ "in": "query",
56
+ "description": "Pagination cursor from a previous response.",
57
+ "schema": {
58
+ "type": "string"
59
+ }
60
+ }
61
+ ],
62
+ "responses": {
63
+ "200": {
64
+ "description": "Project list.",
65
+ "content": {
66
+ "application/json": {
67
+ "schema": {
68
+ "$ref": "#/components/schemas/ProjectList"
69
+ },
70
+ "examples": {
71
+ "default": {
72
+ "summary": "Two projects",
73
+ "value": {
74
+ "data": [
75
+ {
76
+ "id": "proj_123",
77
+ "name": "Documentation",
78
+ "status": "active"
79
+ },
80
+ {
81
+ "id": "proj_456",
82
+ "name": "API Reference",
83
+ "status": "archived"
84
+ }
85
+ ],
86
+ "nextCursor": null
87
+ }
88
+ }
89
+ }
90
+ }
91
+ }
92
+ },
93
+ "401": {
94
+ "$ref": "#/components/responses/Unauthorized"
95
+ }
96
+ }
97
+ },
98
+ "post": {
99
+ "tags": ["Projects"],
100
+ "operationId": "createProject",
101
+ "summary": "Create a project",
102
+ "description": "Creates a new project from a JSON request body.",
103
+ "requestBody": {
104
+ "required": true,
105
+ "description": "Send **JSON** with a `name` and optional `description`.",
106
+ "content": {
107
+ "application/json": {
108
+ "schema": {
109
+ "$ref": "#/components/schemas/ProjectCreate"
110
+ },
111
+ "examples": {
112
+ "default": {
113
+ "value": {
114
+ "name": "Documentation",
115
+ "description": "Public product documentation."
116
+ }
117
+ }
118
+ }
119
+ }
120
+ }
121
+ },
122
+ "responses": {
123
+ "201": {
124
+ "description": "Project created.",
125
+ "content": {
126
+ "application/json": {
127
+ "schema": {
128
+ "$ref": "#/components/schemas/Project"
129
+ }
130
+ }
131
+ }
132
+ },
133
+ "400": {
134
+ "$ref": "#/components/responses/BadRequest"
135
+ },
136
+ "401": {
137
+ "$ref": "#/components/responses/Unauthorized"
138
+ }
139
+ }
140
+ }
141
+ },
142
+ "/v1/projects/{projectId}": {
143
+ "parameters": [
144
+ {
145
+ "name": "projectId",
146
+ "in": "path",
147
+ "required": true,
148
+ "description": "Project identifier.",
149
+ "schema": {
150
+ "type": "string",
151
+ "pattern": "^proj_[a-zA-Z0-9]+$"
152
+ }
153
+ }
154
+ ],
155
+ "get": {
156
+ "tags": ["Projects"],
157
+ "operationId": "getProject",
158
+ "summary": "Get a project",
159
+ "responses": {
160
+ "200": {
161
+ "description": "Project details.",
162
+ "content": {
163
+ "application/json": {
164
+ "schema": {
165
+ "$ref": "#/components/schemas/Project"
166
+ }
167
+ }
168
+ }
169
+ },
170
+ "404": {
171
+ "$ref": "#/components/responses/NotFound"
172
+ }
173
+ }
174
+ }
175
+ },
176
+ "/v1/health": {
177
+ "get": {
178
+ "tags": ["System"],
179
+ "operationId": "getHealth",
180
+ "summary": "Check service health",
181
+ "security": [],
182
+ "responses": {
183
+ "200": {
184
+ "description": "Service status.",
185
+ "content": {
186
+ "application/json": {
187
+ "schema": {
188
+ "type": "object",
189
+ "required": ["status"],
190
+ "properties": {
191
+ "status": {
192
+ "type": "string",
193
+ "enum": ["ok"]
194
+ }
195
+ }
196
+ }
197
+ }
198
+ }
199
+ }
200
+ }
201
+ }
202
+ }
203
+ },
204
+ "components": {
205
+ "securitySchemes": {
206
+ "BearerAuth": {
207
+ "type": "http",
208
+ "scheme": "bearer",
209
+ "bearerFormat": "JWT"
210
+ }
211
+ },
212
+ "schemas": {
213
+ "ProjectStatus": {
214
+ "type": "string",
215
+ "enum": ["active", "archived"],
216
+ "description": "Project lifecycle state: `active` projects appear in default lists; `archived` projects are retained for history."
217
+ },
218
+ "Project": {
219
+ "type": "object",
220
+ "required": ["id", "name", "status"],
221
+ "properties": {
222
+ "id": {
223
+ "type": "string",
224
+ "examples": ["proj_123"]
225
+ },
226
+ "name": {
227
+ "type": "string",
228
+ "minLength": 1
229
+ },
230
+ "description": {
231
+ "type": ["string", "null"],
232
+ "description": "Optional public summary. Markdown such as **bold text** and `inline code` is allowed in OpenAPI descriptions."
233
+ },
234
+ "status": {
235
+ "$ref": "#/components/schemas/ProjectStatus"
236
+ },
237
+ "createdAt": {
238
+ "type": "string",
239
+ "format": "date-time"
240
+ }
241
+ }
242
+ },
243
+ "ProjectCreate": {
244
+ "type": "object",
245
+ "required": ["name"],
246
+ "properties": {
247
+ "name": {
248
+ "type": "string",
249
+ "minLength": 1,
250
+ "maxLength": 120
251
+ },
252
+ "description": {
253
+ "type": "string",
254
+ "maxLength": 500
255
+ }
256
+ }
257
+ },
258
+ "ProjectList": {
259
+ "type": "object",
260
+ "required": ["data"],
261
+ "properties": {
262
+ "data": {
263
+ "type": "array",
264
+ "items": {
265
+ "$ref": "#/components/schemas/Project"
266
+ }
267
+ },
268
+ "nextCursor": {
269
+ "type": ["string", "null"]
270
+ }
271
+ }
272
+ },
273
+ "Error": {
274
+ "type": "object",
275
+ "required": ["code", "message"],
276
+ "properties": {
277
+ "code": {
278
+ "type": "string"
279
+ },
280
+ "message": {
281
+ "type": "string"
282
+ }
283
+ }
284
+ }
285
+ },
286
+ "responses": {
287
+ "BadRequest": {
288
+ "description": "Invalid request.\n\nCheck the response `code` and `message` before retrying.",
289
+ "content": {
290
+ "application/json": {
291
+ "schema": {
292
+ "$ref": "#/components/schemas/Error"
293
+ }
294
+ }
295
+ }
296
+ },
297
+ "Unauthorized": {
298
+ "description": "Missing or invalid API token.",
299
+ "content": {
300
+ "application/json": {
301
+ "schema": {
302
+ "$ref": "#/components/schemas/Error"
303
+ }
304
+ }
305
+ }
306
+ },
307
+ "NotFound": {
308
+ "description": "Resource was not found.",
309
+ "content": {
310
+ "application/json": {
311
+ "schema": {
312
+ "$ref": "#/components/schemas/Error"
313
+ }
314
+ }
315
+ }
316
+ }
317
+ }
318
+ }
319
+ }
@@ -0,0 +1,20 @@
1
+ ---
2
+ title: 更新日志
3
+ description: 记录重要的产品和文档变更。
4
+ ---
5
+
6
+ # 更新日志
7
+
8
+ 使用此页面发布重要的产品、API 和文档更新。
9
+
10
+ ## 2026-06-20
11
+
12
+ ### 新增
13
+
14
+ - 初始 Clarify 文档模板。
15
+ - 基础 MDX 写作示例。
16
+ - OpenAPI 参考示例。
17
+
18
+ ### 变更
19
+
20
+ - 将这些条目替换为你的真实发布说明。
@@ -0,0 +1,78 @@
1
+ ---
2
+ title: 导航
3
+ description: 配置标签页、侧边栏分组、页面链接、OpenAPI 条目、导航栏链接和页脚链接。
4
+ ---
5
+
6
+ # 导航
7
+
8
+ Clarify 的导航在 `clarify.ts` 中配置。这个完整模板使用显式标签页,让你可以看清每一部分如何组合在一起。
9
+
10
+ ## 标签页和侧边栏分组
11
+
12
+ ```ts title="clarify.ts"
13
+ export default defineConfig({
14
+ tabs: [
15
+ {
16
+ tab: 'Docs',
17
+ icon: 'BookOpen',
18
+ pages: [
19
+ {
20
+ group: 'Start here',
21
+ icon: 'Rocket',
22
+ pages: [
23
+ { page: 'index', title: 'Overview', icon: 'Sparkles' },
24
+ { page: 'guides/writing-content', title: 'Writing content', icon: 'PenLine' },
25
+ ],
26
+ },
27
+ ],
28
+ },
29
+ ],
30
+ })
31
+ ```
32
+
33
+ ## 文件树模式
34
+
35
+ 对于规模较小的文档,可以使用 `FileTree`,让 Clarify 从文件结构自动生成导航。
36
+
37
+ ```ts title="clarify.ts"
38
+ export default defineConfig({
39
+ tabs: [
40
+ {
41
+ tab: 'Docs',
42
+ pages: 'FileTree',
43
+ },
44
+ ],
45
+ })
46
+ ```
47
+
48
+ ## 导航栏和页脚
49
+
50
+ ```ts title="clarify.ts"
51
+ export default defineConfig({
52
+ navbar: {
53
+ links: [
54
+ { label: 'Guides', href: '/guides/writing-content' },
55
+ { label: 'GitHub', href: 'https://github.com/taicode-labs/clarify', external: true },
56
+ ],
57
+ },
58
+ footer: {
59
+ copyright: '© 2026 Your Company.',
60
+ links: [{ label: 'Configuration', href: '/reference/configuration' }],
61
+ socials: { GitHub: 'https://github.com/taicode-labs/clarify' },
62
+ },
63
+ })
64
+ ```
65
+
66
+ ## OpenAPI 条目
67
+
68
+ 在导航中使用 `openapi` 而不是 `page`,即可添加 OpenAPI 文件。
69
+
70
+ ```ts title="clarify.ts"
71
+ {
72
+ openapi: 'api.openapi.json',
73
+ title: 'OpenAPI reference',
74
+ icon: 'FileJson2',
75
+ }
76
+ ```
77
+
78
+ 这会把 `{{contentDir}}/api.openapi.json` 渲染为 `/api` 下的完整参考文档。
@@ -0,0 +1,65 @@
1
+ ---
2
+ title: MDX 组件
3
+ description: Clarify 页面中可用的内置 MDX 组件示例。
4
+ ---
5
+
6
+ # MDX 组件
7
+
8
+ 本页展示 Clarify MDX 页面中可用的内置组件。
9
+
10
+ ## 卡片
11
+
12
+ <CardGroup cols={2}>
13
+ <Card title="链接卡片" icon="ArrowRight" href="/guides/writing-content">
14
+ 卡片可以链接到站内或站外目标。
15
+ </Card>
16
+ <Card title="静态卡片" icon="Box">
17
+ 卡片也可以作为静态功能摘要使用。
18
+ </Card>
19
+ </CardGroup>
20
+
21
+ ## Callout 和 Note
22
+
23
+ <Callout title="Callout">
24
+ 用于展示需要从正文中突出显示的重要说明。
25
+ </Callout>
26
+
27
+ <Note>
28
+ Note 适合承载轻量的上下文提示。
29
+ </Note>
30
+
31
+ ## 属性
32
+
33
+ <Properties>
34
+ <Property name="children" type="ReactNode">
35
+ 组件内部渲染的内容。
36
+ </Property>
37
+ <Property name="title" type="string">
38
+ 卡片、提示或标题使用的短标签。
39
+ </Property>
40
+ <Property name="icon" type="string">
41
+ 图标名称会从 Lucide icons 中解析。
42
+ </Property>
43
+ </Properties>
44
+
45
+ ## 代码
46
+
47
+ ```ts title="typed-example.ts"
48
+ type Feature = {
49
+ name: string
50
+ stable: boolean
51
+ }
52
+
53
+ export const feature: Feature = {
54
+ name: 'Clarify starter',
55
+ stable: true,
56
+ }
57
+ ```
58
+
59
+ ## OpenAPI 端点
60
+
61
+ 使用 `OpenApiOperation` 可以从站点的 OpenAPI spec 中嵌入单个操作:
62
+
63
+ <OpenApiOperation specPath="/api" path="/v1/projects" method="get" />
64
+
65
+ <OpenApiOperation specPath="/api" path="/v1/projects" method="post" />
@@ -0,0 +1,77 @@
1
+ ---
2
+ title: 配置
3
+ description: 了解此模板使用的 Clarify 配置字段。
4
+ ---
5
+
6
+ # 配置
7
+
8
+ `clarify.ts` 控制站点外壳、主题、导航和 OpenAPI 条目。
9
+
10
+ <Properties>
11
+ <Property name="title" type="string">
12
+ 产品或文档站点名称。
13
+ </Property>
14
+ <Property name="description" type="string">
15
+ 站点默认 SEO 描述。
16
+ </Property>
17
+ <Property name="logo" type="string | { light?: string; dark?: string }">
18
+ `public` 中的 logo 路径,或一个绝对 URL。
19
+ </Property>
20
+ <Property name="favicon" type="string | { light?: string; dark?: string }">
21
+ 浏览器 favicon 路径。
22
+ </Property>
23
+ <Property name="banner" type="{ content: string; dismissible?: boolean }">
24
+ 显示在站点顶部的可选公告横幅。
25
+ </Property>
26
+ <Property name="theme" type="ClarifyThemeConfig">
27
+ 主题预设、颜色 token、圆角 token 和布局设置。
28
+ </Property>
29
+ <Property name="navbar" type="{ links?: ClarifyNavbarLink[] }">
30
+ 顶部导航链接。站外链接请使用 `external: true`。
31
+ </Property>
32
+ <Property name="footer" type="ClarifyFooterConfig">
33
+ 页脚链接、社交链接、版权文本,或自定义页脚组件路径。Clarify 品牌标识会始终保留在右下角。
34
+ </Property>
35
+ <Property name="tabs" type="ClarifyTabsConfig">
36
+ 顶级导航标签页和侧边栏页面。
37
+ </Property>
38
+ <Property name="i18n" type="ClarifyI18nConfig">
39
+ 多语言站点的可选 locale 配置。
40
+ </Property>
41
+ </Properties>
42
+
43
+ ## 主题示例
44
+
45
+ ```ts title="clarify.ts"
46
+ theme: {
47
+ preset: 'default',
48
+ tokens: {
49
+ colors: {
50
+ primary: '#2563eb',
51
+ accent: '#7c3aed',
52
+ background: '#ffffff',
53
+ foreground: '#111827',
54
+ muted: { light: '#64748b', dark: '#a1a1aa' },
55
+ },
56
+ radius: {
57
+ lg: '0.75rem',
58
+ xl: '1rem',
59
+ },
60
+ },
61
+ }
62
+ ```
63
+
64
+ ## i18n 示例
65
+
66
+ ```ts title="clarify.ts"
67
+ i18n: {
68
+ defaultLocale: 'en-US',
69
+ missing: 'fallback',
70
+ locales: [
71
+ { code: 'en-US', label: 'English', dir: 'ltr' },
72
+ { code: 'zh-CN', label: '简体中文', dir: 'ltr' },
73
+ ],
74
+ }
75
+ ```
76
+
77
+ 启用 i18n 后,请把内容放在 locale 目录下,例如 `{{contentDir}}/en-US/index.mdx` 和 `{{contentDir}}/zh-CN/index.mdx`。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clarify-labs/templates",
3
- "version": "0.8.2",
3
+ "version": "0.9.0",
4
4
  "license": "AGPL-3.0-only",
5
5
  "type": "module",
6
6
  "repository": {