hd-garden 0.8.0 → 0.8.2

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.
Files changed (187) hide show
  1. package/.agents/skills/garden-ui/SKILL.md +2 -2
  2. package/.env.en.example +67 -0
  3. package/README.en.md +2 -2
  4. package/README.md +2 -2
  5. package/app/a2/[slug]/page.tsx +4 -3
  6. package/app/a2/page.tsx +4 -3
  7. package/app/about/page.tsx +8 -9
  8. package/app/admin/page.tsx +7 -6
  9. package/app/admin/preview/[...path]/page.tsx +2 -1
  10. package/app/admin/ui/blocks/page.tsx +2 -1
  11. package/app/admin/ui/catalog/page.tsx +2 -1
  12. package/app/admin/ui/evals/page.tsx +2 -1
  13. package/app/admin/ui/page.tsx +2 -1
  14. package/app/blog/[...path]/page.tsx +7 -6
  15. package/app/blog/page.tsx +4 -2
  16. package/app/columns/[column]/[...path]/page.tsx +8 -7
  17. package/app/columns/page.tsx +12 -8
  18. package/app/components/AdminUiShell.tsx +4 -3
  19. package/app/components/ArticleMeasure.tsx +6 -3
  20. package/app/components/ArticleReferences.tsx +4 -1
  21. package/app/components/ArticleTags.tsx +3 -2
  22. package/app/components/BlogArchive.tsx +20 -16
  23. package/app/components/Comments.tsx +16 -10
  24. package/app/components/ContentEmptyState.tsx +29 -28
  25. package/app/components/ExternalEmbed.tsx +15 -14
  26. package/app/components/GardenContentGuide.tsx +10 -2
  27. package/app/components/GardenDocsNav.tsx +4 -2
  28. package/app/components/GiscusComments.tsx +2 -1
  29. package/app/components/GithubLiveOverview.tsx +10 -8
  30. package/app/components/GithubProfile.tsx +31 -21
  31. package/app/components/HandbookLangSwitch.tsx +8 -4
  32. package/app/components/HandbookView.tsx +92 -9
  33. package/app/components/MarkdownArticle.tsx +31 -7
  34. package/app/components/MermaidDiagram.tsx +4 -3
  35. package/app/components/SiteChrome.tsx +3 -3
  36. package/app/components/SiteFooter.tsx +1 -1
  37. package/app/components/SiteHeader.tsx +13 -4
  38. package/app/components/ThoughtCard.tsx +16 -14
  39. package/app/components/UiBlock.tsx +3 -2
  40. package/app/components/Webmentions.tsx +11 -11
  41. package/app/components/WidgetChart.tsx +8 -6
  42. package/app/components/garden/FilePreview.tsx +2 -2
  43. package/app/components/garden/GardenBlock.tsx +7 -0
  44. package/app/components/garden/GardenFile.tsx +2 -2
  45. package/app/components/garden/RefDemo.tsx +62 -0
  46. package/app/components/garden/blocks.tsx +56 -8
  47. package/app/components/garden/patterns.tsx +497 -0
  48. package/app/garden/[...slug]/page.tsx +3 -2
  49. package/app/garden/en/page.tsx +7 -7
  50. package/app/garden/page.tsx +3 -2
  51. package/app/globals.css +49 -1
  52. package/app/lib/a2-meta.ts +26 -3
  53. package/app/lib/content.ts +2 -2
  54. package/app/lib/garden-docs-meta.ts +24 -0
  55. package/app/lib/github-id.mjs +8 -0
  56. package/app/lib/handbook-switch.mjs +12 -0
  57. package/app/lib/i18n.ts +401 -2
  58. package/app/lib/rehype-field-tables.mjs +47 -0
  59. package/app/lib/remark-a2.mjs +18 -8
  60. package/app/lib/remark-link-card.mjs +22 -0
  61. package/app/lib/remark-ref-demos.mjs +42 -0
  62. package/app/lib/tag-filter.ts +9 -2
  63. package/app/not-found.tsx +32 -4
  64. package/app/page.tsx +17 -14
  65. package/app/rss.xml/route.ts +2 -1
  66. package/app/styles/a2.css +338 -0
  67. package/app/styles/shell.css +15 -2
  68. package/app/tags/page.tsx +7 -5
  69. package/app/thoughts/[slug]/page.tsx +2 -1
  70. package/app/thoughts/page/[n]/page.tsx +1 -1
  71. package/app/thoughts/page.tsx +2 -1
  72. package/app/ui-parity/page.tsx +38 -22
  73. package/bin/garden.mjs +129 -19
  74. package/docs/handbook/ai-writing.md +2 -2
  75. package/docs/handbook/assets/reading-layout-en.svg +26 -0
  76. package/docs/handbook/components/card.md +43 -22
  77. package/docs/handbook/components/chart.md +10 -26
  78. package/docs/handbook/components/choice.md +42 -0
  79. package/docs/handbook/components/compare.md +32 -17
  80. package/docs/handbook/components/figure.md +33 -46
  81. package/docs/handbook/components/file.md +10 -15
  82. package/docs/handbook/components/html.md +10 -30
  83. package/docs/handbook/components/interactive.md +9 -35
  84. package/docs/handbook/components/list.md +65 -0
  85. package/docs/handbook/components/relations.md +95 -0
  86. package/docs/handbook/components/stat.md +10 -28
  87. package/docs/handbook/components/timeline.md +13 -28
  88. package/docs/handbook/components.md +210 -19
  89. package/docs/handbook/config.md +5 -3
  90. package/docs/handbook/deploy.md +1 -1
  91. package/docs/handbook/design.md +20 -12
  92. package/docs/handbook/en/ai-writing.md +2 -2
  93. package/docs/handbook/en/components/card.md +42 -21
  94. package/docs/handbook/en/components/chart.md +10 -26
  95. package/docs/handbook/en/components/choice.md +42 -0
  96. package/docs/handbook/en/components/compare.md +30 -15
  97. package/docs/handbook/en/components/figure.md +29 -42
  98. package/docs/handbook/en/components/file.md +9 -14
  99. package/docs/handbook/en/components/html.md +9 -29
  100. package/docs/handbook/en/components/interactive.md +8 -34
  101. package/docs/handbook/en/components/list.md +65 -0
  102. package/docs/handbook/en/components/relations.md +95 -0
  103. package/docs/handbook/en/components/stat.md +9 -27
  104. package/docs/handbook/en/components/timeline.md +9 -24
  105. package/docs/handbook/en/components.md +211 -19
  106. package/docs/handbook/en/config.md +32 -30
  107. package/docs/handbook/en/deploy.md +12 -12
  108. package/docs/handbook/en/design.md +19 -12
  109. package/docs/handbook/en/index.md +2 -2
  110. package/docs/handbook/en/reference/card.md +85 -0
  111. package/docs/handbook/en/reference/chart.md +68 -0
  112. package/docs/handbook/en/reference/choice.md +69 -0
  113. package/docs/handbook/en/reference/compare.md +59 -0
  114. package/docs/handbook/en/reference/figure.md +84 -0
  115. package/docs/handbook/en/reference/file/checklist.md +17 -0
  116. package/docs/handbook/en/reference/file.md +50 -0
  117. package/docs/handbook/en/reference/html.md +62 -0
  118. package/docs/handbook/en/reference/interactive.md +71 -0
  119. package/docs/handbook/en/reference/list.md +72 -0
  120. package/docs/handbook/en/reference/relations.md +113 -0
  121. package/docs/handbook/en/reference/stat.md +60 -0
  122. package/docs/handbook/en/reference/timeline.md +56 -0
  123. package/docs/handbook/en/reference.md +26 -0
  124. package/docs/handbook/en/start.md +2 -2
  125. package/docs/handbook/en/workflow.md +6 -5
  126. package/docs/handbook/en/writing.md +3 -2
  127. package/docs/handbook/index.md +1 -1
  128. package/docs/handbook/reference/card.md +85 -0
  129. package/docs/handbook/reference/chart.md +68 -0
  130. package/docs/handbook/reference/choice.md +69 -0
  131. package/docs/handbook/reference/compare.md +59 -0
  132. package/docs/handbook/reference/figure.md +84 -0
  133. package/docs/handbook/reference/file/checklist.md +17 -0
  134. package/docs/handbook/reference/file.md +50 -0
  135. package/docs/handbook/reference/html.md +62 -0
  136. package/docs/handbook/reference/interactive.md +71 -0
  137. package/docs/handbook/reference/list.md +72 -0
  138. package/docs/handbook/reference/relations.md +113 -0
  139. package/docs/handbook/reference/stat.md +60 -0
  140. package/docs/handbook/reference/timeline.md +56 -0
  141. package/docs/handbook/reference.md +26 -0
  142. package/docs/handbook/start.md +1 -1
  143. package/docs/handbook/workflow.md +6 -5
  144. package/docs/handbook/writing.md +3 -2
  145. package/next.config.ts +6 -0
  146. package/package.json +2 -1
  147. package/public/images/garden/ref-card-book.svg +1 -0
  148. package/public/images/garden/ref-card-lamp.svg +1 -0
  149. package/scripts/build-content.mjs +37 -16
  150. package/scripts/favicon-ico.mjs +9 -6
  151. package/scripts/file-preview.mjs +10 -7
  152. package/scripts/handbook-allowlist.mjs +18 -0
  153. package/scripts/handbook-facts.mjs +305 -11
  154. package/scripts/link-assets.mjs +7 -0
  155. package/scripts/new-post.mjs +18 -9
  156. package/scripts/prepare-pages-output.mjs +30 -18
  157. package/scripts/redirects.mjs +17 -6
  158. package/templates/garden-blocks.md +67 -0
  159. package/templates/garden-snippets.plist +61 -0
  160. package/templates/site/Makefile.en +45 -0
  161. package/templates/site/README.en.md +15 -0
  162. package/templates/site/site.config.en.yaml +55 -0
  163. package/templates/skills-en/garden-interactive-chart/SKILL.md +84 -0
  164. package/templates/skills-en/garden-interactive-chart/references/shell.html +49 -0
  165. package/templates/skills-en/garden-interactive-chart/references/style.md +61 -0
  166. package/templates/skills-en/garden-post-review/SKILL.md +63 -0
  167. package/templates/skills-en/garden-ui/SKILL.md +118 -0
  168. package/templates/workflows/pages.en.yml +195 -0
  169. package/templates/workflows/pages.yml +195 -0
  170. package/ui/garden/catalog.mjs +205 -4
  171. package/ui/garden/check.mjs +6 -0
  172. package/ui/garden/file-block.mjs +8 -7
  173. package/ui/garden/html-lang.mjs +73 -1
  174. package/ui/garden/markdown-links.mjs +7 -4
  175. package/ui/garden/parse.mjs +45 -0
  176. package/ui/garden/relations.mjs +252 -0
  177. package/ui/garden/search-index.mjs +6 -4
  178. package/ui/garden/source-icon.mjs +54 -0
  179. package/ui/parity-fixtures.mjs +77 -0
  180. package/ui/preview/dist/garden-ui.esm.js +41 -4
  181. package/ui/preview/dist/garden-ui.iife.js +41 -4
  182. package/ui/prompt/rules.md +28 -1
  183. package/ui/react/components/chart.tsx +1 -1
  184. package/ui/react/components/display.tsx +1 -1
  185. package/ui/react/lang.tsx +4 -0
  186. package/ui/react/parity.tsx +8 -6
  187. package/worker/index.ts +8 -2
