@windrun-huaiin/diaomao 2.4.0 → 2.5.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@windrun-huaiin/diaomao",
3
- "version": "2.4.0",
3
+ "version": "2.5.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -1,17 +1,17 @@
1
1
  diff --git a/dist/components/layout/toc-clerk.d.ts.map b/dist/components/layout/toc-clerk.d.ts.map
2
- index 30dfe1ce45819999661e37005f3c0238a596b678..478144443e205959381138a5ff0cbe45bdae2f7b 100644
2
+ index 30dfe1ce45819999661e37005f3c0238a596b678..6b9c00aef82311612b7e549c419b9534c01a03a7 100644
3
3
  --- a/dist/components/layout/toc-clerk.d.ts.map
4
4
  +++ b/dist/components/layout/toc-clerk.d.ts.map
5
5
  @@ -1 +1 @@
6
6
  -{"version":3,"file":"toc-clerk.d.ts","sourceRoot":"","sources":["../../../src/components/layout/toc-clerk.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAOxD,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EAAE,KAAK,EAAE,EAAE;IAAE,KAAK,EAAE,WAAW,EAAE,CAAA;CAAE,2CA2FxE"}
7
7
 
8
- +{"version":3,"file":"toc-clerk.d.ts","sourceRoot":"","sources":["../../../src/components/layout/toc-clerk.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AA8BxD,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EAAE,KAAK,EAAE,EAAE;IAAE,KAAK,EAAE,WAAW,EAAE,CAAA;CAAE,2CAyFxE"}
8
+ +{"version":3,"file":"toc-clerk.d.ts","sourceRoot":"","sources":["../../../src/components/layout/toc-clerk.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAuDxD,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EAAE,KAAK,EAAE,EAAE;IAAE,KAAK,EAAE,WAAW,EAAE,CAAA;CAAE,2CAyFxE"}
9
9
 
10
10
  diff --git a/dist/components/layout/toc-clerk.js b/dist/components/layout/toc-clerk.js
11
- index 7c128748acf238d7fd63a446876f35d5a0679fed..58bd8c8effdf362d62acd20d2910b61093327659 100644
11
+ index 7c128748acf238d7fd63a446876f35d5a0679fed..d90e60ef967bc3e5f82ffb87f0ff6624a9d54e46 100644
12
12
  --- a/dist/components/layout/toc-clerk.js
13
13
  +++ b/dist/components/layout/toc-clerk.js
14
- @@ -1,10 +1,32 @@
14
+ @@ -1,10 +1,55 @@
15
15
  'use client';
16
16
  -import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
17
17
  +import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
@@ -34,18 +34,41 @@ index 7c128748acf238d7fd63a446876f35d5a0679fed..58bd8c8effdf362d62acd20d2910b610
34
34
  + // e.g., if depth >=3, line is at 10px from the start of the content box of TOCItem
35
35
  + return depth >= 3 ? 10 : 0;
36
36
  +}
37
- +// New helper function to extract step info from URL
38
- +function getStepInfoFromUrl(url) {
39
- + const match = url.match(/^#(\d+)-/);
40
- + if (match && match[1]) {
41
- + return { isStep: true, stepNumber: match[1] };
37
+ +// Fallback: extract leading digits from URL like "#12-title"
38
+ +function _getDigitsFromUrl(url) {
39
+ + const m = /^#(\d+)-/.exec(url);
40
+ + if (!m)
41
+ + return null;
42
+ + const n = Number.parseInt(m[1], 10);
43
+ + return Number.isNaN(n) ? null : n;
44
+ +}
45
+ +// (Deprecated) URL-based step detection and mapping removed in favor of title-based rules
46
+ +// Extract step info from the ORIGINAL title for h3-only rendering.
47
+ +// Rules:
48
+ +// - Title must match: number(.number)* <space> <non-empty text>
49
+ +// - Display step is the last numeric segment, clamped to 0..19
50
+ +function getStepInfoFromTitle(title) {
51
+ + const trimmed = title.trim();
52
+ + // Trailing dot is optional: e.g., "1 ", "1. ", "1.1 ", "1.1. "
53
+ + const match = trimmed.match(/^(\d+(?:\.\d+)*\.?)\s+(.+)$/);
54
+ + if (!match)
55
+ + return { isStep: false, displayStep: null, content: null };
56
+ + const content = (match[2] ?? '').trim();
57
+ + if (content.length === 0)
58
+ + return { isStep: false, displayStep: null, content: null };
59
+ + const numericPart = match[1].replace(/\.$/, '');
60
+ + const parts = numericPart.split('.').map((p) => Number.parseInt(p, 10));
61
+ + const lastPart = parts.at(-1);
62
+ + if (lastPart == null || Number.isNaN(lastPart)) {
63
+ + return { isStep: false, displayStep: null, content: null };
42
64
  + }
43
- + return { isStep: false, stepNumber: null };
65
+ + const clamped = Math.max(0, Math.min(19, lastPart));
66
+ + return { isStep: true, displayStep: clamped, content };
44
67
  +}
45
68
  export default function ClerkTOCItems({ items }) {
46
69
  const containerRef = useRef(null);
47
70
  const [svg, setSvg] = useState();
48
- @@ -18,21 +40,25 @@ export default function ClerkTOCItems({ items }) {
71
+ @@ -18,21 +63,25 @@ export default function ClerkTOCItems({ items }) {
49
72
  let w = 0, h = 0;
50
73
  const d = [];
51
74
  for (let i = 0; i < items.length; i++) {
@@ -77,7 +100,7 @@ index 7c128748acf238d7fd63a446876f35d5a0679fed..58bd8c8effdf362d62acd20d2910b610
77
100
  height: h,
78
101
  });
79
102
  }
80
- @@ -45,29 +71,31 @@ export default function ClerkTOCItems({ items }) {
103
+ @@ -45,29 +94,51 @@ export default function ClerkTOCItems({ items }) {
81
104
  }, [items]);
82
105
  if (items.length === 0)
83
106
  return _jsx(TocItemsEmpty, {});
@@ -89,7 +112,9 @@ index 7c128748acf238d7fd63a446876f35d5a0679fed..58bd8c8effdf362d62acd20d2910b610
89
112
  - // Inline SVG
90
113
  - encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${svg.width} ${svg.height}"><path d="${svg.path}" stroke="black" stroke-width="1" fill="none" /></svg>`)}")`,
91
114
  - }, children: _jsx(TocThumb, { containerRef: containerRef, className: "mt-(--fd-top) h-(--fd-height) bg-fd-primary transition-all" }) })) : null, _jsx("div", { className: "flex flex-col", ref: containerRef, children: items.map((item, i) => (_jsx(TOCItem, { item: item, upper: items[i - 1]?.depth, lower: items[i + 1]?.depth }, item.url))) })] }));
92
- -}
115
+ + maskImage: `url("data:image/svg+xml,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${svg.width} ${svg.height}"><path d="${svg.path}" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" fill="none" /></svg>`)}")`,
116
+ + }, children: _jsx(TocThumb, { containerRef: containerRef, className: "bg-fd-primary transition-all duration-500 ease-in-out" }) })) : null, _jsx("div", { className: "flex flex-col", ref: containerRef, children: items.map((item, i) => (_jsx(EnhancedClerkTOCItemInternal, { item: item, upperDepth: items[i - 1]?.depth, lowerDepth: items[i + 1]?.depth }, item.url))) })] }));
117
+ }
93
118
  -function getItemOffset(depth) {
94
119
  - if (depth <= 2)
95
120
  - return 14;
@@ -99,13 +124,35 @@ index 7c128748acf238d7fd63a446876f35d5a0679fed..58bd8c8effdf362d62acd20d2910b610
99
124
  -}
100
125
  -function getLineOffset(depth) {
101
126
  - return depth >= 3 ? 10 : 0;
102
- + maskImage: `url("data:image/svg+xml,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${svg.width} ${svg.height}"><path d="${svg.path}" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" fill="none" /></svg>`)}")`,
103
- + }, children: _jsx(TocThumb, { containerRef: containerRef, className: "bg-fd-primary transition-all duration-500 ease-in-out" }) })) : null, _jsx("div", { className: "flex flex-col", ref: containerRef, children: items.map((item, i) => (_jsx(EnhancedClerkTOCItemInternal, { item: item, upperDepth: items[i - 1]?.depth, lowerDepth: items[i + 1]?.depth }, item.url))) })] }));
104
- }
127
+ -}
105
128
  -function TOCItem({ item, upper = item.depth, lower = item.depth, }) {
106
129
  - const offset = getLineOffset(item.depth), upperOffset = getLineOffset(upper), lowerOffset = getLineOffset(lower);
107
130
  +function EnhancedClerkTOCItemInternal({ item, upperDepth = item.depth, lowerDepth = item.depth, }) {
108
- + const { isStep, stepNumber } = getStepInfoFromUrl(item.url);
131
+ + // New rule: only h3 and based on ORIGINAL title pattern
132
+ + const isH3 = item.depth === 3;
133
+ + const rawTitle = typeof item.title === 'string' ? item.title : '';
134
+ + const { isStep, displayStep, content } = getStepInfoFromTitle(rawTitle);
135
+ + let stepNumber = isH3 && isStep ? String(displayStep) : null;
136
+ + let resolvedContent = item.title;
137
+ + if (isH3 && isStep) {
138
+ + resolvedContent = content ?? item.title;
139
+ + }
140
+ + // Fallback to URL-based digits if title-based detection fails unexpectedly
141
+ + if (isH3 && !stepNumber) {
142
+ + const urlNum = _getDigitsFromUrl(item.url);
143
+ + if (urlNum != null) {
144
+ + const clamped = Math.max(0, Math.min(19, urlNum));
145
+ + stepNumber = String(clamped);
146
+ + // Try to strip numeric prefix from title even if title-based regex failed
147
+ + if (typeof rawTitle === 'string') {
148
+ + const m = rawTitle.match(/^(\d+(?:\.\d+)*\.?)\s+(.+)$/);
149
+ + if (m && m[2]) {
150
+ + resolvedContent = m[2];
151
+ + }
152
+ + }
153
+ + }
154
+ + }
155
+ + const shouldRenderCircle = isH3 && stepNumber !== null;
109
156
  + const lineOffsetWithinItem = getLineOffset(item.depth);
110
157
  + const upperLineOffsetWithinItem = getLineOffset(upperDepth);
111
158
  + const lowerLineOffsetWithinItem = getLineOffset(lowerDepth);
@@ -119,13 +166,9 @@ index 7c128748acf238d7fd63a446876f35d5a0679fed..58bd8c8effdf362d62acd20d2910b610
119
166
  + }, className: "prose group relative py-1.5 text-sm text-fd-muted-foreground transition-colors [overflow-wrap:anywhere] first:pt-0 last:pb-0 data-[active=true]:text-fd-primary", children: [lineOffsetWithinItem !== upperLineOffsetWithinItem ? (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 16 16", className: "absolute -top-1.5 size-4 rtl:-scale-x-100 pointer-events-none", style: { insetInlineStart: Math.min(lineOffsetWithinItem, upperLineOffsetWithinItem), zIndex: 1 }, children: _jsx("line", { x1: upperLineOffsetWithinItem - Math.min(lineOffsetWithinItem, upperLineOffsetWithinItem), y1: "0", x2: lineOffsetWithinItem - Math.min(lineOffsetWithinItem, upperLineOffsetWithinItem), y2: "12", className: cn('stroke-fd-foreground/10', 'group-data-[active=true]:stroke-fd-primary'), strokeWidth: "1", strokeLinecap: "round" }) })) : null, _jsx("div", { className: cn('absolute inset-y-0 w-px pointer-events-none', 'bg-fd-foreground/10 group-data-[active=true]:bg-fd-primary', lineOffsetWithinItem !== upperLineOffsetWithinItem && 'top-1.5', lineOffsetWithinItem !== lowerLineOffsetWithinItem && 'bottom-1.5'), style: {
120
167
  + insetInlineStart: lineOffsetWithinItem,
121
168
  + zIndex: 1,
122
- + } }), isStep && stepNumber && (_jsx("span", { className: cn('absolute z-10 flex size-[14px] rounded-full justify-center items-center', 'bg-black text-white dark:bg-white dark:text-black', 'group-data-[active=true]:bg-fd-primary group-data-[active=true]:text-white dark:group-data-[active=true]:text-black', 'font-medium text-xs'), style: {
169
+ + } }), shouldRenderCircle && stepNumber && (_jsx("span", { className: cn('absolute z-10 flex size-[14px] rounded-full justify-center items-center', 'bg-black text-white dark:bg-white dark:text-black', 'group-data-[active=true]:bg-fd-primary group-data-[active=true]:text-white dark:group-data-[active=true]:text-black', 'font-medium text-xs'), style: {
123
170
  + left: lineOffsetWithinItem - CIRCLE_RADIUS_PX,
124
171
  + top: '50%',
125
172
  + transform: 'translateY(-50%)',
126
- + }, children: stepNumber })), _jsx("span", { style: {
127
- + position: 'relative',
128
- + zIndex: 1,
129
- + // marginLeft: isStep ? lineOffsetWithinItem : undefined,
130
- + }, children: item.title })] }));
173
+ + }, children: stepNumber })), _jsx("span", { style: { position: 'relative', zIndex: 1 }, children: resolvedContent })] }));
131
174
  }
@@ -2,16 +2,19 @@
2
2
  title: Blog
3
3
  description: Articles and thoughts about various topics.
4
4
  icon: Rss
5
- date: 2025-07-31
5
+ date: 2025-08-08
6
6
  ---
7
7
 
8
8
  ## Past List
9
9
 
10
10
  <Cards>
11
- <ZiaCard href="blog/AsyncArchitecture" title="Next.js 异步处理架构升级方案">
11
+ <ZiaCard href="blog/async-architecture" title="Next.js 异步处理架构升级方案">
12
12
  2025-07-31
13
13
  </ZiaCard>
14
- <ZiaCard href="blog/PaidDesign-v1.0" title="订阅与积分系统产品设计文档 v1.0">
14
+ <ZiaCard href="blog/paid-system-design" title="订阅与积分系统产品设计文档 v1.0">
15
15
  2025-07-31
16
16
  </ZiaCard>
17
+ <ZiaCard icon={<Test />} href="blog/test" title="MDX Test">
18
+ 2025-06-23
19
+ </ZiaCard>
17
20
  </Cards>
@@ -1,15 +1,18 @@
1
1
  ---
2
2
  title: Monthly Summary
3
3
  description: Index and Summary
4
- date: 2025-07-31
4
+ date: 2025-08-08
5
5
  ---
6
6
 
7
7
 
8
8
  ## Overview
9
9
  <Files>
10
10
  <ZiaFolder name="2025-07(2)" defaultOpen>
11
- <ZiaFile name="2025-07-31(Next.js 异步处理架构升级方案)" href="./AsyncArchitecture" />
12
- <ZiaFile name="2025-07-31(订阅与积分系统产品设计文档 v1.0)" href="./PaidDesign-v1.0" />
11
+ <ZiaFile name="2025-07-31(Next.js 异步处理架构升级方案)" href="./async-architecture" />
12
+ <ZiaFile name="2025-07-31(订阅与积分系统产品设计文档 v1.0)" href="./paid-system-design" />
13
+ </ZiaFolder>
14
+ <ZiaFolder name="2025-06(1)">
15
+ <ZiaFile name="2025-06-23(MDX Test)" href="./test" />
13
16
  </ZiaFolder>
14
17
  </Files>
15
18