hd-garden 0.13.0 → 0.13.1

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.
@@ -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) {
@@ -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
 
@@ -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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hd-garden",
3
- "version": "0.13.0",
3
+ "version": "0.13.1",
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",