@@ -1,72 +1,59 @@
1
1
  ---
2
2
  title: 分区结构图(figure)
3
3
  navTitle: 分区结构图
4
- description: 为 SVG 结构图加上分区高亮按钮,点击切换对应区域与文字说明。
4
+ description: 一张带切换按钮的结构图,点到哪个部分就高亮并显示对应说明。
5
5
  section: components
6
6
  order: 36
7
7
  badge: figure
8
8
  ---
9
9
 
10
- 在 `garden` 想法块里写一句「用 `figure` 画一张静态发布流程的结构图,点到哪一步就高亮并显示那一步的说明」,Agent 会按 `garden-ui` skill 生成下面的 `garden figure`(手写格式附后)。
11
-
12
10
  ```garden figure
13
11
  caption: 点击上方按钮切换高亮各步骤
14
12
  svg: |
15
- <svg viewBox="0 0 680 110" xmlns="http://www.w3.org/2000/svg" font-family="var(--sans)">
16
- <rect data-p="sync" x="12" y="18" width="196" height="74" rx="10" fill="var(--card)" stroke="var(--rule-strong)" stroke-width="1.5"/>
17
- <text data-p="sync" x="110" y="50" text-anchor="middle" font-size="14" font-weight="600" fill="var(--ink)">1. garden sync</text>
18
- <text data-p="sync" x="110" y="72" text-anchor="middle" font-size="12" fill="var(--muted)">解析 Markdown 与图片尺寸</text>
19
- <path d="M214 55 H236" stroke="var(--muted)" stroke-width="1.5"/>
20
- <rect data-p="build" x="242" y="18" width="196" height="74" rx="10" fill="var(--card)" stroke="var(--rule-strong)" stroke-width="1.5"/>
21
- <text data-p="build" x="340" y="50" text-anchor="middle" font-size="14" font-weight="600" fill="var(--ink)">2. garden build</text>
22
- <text data-p="build" x="340" y="72" text-anchor="middle" font-size="12" fill="var(--muted)">生成静态页面与搜索索引</text>
23
- <path d="M444 55 H466" stroke="var(--muted)" stroke-width="1.5"/>
24
- <rect data-p="validate" x="472" y="18" width="196" height="74" rx="10" fill="var(--card)" stroke="var(--rule-strong)" stroke-width="1.5"/>
25
- <text data-p="validate" x="570" y="50" text-anchor="middle" font-size="14" font-weight="600" fill="var(--ink)">3. pages:validate</text>
26
- <text data-p="validate" x="570" y="72" text-anchor="middle" font-size="12" fill="var(--muted)">检查 index.html 与禁用文件</text>
13
+ <svg viewBox="0 0 560 194" xmlns="http://www.w3.org/2000/svg" font-family="var(--sans)" style="max-width: 380px; margin-inline: auto">
14
+ <rect data-p="sync" x="2" y="4" width="180" height="186" rx="16" fill="var(--card)" stroke="var(--rule-strong)" stroke-width="2.5"/>
15
+ <text data-p="sync" x="92" y="42" text-anchor="middle" font-size="24" font-weight="600" fill="var(--ink)">1. garden</text>
16
+ <text data-p="sync" x="92" y="72" text-anchor="middle" font-size="24" font-weight="600" fill="var(--ink)">sync</text>
17
+ <text data-p="sync" x="92" y="108" text-anchor="middle" font-size="24" fill="var(--muted)">解析</text>
18
+ <text data-p="sync" x="92" y="137" text-anchor="middle" font-size="24" fill="var(--muted)">Markdown 与</text>
19
+ <text data-p="sync" x="92" y="166" text-anchor="middle" font-size="24" fill="var(--muted)">图片尺寸</text>
20
+ <path d="M183.5 97 H188.5" stroke="var(--muted)" stroke-width="2.5"/>
21
+ <rect data-p="build" x="190" y="4" width="180" height="186" rx="16" fill="var(--card)" stroke="var(--rule-strong)" stroke-width="2.5"/>
22
+ <text data-p="build" x="280" y="42" text-anchor="middle" font-size="24" font-weight="600" fill="var(--ink)">2. garden</text>
23
+ <text data-p="build" x="280" y="72" text-anchor="middle" font-size="24" font-weight="600" fill="var(--ink)">build</text>
24
+ <text data-p="build" x="280" y="108" text-anchor="middle" font-size="24" fill="var(--muted)">生成静态页面</text>
25
+ <text data-p="build" x="280" y="137" text-anchor="middle" font-size="24" fill="var(--muted)">与搜索索引</text>
26
+ <path d="M371.5 97 H376.5" stroke="var(--muted)" stroke-width="2.5"/>
27
+ <rect data-p="validate" x="378" y="4" width="180" height="186" rx="16" fill="var(--card)" stroke="var(--rule-strong)" stroke-width="2.5"/>
28
+ <text data-p="validate" x="468" y="42" text-anchor="middle" font-size="24" font-weight="600" fill="var(--ink)">3. pages:</text>
29
+ <text data-p="validate" x="468" y="72" text-anchor="middle" font-size="24" font-weight="600" fill="var(--ink)">validate</text>
30
+ <text data-p="validate" x="468" y="108" text-anchor="middle" font-size="24" fill="var(--muted)">检查</text>
31
+ <text data-p="validate" x="468" y="137" text-anchor="middle" font-size="24" fill="var(--muted)">index.html 与</text>
32
+ <text data-p="validate" x="468" y="166" text-anchor="middle" font-size="24" fill="var(--muted)">禁用文件</text>
27
33
  </svg>
28
34
  parts:
29
35
  - id: sync
30
36
  label: 1. 同步内容
31
- text: 扫描 `content/` 与 `docs/handbook/`,复制随文附件并生成 `.garden/generated-content.ts`。
37
+ text: 扫描正文与随文附件,生成站点内容数据。
32
38
  - id: build
33
39
  label: 2. 构建页面
34
- text: 根据 `STATIC_EXPORT=1` 预渲染所有页面路由,输出 RSS、sitemap 与全文搜索文件。
40
+ text: 预渲染所有页面路由,输出 RSS、sitemap 与全文搜索文件。
35
41
  - id: validate
36
42
  label: 3. 导出校验
37
- text: 运行 pages:validate,确认导出目录里有 `index.html`,且没有 `.env`、源码目录、`.map` 或 `.md` 文件和软链接。
43
+ text: 确认导出目录里有 `index.html`,且没有混入源码或配置文件。
38
44
  ```
