hd-garden 0.13.0 → 0.13.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.
package/README.en.md CHANGED
@@ -73,7 +73,7 @@ Ask your Agent to compile the post using the bundled `garden-ui` skill: it runs
73
73
  ```bash
74
74
  make new SLUG=writing-pace TITLE="Writing Pace" # Create a draft post in content/posts/
75
75
  make dev # Sync content and start the local server
76
- CONTENT_INCLUDE_DRAFTS=1 make dev # Preview drafts and future publishAt posts
76
+ CONTENT_INCLUDE_DRAFTS=0 make dev # Preview published posts only (optional)
77
77
  make check # Run garden sync and garden build
78
78
  make update MESSAGE="Add writing-pace post" # Check, commit, and push to origin
79
79
  npx garden check content/posts/writing-pace.md # Validate front matter, components, and assets
package/README.md CHANGED
@@ -75,7 +75,7 @@ Obsidian 插件这一轮不随包安装。
75
75
  ```bash
76
76
  make new SLUG=writing-pace TITLE="慢慢写" # 在 content/posts/ 下创建文章草稿
77
77
  make dev # 同步内容并启动本地预览
78
- CONTENT_INCLUDE_DRAFTS=1 make dev # 连同草稿和未来定时文章一起预览
78
+ CONTENT_INCLUDE_DRAFTS=0 make dev # 只预览已发布文章(可选)
79
79
  make check # 运行 garden sync 与 garden build 验证全站
80
80
  make update MESSAGE="新增一篇文章" # 检查通过后提交并推送到远端仓库
81
81
  npx garden check content/posts/writing-pace.md # 单独检查一篇文章的标题、组件与资源路径