39
45
 
46
+ - **什么时候用**:一张架构图或数据流图,读者点一个区域就能看清那一部分做什么。
47
+ - **什么时候不用**:不需要分区点击说明的普通流程图或截图,直接贴图片或画 Mermaid 图。
48
+
49
+ 可以这样对 AI 说:
50
+
40
51
  ````markdown
41
- ```garden figure
42
- caption: 点击上方按钮切换高亮各步骤
43
- svg: |
44
- <svg viewBox="0 0 680 110" xmlns="http://www.w3.org/2000/svg" font-family="var(--sans)">
45
- <rect data-p="sync" x="12" y="18" width="196" height="74" rx="10" fill="var(--card)" stroke="var(--rule-strong)" stroke-width="1.5"/>
46
- <text data-p="sync" x="110" y="50" text-anchor="middle" font-size="14" font-weight="600" fill="var(--ink)">1. garden sync</text>
47
- <text data-p="sync" x="110" y="72" text-anchor="middle" font-size="12" fill="var(--muted)">解析 Markdown 与图片尺寸</text>
48
- <rect data-p="build" x="242" y="18" width="196" height="74" rx="10" fill="var(--card)" stroke="var(--rule-strong)" stroke-width="1.5"/>
49
- <rect data-p="validate" x="472" y="18" width="196" height="74" rx="10" fill="var(--card)" stroke="var(--rule-strong)" stroke-width="1.5"/>
50
- </svg>
51
- parts:
52
- - id: sync
53
- label: 1. 同步内容
54
- text: 扫描 `content/` 与 `docs/handbook/`,复制随文附件并生成 `.garden/generated-content.ts`。
55
- - id: build
56
- label: 2. 构建页面
57
- text: 根据 `STATIC_EXPORT=1` 预渲染所有页面路由,输出 RSS、sitemap 与全文搜索文件。
58
- - id: validate
59
- label: 3. 导出校验
60
- text: 运行 pages:validate,确认导出目录里有 `index.html`,且没有 `.env`、源码目录、`.map` 或 `.md` 文件和软链接。
52
+ ```garden
53
+ 画一张静态发布流程的结构图,点到哪一步就高亮那一步并显示说明。
61
54
  ```
62
55
  ````
63
56
 
64
- - **用**:展示模块架构或数据流向,需要读者点击按钮逐块查看对应区域职责时(SVG 内优先使用 `var(--well)`、`var(--ink)`、`var(--muted)` 等主题变量以兼容深色模式)。
65
- - **别用**:不需要分区点击说明的普通流程图或截图,直接用标准 Markdown 图片或 `mermaid` 代码块。
57
+ ## 字段说明
66
58
 
67
- | 字段 | 必填 | 类型 | 说明 |
68
- | :--- | :--- | :--- | :--- |
69
- | `svg` | 与 `image` 二选一 | 多行字符串 | 内联 `<svg>` 源码;在需要高亮的分组上标注 `data-p="<id>"` |
70
- | `image` | 与 `svg` 二选一 | 路径字符串 | 普通图片路径(可写成 `{ src, alt }`) |
71
- | `parts` | 否 | `{ id, label, text }[]` | 顶部分区切换按钮及底部对应的说明文字 |
72
- | `caption` | 否 | 字符串 | 图框下方的图注说明 |
59
+ 全部字段、默认值、取值限制和报错代码见 [组件参考 · figure](/garden/reference/figure)。
@@ -1,34 +1,29 @@
1
1
  ---
2
2
  title: 文件下载与预览(file)
3
3
  navTitle: 文件下载与预览
4
- description: 提供单个或一组附件下载,自动显示格式与大小,支持在页内展开预览。
4
+ description: 给读者提供一份或一组可下载的文件,支持在当前页展开预览。
5
5
  section: components
6
6
  order: 39
7
7
  badge: file
8
8
  ---
9
9
 
10
- 在 `garden` 想法块里写一句「用 `file` 给读者一份可以下载和页内预览的发布前检查清单」,Agent 会按 `garden-ui` skill 生成下面的 `garden file`(手写格式附后)。
11
-
12
10
  ```garden file
13
11
  src: ./file/checklist.md
14
12
  title: 发布前检查清单
15
13
  note: Markdown 附件示例,可点击「预览」在当前页展开阅读,或直接下载原文件
16
14
  ```
17
15
 
16
+ - **什么时候用**:随文章提供配置文件、PDF、压缩包或 Markdown 附件供读者下载与页内预览。
17
+ - **什么时候不用**:只是引用一个外部网页时用[知识卡片](/garden/components/card);正文里本来就要直接展示的配图直接贴图片。
18
+
19
+ 可以这样对 AI 说:
20
+
18
21
  ````markdown
19
- ```garden file
20
- src: ./file/checklist.md
21
- title: 发布前检查清单
22
- note: Markdown 附件示例,可点击「预览」在当前页展开阅读,或直接下载原文件
22
+ ```garden
23
+ 把同目录下的 checklist.md 放成附件,让读者可以在页面里预览或下载。
23
24
  ```
24
25
  ````
25
26
 
26
- - **用**:随文章提供配置文件、数据表、PDF、图片或 Markdown 附件供读者下载与页内预览时(多文件可用 `files` 数组)。
27
- - **别用**:正文里本来就要直接展示的配图用标准 Markdown 图片语法 `![]()`,不要放进 `file` 组件。
27
+ ## 字段说明
28
28
 