@@ -8,10 +8,11 @@ import {
8
8
  groupHandbookDocs,
9
9
  HANDBOOK_SECTIONS,
10
10
  HANDBOOK_UI,
11
- NAV_SHORT_TITLE,
12
11
  REFERENCE_SECTION,
12
+ handbookNavLabel,
13
13
  isReferencePath,
14
14
  handbookPath,
15
+ referenceBadgeSuffix,
15
16
  sectionTitle,
16
17
  type GardenDocNavItem,
17
18
  type HandbookLang,
@@ -103,7 +104,7 @@ export function GardenDocsNav({
103
104
  <div className="gdoc-mobile-crumb" aria-hidden="true">
104
105
  <span>{sectionTitle(currentSection, lang) ?? t.name}</span>
105
106
  <CaretRight size={12} />
106
- <strong>{currentDoc ? (lang === "en" ? currentDoc.navTitle ?? currentDoc.title : NAV_SHORT_TITLE[currentDoc.path] ?? currentDoc.title) : t.overviewHint}</strong>
107
+ <strong>{currentDoc ? handbookNavLabel(currentDoc, lang) : t.overviewHint}</strong>
107
108
  </div>
108
109
  </div>
109
110
 
@@ -161,7 +162,10 @@ export function GardenDocsNav({
161
162
  {group.items.map((item) => {
162
163
  const active = item.path === currentPath;
163
164
  const badge = COMPONENT_BADGE[item.path];
164
- const label = lang === "en" ? item.navTitle ?? item.title : NAV_SHORT_TITLE[item.path] ?? item.title;
165
+ const label = handbookNavLabel(item, lang);
166
+ const referenceSuffix = group.id === REFERENCE_SECTION && badge
167
+ ? referenceBadgeSuffix(badge, label)
168
+ : null;
165
169
  return (
166
170
  <li key={item.path} className={active ? "is-active" : undefined}>
167
171
  <Link
@@ -172,7 +176,11 @@ export function GardenDocsNav({
172
176
  {badge ? (
173
177
  <>
174
178
  <code className="gdoc-comp-pill">{badge}</code>
175
- {group.id === REFERENCE_SECTION ? null : <span className="gdoc-comp-label">{label}</span>}
179
+ {group.id === REFERENCE_SECTION ? (
180
+ referenceSuffix ? <span className="gdoc-comp-label">{referenceSuffix}</span> : null
181
+ ) : (
182
+ <span className="gdoc-comp-label">{label}</span>
183
+ )}
176
184
  </>
177
185
  ) : (
178
186
  <span>{label}</span>
@@ -133,6 +133,31 @@ export const NAV_SHORT_TITLE: Record<string, string> = {
133
133
  reference: "总览",
134
134
  };
135
135
 
136
+
137
+ /**
138
+ * Reference sidebar shows COMPONENT_BADGE inside <code>. When two pages share a
139
+ * badge (compose + compose-icons), keep the code pill and append the remainder
140
+ * of navTitle / short label after a separator (space / · / dash).
141
+ * Returns the suffix including its leading separator, or null.
142
+ */
143
+ export function referenceBadgeSuffix(badge: string, label: string): string | null {
144
+ if (!badge || !label || label === badge) return null;
145
+ if (!label.startsWith(badge)) return null;
146
+ const rest = label.slice(badge.length);
147
+ if (!rest || !/^[\s·\-—]/.test(rest)) return null;
148
+ return rest;
149
+ }
150
+
151
+ /** Sidebar text label: prefer authored navTitle; ZH may fall back to NAV_SHORT_TITLE. */
152
+ export function handbookNavLabel(item: GardenDocNavItem, lang: HandbookLang): string {
153
+ if (item.navTitle) return item.navTitle;
154
+ if (lang !== "en") {
155
+ const short = NAV_SHORT_TITLE[item.path];
156
+ if (short) return short;
157
+ }
158
+ return item.title;
159
+ }
160
+
136
161
  export function groupHandbookDocs<T extends GardenDocNavItem>(docs: T[]) {
137
162
  const bySection = new Map<string, T[]>();
138
163
  for (const section of HANDBOOK_SECTIONS) {
package/bin/garden.mjs CHANGED
@@ -522,6 +522,10 @@ async function main() {
522
522
  await sync();
523
523
  break;
524
524
  case "dev":
525
+ // Preview drafts by default, without overriding an explicit opt-out.
526
+ // Scoped to this CLI process: sync, Vinext and its watcher inherit it;
527
+ // later build/check commands do not.
528
+ process.env.CONTENT_INCLUDE_DRAFTS ??= "1";
525
529
  ensureDevGitHubLogin();
526
530
  await runVinext(["dev", ...rest]);
527
531
  break;
@@ -14,4 +14,4 @@
14
14
  | :--- | :--- |
15
15
  | `npx garden check content/posts/<slug>.md` | 检查单篇文章的组件字段、代码对比与图片附件路径 |
16
16
  | `make check` | 运行 `npx garden sync && npx garden build` 校验全站构建 |
17
- | `CONTENT_INCLUDE_DRAFTS=1 make dev` | 在本地连同草稿和定时文章一起预览 |
17
+ | `make dev` | 在本地连同草稿和定时文章一起预览 |
@@ -14,4 +14,4 @@ Before running `make update` to push changes, verify the following items:
14
14
  | :--- | :--- |
15
15
  | `npx garden check content/posts/<slug>.md` | Checks a single post's component fields, code diffs, and local asset paths |
16
16
  | `make check` | Runs `npx garden sync && npx garden build` to validate the full site build |
17
- | `CONTENT_INCLUDE_DRAFTS=1 make dev` | Previews drafts and scheduled posts locally |
17
+ | `make dev` | Previews drafts and scheduled posts locally |
@@ -173,7 +173,7 @@ One mini sample per group, then a one-line table for every tag. No per-tag essay
173
173
 
174
174
  ## Chart examples
175
175
 
176
- Play-level chart samples (static eight bars, fusion weight slider) live on [Diagrams · compose](/garden/en/components/compose#compose-chart-active-hours).
176
+ Play-level chart samples (static eight bars, fusion weight slider) live on [Diagrams · compose](/garden/en/components/compose#ui-compose-chart-active-hours).
177
177
 
178
178
  ## Limits
179
179
 
@@ -14,4 +14,4 @@ Before running `make update` to push changes, verify the following items:
14
14
  | :--- | :--- |
15
15
  | `npx garden check content/posts/<slug>.md` | Checks a single post's component fields, code diffs, and local asset paths |
16
16
  | `make check` | Runs `npx garden sync && npx garden build` to validate the full site build |
17
- | `CONTENT_INCLUDE_DRAFTS=1 make dev` | Previews drafts and scheduled posts locally |
17
+ | `make dev` | Previews drafts and scheduled posts locally |
@@ -59,10 +59,10 @@ make new DIR=network SLUG=tcp-bbr TITLE="TCP BBR Notes"
59
59
  > [!NOTE] Note
60
60
  > `SLUG` may only contain lowercase letters, digits, and hyphens (`a-z`, `0-9`, `-`), never `/`; pass subdirectories via `DIR`. `make new` reads only `SLUG`, `TITLE`, and `DIR`.
61
61
 
62
- Newly created files default to `draft: true`. Set `CONTENT_INCLUDE_DRAFTS=1` to preview drafts or future-dated (`publishAt`) posts locally:
62
+ Newly created files default to `draft: true`. `make dev` previews drafts and future-dated (`publishAt`) posts by default. Use `CONTENT_INCLUDE_DRAFTS=0 make dev` to opt out. Production builds still exclude them by default:
63
63
 
64
64
  ```bash
65
- CONTENT_INCLUDE_DRAFTS=1 make dev
65
+ make dev
66
66
  ```
67
67
 
68
68
  ### Creating a Thought
@@ -76,7 +76,7 @@ The site `Makefile` and `garden` CLI provide these commands:
76
76
  | Command | What It Runs |
77
77
  | :--- | :--- |
78
78
  | `make dev` | Runs `make prepare` to check dependencies, then runs `npx garden dev` (which syncs content and starts the dev server) |
79
- | `CONTENT_INCLUDE_DRAFTS=1 make dev` | Previews `draft: true` drafts and future `publishAt` posts alongside published content |
79
+ | `CONTENT_INCLUDE_DRAFTS=0 make dev` | Optional: preview published posts only, excluding drafts and future posts |
80
80
  | `make new SLUG=xxx TITLE="Title" DIR=subdir` | Calls `npx garden new` to create a draft post under `content/posts/` (`DIR` is optional) |
81
81
  | `make check` | Runs `npx garden sync && npx garden build` in the site repo to verify content sync and the production build |
82
82
  | `npx garden check content/posts/xxx.md` | Checks a single Markdown post's title, component fields, code diffs, and local asset paths |
@@ -173,7 +173,7 @@ badge: compose
173
173
 
174
174
  ## 图表示例
175
175
 
176
- 玩法级图表示例(静态八柱、融合权重滑杆)见 [说明图 · compose](/garden/components/compose#compose-chart-active-hours)。
176
+ 玩法级图表示例(静态八柱、融合权重滑杆)见 [说明图 · compose](/garden/components/compose#ui-compose-chart-active-hours)。
177
177
 
178
178
  ## 限制
179
179
 
@@ -14,4 +14,4 @@
14
14
  | :--- | :--- |
15
15
  | `npx garden check content/posts/<slug>.md` | 检查单篇文章的组件字段、代码对比与图片附件路径 |
16
16
  | `make check` | 运行 `npx garden sync && npx garden build` 校验全站构建 |
17
- | `CONTENT_INCLUDE_DRAFTS=1 make dev` | 在本地连同草稿和定时文章一起预览 |
17
+ | `make dev` | 在本地连同草稿和定时文章一起预览 |
@@ -59,10 +59,10 @@ make new DIR=network SLUG=tcp-bbr TITLE="TCP BBR 拥塞控制笔记"
59
59
  > [!NOTE]
60
60
  > `SLUG` 只能包含小写字母、数字和连字符(`a-z`、`0-9`、`-`),不能包含 `/`;子目录必须用 `DIR` 参数传入。`make new` 只读取 `SLUG`、`TITLE` 和 `DIR` 三个变量。
61
61
 
62
- 新建的文件默认带有 `draft: true`。本地预览草稿或未来定时文章(`publishAt`)时,加上环境变量 `CONTENT_INCLUDE_DRAFTS=1`:
62
+ 新建的文件默认带有 `draft: true`。`make dev` 默认预览草稿和未来定时文章(`publishAt`);用 `CONTENT_INCLUDE_DRAFTS=0 make dev` 可关闭。正式构建仍默认排除它们:
63
63
 
64
64
  ```bash
65
- CONTENT_INCLUDE_DRAFTS=1 make dev
65
+ make dev
66
66
  ```
67
67
 
68
68
  ### 新建随想
@@ -76,7 +76,7 @@ CONTENT_INCLUDE_DRAFTS=1 make dev
76
76
  | 命令 | 实际执行的操作 |
77
77
  | :--- | :--- |
78
78
  | `make dev` | 先执行 `make prepare` 检查依赖,再运行 `npx garden dev`(内部自动执行同步并启动开发服务器) |
79
- | `CONTENT_INCLUDE_DRAFTS=1 make dev` | 连同 `draft: true` 草稿和未到 `publishAt` 时间的文章一起预览 |
79
+ | `CONTENT_INCLUDE_DRAFTS=0 make dev` | 可选:只预览已发布文章,排除草稿和未来定时文章 |
80
80
  | `make new SLUG=xxx TITLE="标题" DIR=子目录` | 调用 `npx garden new` 在 `content/posts/` 下生成新文章草稿(`DIR` 可省略) |
81
81
  | `make check` | 在站点仓库中运行 `npx garden sync && npx garden build`,验证全站同步与生产构建 |
82
82
  | `npx garden check content/posts/xxx.md` | 单独检查某篇 Markdown 文章的标题、组件字段、代码对比与本地附件路径 |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hd-garden",
3
- "version": "0.13.0",
3
+ "version": "0.13.2",
4
4
  "private": false,
5
5
  "description": "\u7528 Markdown \u5199\u4f5c\u3001\u7528 GitHub Pages \u53d1\u5e03\u7684\u4e2a\u4eba\u535a\u5ba2\u5f15\u64ce\u3002",
6
6
  "license": "MIT",
@@ -67,12 +67,12 @@ async function main() {
67
67
  if (lang === "en") {
68
68
  console.log(`Created draft: ${path.relative(root, destination)}`);
69
69
  console.log(`Post URL: /blog/${[...segments, slug].join("/")}/`);
70
- console.log("Preview: CONTENT_INCLUDE_DRAFTS=1 make dev");
70
+ console.log("Preview: make dev");
71
71
  console.log("Before publishing, fill in description, tags, and body, set draft to false, then run make update.");
72
72
  } else {
73
73
  console.log(`已创建草稿:${path.relative(root, destination)}`);
74
74
  console.log(`文章路径:/blog/${[...segments, slug].join("/")}/`);
75
- console.log("预览:CONTENT_INCLUDE_DRAFTS=1 make dev");
75
+ console.log("预览:make dev");
76
76
  console.log("发布前请完善摘要、标签与正文,并将 draft 改为 false,再运行 make update。");
77
77
  }
78
78
  }
@@ -8,6 +8,8 @@ make new TITLE="Hello, World" SLUG=hello
8
8
  make dev
9
9
  ```
10
10
 
11
+ `make dev`, `npm run dev`, and `npx garden dev` preview drafts and future scheduled posts by default. Opt out with `CONTENT_INCLUDE_DRAFTS=0 make dev`. Production builds exclude them by default.
12
+
11
13
  Running `npx garden dev` for the first time fills in any missing `Makefile` or skills and creates `.env.local`. Cursor and Codex read `.agents/skills/` automatically when opening this repository. Run `npx garden skill` anytime to update the bundled skills.
12
14
 
13
15
  `npx hd-garden init` copies the VS Code / Cursor and Typora Intelligent UI plugins into `.garden/editors/` and asks whether to install them when the terminal is interactive. Run `npx garden editors install` later (`--yes` installs both, `--vscode` or `--typora` installs one). Typora needs typora-community-plugin first; then enable the plugin under Settings, Installed plugins. Use the plugins to insert a plain `garden` brief for the `garden-ui` skill to compile, preview a component, and open the catalog. In Typora, type `/` and choose `/garden` to list each component with a small preview image. Hand `Compile this post:` to the skill when you want it compiled.
@@ -8,6 +8,8 @@ make new TITLE="你好,世界" SLUG=hello
8
8
  make dev
9
9
  ```
10
10
 
11
+ `make dev`、`npm run dev` 和 `npx garden dev` 默认预览草稿及未来定时文章。可用 `CONTENT_INCLUDE_DRAFTS=0 make dev` 关闭;正式构建默认排除这些内容。
12
+
11
13
  第一次 `npx garden dev` 会补齐 Makefile 和 skill,并创建 `.env.local`。Cursor / Codex 打开这个仓库后会读到 `.agents/skills/`。要更新 skill,再运行 `npx garden skill`。
12
14
 
13
15
  `npx hd-garden init` 会把 VS Code / Cursor 与 Typora 的 Intelligent UI 插件放到 `.garden/editors/`,并在交互终端里询问要不要安装。之后可以运行 `npx garden editors install`(加 `--yes` 则直接安装,`--vscode` / `--typora` 只装一个)。Typora 需要先装 typora-community-plugin,再在「设置 → 已安装插件」里勾选。插件用来插入想法(一段给 `garden-ui` skill 编译的 `garden` 围栏,不是写好的 YAML)、预览组件、打开清单,并把「编译这篇」交给 skill。Typora 里输入 `/` 选 `/garden`,再从带小预览图的列表里选。