29
- | 字段 | 必填 | 类型 | 说明 |
30
- | :--- | :--- | :--- | :--- |
31
- | `src` | 单文件必填 | 路径或完整链接 | 相对当前 Markdown 文件的本地路径(不得越出 `content/`)、`/public` 路径或 `https://` 链接 |
32
- | `title` | 否 | 字符串 | 显示的文件标题(默认取文件名;多文件模式下作为分组标题) |
33
- | `note` | 否 | 字符串 | 文件名下方的简短说明 |
34
- | `files` | 多文件必填 | `{ src, title?, note? }[]` | 一次列出多个文件时使用(与顶层 `src` 二选一) |
29
+ 全部字段、默认值、取值限制和报错代码见 [组件参考 · file](/garden/reference/file)。
@@ -1,17 +1,14 @@
1
1
  ---
2
2
  title: 嵌入网页片段(html)
3
3
  navTitle: 嵌入网页片段
4
- description: 在沙盒 iframe 中运行独立的 HTML、CSS 与 JavaScript 演示片段。
4
+ description: 在沙盒中运行一段独立的网页小工具、画布动画或演示。
5
5
  section: components
6
6
  order: 37
7
7
  badge: html
8
8
  ---
9
9
 
10
- 在 `garden` 想法块里写一句「用 `html` 嵌一个小工具,输入文字就实时算出字符数」,Agent 会按 `garden-ui` skill 生成下面的 `garden html`(手写格式附后)。
11
-
12
10
  ```garden html
13
11
  title: 字符长度与预计阅读耗时小工具
14
- height: 156
15
12
  code: |
16
13
  <!doctype html>
17
14
  <html lang="zh-CN">
@@ -36,34 +33,17 @@ code: |
36
33
  </html>
37
34
  ```
38
35
 
36
+ - **什么时候用**:内置组件画不出来的画布动画、物理模拟或独立小工具。
37
+ - **什么时候不用**:只需要拖动滑杆算公式时用[可调公式与参数](/garden/components/interactive);静态图表或结构图优先用对应组件。
38
+
39
+ 可以这样对 AI 说:
40
+
39
41
  ````markdown
40
- ```garden html
41
- title: 字符长度与预计阅读耗时小工具
42
- height: 156
43
- code: |
44
- <!doctype html>
45
- <html lang="zh-CN">
46
- <head><meta charset="utf-8" /></head>
47
- <body>
48
- <input id="txt" value="把文章放在自己的 Git 仓库里,推送后自动构建。" />
49
- <div>当前字符数:<strong id="count">23</strong> 字</div>
50
- <script>
51
- const input = document.getElementById("txt");
52
- const count = document.getElementById("count");
53
- input.addEventListener("input", () => { count.textContent = String(input.value.length); });
54
- </script>
55
- </body>
56
- </html>
42
+ ```garden
43
+ 做一个网页小工具,让读者输入一句话就能实时看到字符数。
57
44
  ```
58
45
  ````
59
46
 
60
- - **用**:需要运行自定义 DOM 脚本、Canvas 绘图或独立 HTML 页面片段时(支持 `code` 内联或 `src` 引用文章同名目录下的 `.html` 文件)。
61
- - **别用**:只需要滑杆调参数算公式时用 [`interactive`](/garden/components/interactive);静态结构图用 [`figure`](/garden/components/figure)。
47
+ ## 字段说明
62
48
 
63
- | 字段 | 必填 | 类型 | 说明 |
64
- | :--- | :--- | :--- | :--- |
65
- | `src` | 与 `code` 二选一 | 相对路径字符串 | 引用与当前 Markdown 同目录(或同名子目录)下的 `.html` 文件 |
66
- | `code` | 与 `src` 二选一 | 多行字符串 | 直接内联编写的 HTML 源码(也可用别名 `html`) |
67
- | `title` | 建议 | 字符串 | 卡片顶部栏标题及 `iframe` 的无障碍标题 |
68
- | `height` | 否 | 数字 | 初始高度(像素,默认 `260`;加载后也会随内容高度自动调整) |
69
- | `caption` | 否 | 字符串 | 底部的图注说明 |
49
+ 全部字段、默认值、取值限制和报错代码见 [组件参考 · html](/garden/reference/html)。
@@ -1,14 +1,12 @@
1
1
  ---
2
2
  title: 可调公式与参数(interactive)
3
3
  navTitle: 可调公式与参数
4
- description: 提供滑杆或单选按钮,让读者调整变量并实时计算公式与图表结果。
4
+ description: 让读者拖动滑杆或切换选项,实时看到公式和图表的计算结果。
5
5
  section: components
6
6
  order: 38
7
7
  badge: interactive
8
8
  ---
9
9
 
10
- 在 `garden` 想法块里写一句「让读者拖动字数、阅读速度和配图数,看预计阅读时间怎么变」,Agent 会按 `garden-ui` skill 生成下面的 `garden interactive`(手写格式附后)。
11
-
12
10
  ```garden interactive #reading-time
13
11
  caption: 示例:按字数、阅读速度和配图数估算一篇文章的阅读时间。数字只用来演示组件,不是统计结果。
14
12
  ---
@@ -27,41 +25,17 @@ caption: 示例:按字数、阅读速度和配图数估算一篇文章的阅
27
25
  </Chart>
28
26
  ```
29
27
 
30
- ````markdown
31
- ```garden interactive #reading-time
32
- caption: 示例:按字数、阅读速度和配图数估算一篇文章的阅读时间。数字只用来演示组件,不是统计结果。
33
- ---
34
- <State words={6000} speed={400} images={8} />
35
- <Let textMinutes={round(words / speed)} />
36
- <Let imageMinutes={round(images * 12 / 60)} />
37
- <Let parts={[{ part: "正文", minutes: textMinutes }, { part: "配图", minutes: imageMinutes }]} />
28
+ - **什么时候用**:公式或结论随多个变量变化,读者自己拧一下参数比读干巴巴的数字更容易明白。
29
+ - **什么时候不用**:一次简单乘法就能算清(触发 `interactive-trivial`),或者只是把几段文字拆成步骤而没有任何状态与输入控件(触发 `steps-prose`)时,直接写在正文里。
38
30
 
39
- <Slider bind="words" label="正文字数" min={1000} max={20000} step={500} unit="字" />
40
- <Slider bind="speed" label="阅读速度" min={200} max={800} step={50} unit="字/分钟" />
41
- <Slider bind="images" label="配图数" min={0} max={30} step={1} unit="张" />
31
+ 可以这样对 AI 说:
42
32
 
43
- <Stat label="示例:预计阅读时间" value={textMinutes + imageMinutes} unit="分钟" hint="配图按每张 12 秒估算" />
44
- <Chart data={parts} x={part} yLabel="分钟">
45
- <Bar y={minutes} label="示例" />
46
- </Chart>
33
+ ````markdown
34
+ ```garden
35
+ 让读者拖动正文字数、阅读速度和配图数,看预计阅读时间怎么变。
47
36
  ```
48
37
  ````
49
38
 
50
- - **用**:解释带多个变量的数学关系、容量估算或参数权衡,需要读者拖动滑杆实时观察结果变化时。
51
- - **别用**:只有 `<Steps>` 而没有任何状态或输入控件,会报 `steps-prose` 错误;所有 `<Let>` 都只是一次乘法(形如 `a * b`),会报 `interactive-trivial` 错误。遇到这两种情况,改用普通段落。
52
-
53
- 分隔线 `---` 上方是块头,下方是标签。常用的写法:
54
-
55
- | 字段或标签 | 必填 | 说明 |
56
- | :--- | :--- | :--- |
57
- | `#reading-time` | 建议 | 写在围栏头,块的标识,只能用小写字母、数字和连字符 |
58
- | `caption` | 是 | 一句话说明这块交互想让读者看到什么 |
59
- | `intent` | 否 | 这块交互由哪句想法编译而来,写成文字 |
60
- | `expect` | 否 | 数组,每条写成 `{ given: {...}, 名字: 期望值 }`,检查时会按给定状态算一遍 |
61
- | `<State />` | 是 | 声明会变的量和默认值,例如 `<State words={6000} />` |
62
- | `<Let />` | 否 | 由别的量算出来的值,也可以写数据数组 |
63
- | `<Slider />` / `<Choice />` / `<Toggle />` | 是 | 输入控件,用 `bind` 绑定一个状态;`Slider` 必填 `label`、`min`、`max` |
64
- | `<Stat />` | 否 | 显示一个醒目的数字,必填 `label` 与 `value` |
65
- | `<Chart />` | 否 | 用 `sweep` 画函数曲线,或用 `data` 加 `<Bar>` / `<Line>` 画数据 |
39
+ ## 字段说明
66
40
 
67
- 全部标签和属性见 `npx garden ui catalog` 生成的组件目录。
41
+ 全部字段、默认值、取值限制和报错代码见 [组件参考 · interactive](/garden/reference/interactive)。
@@ -0,0 +1,65 @@
1
+ ---
2
+ title: 图标列表(list)
3
+ navTitle: 图标列表
4
+ description: 用线条图标配短句列出几条并列动作,或带小标题列出分步做法。
5
+ section: components
6
+ order: 41
7
+ badge: list
8
+ ---
9
+
10
+ ```garden list
11
+ items:
12
+ - icon: search
13
+ text: 搜索这个月的书名
14
+ - icon: eye
15
+ text: 看了 3 篇书评
16
+ - icon: heart
17
+ text: 收藏了活动页面
18
+ - icon: chat
19
+ text: 在群里问能不能只听不说
20
+ ```
21
+
22
+ - **什么时候用**:几条并列的行为、信号或做法,每条配一个线条图标;或者带小标题与分段说明的做法列表。
23
+ - **什么时候不用**:只是一组带编号的先后顺序时用普通有序列表;按时间演进的节点用[时间线](/garden/components/timeline)。
24
+
25
+ 可以这样对 AI 说:
26
+
27
+ ````markdown
28
+ ```garden
29
+ 把新成员报名前常做的四件事列成带图标的列表:搜书名、看书评、收藏页面、在群里问能不能只听不说。
30
+ ```
31
+ ````
32
+
33
+ ## 带小标题的分段步骤列表
34
+
35
+ 当任一条目包含 `title` 时,组件自动切换为带分隔线的步骤列表,`text` 可以写多段说明:
36
+
37
+ ```garden list
38
+ items:
39
+ - icon: flask
40
+ title: 实验一:一个月读一本是不是太多?
41
+ text:
42
+ - 前两次活动分别选一本中篇和一本长篇,记录每个人读完的比例。
43
+ - 读完比例明显下降时,下次改成只读前半本。
44
+ - icon: chat
45
+ title: 实验二:怎样让第一次来的人开口?
46
+ text:
47
+ - 一半活动先轮流说一句话,另一半直接自由讨论。
48
+ - 比较第一次来的人发言的次数。
49
+ - icon: bell
50
+ title: 实验三:提醒要提前几天发?
51
+ text:
52
+ - 分别在活动前三天和前一天发提醒,看到场人数有没有差别。
53
+ ```
54
+
55
+ 可以这样对 AI 说:
56
+
57
+ ````markdown
58
+ ```garden
59
+ 把这三个小实验列成带图标和小标题的步骤:确认阅读量、让新成员开口、测试提前几天发提醒。
60
+ ```
61
+ ````
62
+
63
+ ## 字段说明
64
+
65
+ 全部字段、默认值、取值限制和报错代码见 [组件参考 · list](/garden/reference/list)。
@@ -0,0 +1,95 @@
1
+ ---
2
+ title: 关系图(relations)
3
+ navTitle: 关系图
4
+ description: 把三到六个要素排成环或中心辐射结构,画出谁影响谁、哪些是双向的。
5
+ section: components
6
+ order: 40
7
+ badge: relations
8
+ ---
9
+
10
+ ```garden relations
11
+ items:
12
+ - title: 选书
13
+ text: 定下这个月读什么
14
+ - title: 共读
15
+ text: 每周读完约定的章节
16
+ - title: 讨论
17
+ text: 见面聊各自的看法
18
+ - title: 复盘
19
+ text: 记下下次要改的地方
20
+ links:
21
+ - from: 1
22
+ to: 2
23
+ - from: 2
24
+ to: 3
25
+ - from: 3
26
+ to: 4
27
+ - from: 4
28
+ to: 1
29
+ - from: 3
30
+ to: 1
31
+ style: dashed
32
+ label: 影响选书
33
+ - from: 2
34
+ to: 4
35
+ style: dashed
36
+ caption: 四个环节互相提供信息,而不是按固定顺序走一遍。
37
+ ```
38
+
39
+ - **什么时候用**:三到六个关键要素,读者需要看清谁影响谁、哪些是双向的;首尾相接的循环或单中心向外辐射的关系都用它。
40
+ - **什么时候不用**:要素更多、有条件分支时用 Mermaid 流程图;只走一遍的步骤用[图标列表](/garden/components/list)。
41
+
42
+ 可以这样对 AI 说:
43
+
44
+ ````markdown
45
+ ```garden
46
+ 把选书、共读、讨论、复盘这四个环节的循环关系画出来,再标出讨论影响选书、共读影响复盘。
47
+ ```
48
+ ````
49
+
50
+ ## 中心节点与外圈要素(`center`)
51
+
52
+ 当其中一个要素居中、其余要素围在外圈时,在 `items` 与 `links` 之间写 `center: <序号或标题>`(不会自动猜测中心节点;指定的要素放在正中,其余要素从正上方起顺时针均布在外圈):
53
+
54
+ ```garden relations
55
+ items:
56
+ - title: 组织者
57
+ text: 每月发一次通知
58
+ - title: 成员
59
+ text: 八到十个邻居
60
+ - title: 场地
61
+ text: 咖啡馆或图书馆
62
+ - title: 书单
63
+ text: 大家轮流提名
64
+ center: 组织者
65
+ links:
66
+ - from: 1
67
+ to: 2
68
+ label: 邀请
69
+ - from: 1
70
+ to: 3
71
+ label: 预约
72
+ - from: 1
73
+ to: 4
74
+ label: 汇总
75
+ - from: 2
76
+ to: 4
77
+ style: dashed
78
+ direction: both
79
+ label: 提名
80
+ caption: 组织者放在正中,连着外圈的其余三个;成员和书单互相影响。
81
+ ```
82
+
83
+ 可以这样对 AI 说:
84
+
85
+ ````markdown
86
+ ```garden
87
+ 把组织者放在正中间,外圈放成员、场地、书单:组织者分别邀请成员、预约场地、汇总书单,成员和书单之间双向提名。
88
+ ```
89
+ ````
90
+
91
+ 各要素按椭圆均布(不设 `center` 时从正上方 12 点钟方向起顺时针排列;设了 `center` 时中心节点居于正中,其余要素在外圈从正上方起顺时针均布),外圈相邻要素之间的连线向外轻弧弯曲,跨节点或连向中心的连线从中间直穿而过。
92
+
93
+ ## 字段说明
94
+
95
+ 全部字段、默认值、取值限制和报错代码见 [组件参考 · relations](/garden/reference/relations)。
@@ -1,14 +1,12 @@
1
1
  ---
2
2
  title: 数字指标(stat)
3
3
  navTitle: 数字指标
4
- description: 将 2~4 组关键数字、单位与简短说明并排展示。
4
+ description: 把 2~4 个关键数字、单位与一句说明并排摆出来。
5
5
  section: components
6
6
  order: 32
7
7
  badge: stat
8
8
  ---
9
9
 
10
- 在 `garden` 想法块里写一句「用 `stat` 列出正文列、宽图区、宽表区三个宽度上限」,Agent 会按 `garden-ui` skill 生成下面的 `garden stat`(手写格式附后)。
11
-
12
10
  ```garden stat
13
11
  items:
14
12
  - label: 正文列宽
@@ -25,33 +23,17 @@ items:
25
23
  caption: 左右各最多向外延伸 300px
26
24
  ```
27
25
 
26
+ - **什么时候用**:把分散在段落里的两到四个关键数字、阈值或规格并排展示。
27
+ - **什么时候不用**:只有一个数字时留在正文句子里;数字会随读者选择变化时让 AI 做成[可调公式与参数](/garden/components/interactive);有多行多列维度时直接用表格。
28
+
29
+ 可以这样对 AI 说:
30
+
28
31
  ````markdown
29
- ```garden stat
30
- items:
31
- - label: 正文列宽
32
- value: "740"
33
- unit: px
34
- caption: 默认阅读列宽度
35
- - label: 宽图上限
36
- value: "1040"
37
- unit: px
38
- caption: 左右各最多向外延伸 150px
39
- - label: 宽表上限
40
- value: "1340"
41
- unit: px
42
- caption: 左右各最多向外延伸 300px
32
+ ```garden
33
+ 把正文列宽 740px、宽图上限 1040px 和宽表上限 1340px 三个数字并排摆出来。
43
34
  ```
44
35
  ````
45
36
 
46
- - **用**:把分散在段落里的 2~4 个核心数字、阈值或规格并排摆出来时。
47
- - **别用**:只有一个数字时直接写在正文句子里;有多行多列维度时改用 Markdown 表格。
37
+ ## 字段说明
48
38
 
49
- | 字段 | 必填 | 类型 | 说明 |
50
- | :--- | :--- | :--- | :--- |
51
- | `items` | 否 | 对象数组 | 展示多项指标时使用;单卡可直接把字段写在顶层 |
52
- | `label` | 是 | 字符串 | 指标名称(显示在数字上方) |
53
- | `value` | 是 | 字符串或数字 | 核心数值(等宽大字号显示) |
54
- | `unit` | 否 | 字符串 | 紧跟在数值右侧的单位 |
55
- | `caption` | 否 | 字符串 | 数值下方的简短说明 |
56
- | `text` | 否 | 字符串 | 补充说明文字 |
57
- | `source` | 否 | 字符串或 `{ title, url }` | 数据出处角标 |
39
+ 全部字段、默认值、取值限制和报错代码见 [组件参考 · stat](/garden/reference/stat)。
@@ -1,52 +1,37 @@
1
1
  ---
2
2
  title: 时间线(timeline)
3
3
  navTitle: 时间线
4
- description: 按时间或步骤顺序排列版本演进、排查过程与关键节点。
4
+ description: 按时间或阶段顺序排开版本演进、排查经过或关键节点。
5
5
  section: components
6
6
  order: 34
7
7
  badge: timeline
8
8
  ---
9
9
 
10
- 在 `garden` 想法块里写一句「用 `timeline` 按顺序列出静态发布流水线的三个步骤」,Agent 会按 `garden-ui` skill 生成下面的 `garden timeline`(手写格式附后)。
11
-
12
10
  ```garden timeline
13
11
  title: 静态发布流水线执行步骤
14
12
  items:
15
13
  - date: 步骤 1
16
14
  title: 同步内容与静态资源
17
- text: 运行 `npx garden sync`,校验 Front Matter、复制图片附件并生成搜索索引与 RSS。
15
+ text: 校验文章信息、复制图片附件并生成搜索索引与 RSS。
18
16
  - date: 步骤 2
19
17
  title: 构建静态站点产物
20
- text: 运行 `STATIC_EXPORT=1 npx garden build`,把全部路由预渲染到 `dist/client/`。
18
+ text: 把全部页面预渲染到静态目录。
21
19
  - date: 步骤 3
22
20
  title: 校验静态页面并部署
23
- text: 运行 `npm run pages:validate` 确认有 `index.html`,且没有混入 `.env`、源码目录、`.map` 或 `.md` 文件和软链接,通过后发布到 GitHub Pages。
21
+ text: 检查导出文件完整无误后发布到 GitHub Pages。
24
22
  ```
25
23
 
24
+ - **什么时候用**:版本演进、故障排查时间点或按先后顺序推进的阶段。
25
+ - **什么时候不用**:没有时间顺序的并列要点用普通列表或[图标列表](/garden/components/list)。
26
+
27
+ 可以这样对 AI 说:
28
+
26
29
  ````markdown
27
- ```garden timeline
28
- title: 静态发布流水线执行步骤
29
- items:
30
- - date: 步骤 1
31
- title: 同步内容与静态资源
32
- text: 运行 `npx garden sync`,校验 Front Matter、复制图片附件并生成搜索索引与 RSS。
33
- - date: 步骤 2
34
- title: 构建静态站点产物
35
- text: 运行 `STATIC_EXPORT=1 npx garden build`,把全部路由预渲染到 `dist/client/`。
36
- - date: 步骤 3
37
- title: 校验静态页面并部署
38
- text: 运行 `npm run pages:validate` 确认有 `index.html`,且没有混入 `.env`、源码目录、`.map` 或 `.md` 文件和软链接,通过后发布到 GitHub Pages。
30
+ ```garden
31
+ 按时间顺序把静态发布流水线的三个阶段列出来。
39
32
  ```
40
33
  ````
41
34
 
42
- - **用**:按先后顺序记录故障排查时间点、演进阶段或构建流水线步骤(至少 2 个节点)时。
43
- - **别用**:没有时间或先后顺序的并列要点,直接用无序列表。
35
+ ## 字段说明
44
36
 
45
- | 字段 | 必填 | 类型 | 说明 |
46
- | :--- | :--- | :--- | :--- |
47
- | `title` | 否 | 字符串 | 时间线顶部的总标题 |
48
- | `items` | 是 | 对象数组(至少 2 项) | 按顺序排列的节点列表 |
49
- | `items[].date` | 否 | 字符串 | 时间、阶段或步骤编号(显示在节点标题上方) |
50
- | `items[].title` | 是 | 字符串 | 节点标题 |
51
- | `items[].text` | 否 | 字符串 | 节点详细说明 |
52
- | `items[].source` | 否 | 字符串或 `{ title, url }` | 节点出处角标 |
37
+ 全部字段、默认值、取值限制和报错代码见 [组件参考 · timeline](/garden/reference/timeline)。