@uniweb/build 0.1.19 → 0.1.20
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
|
@@ -79,9 +79,14 @@ function isMarkdownFile(filename) {
|
|
|
79
79
|
|
|
80
80
|
/**
|
|
81
81
|
* Parse numeric prefix from filename (e.g., "1-hero.md" → { prefix: "1", name: "hero" })
|
|
82
|
+
* Supports:
|
|
83
|
+
* - Simple: "1", "2", "3"
|
|
84
|
+
* - Decimal ordering: "1.5" (between 1 and 2), "2.5" (between 2 and 3)
|
|
85
|
+
* - Hierarchy via comma: "1,1" (child of 1), "1,2" (second child of 1)
|
|
86
|
+
* - Mixed: "1.5,1" (child of section 1.5)
|
|
82
87
|
*/
|
|
83
88
|
function parseNumericPrefix(filename) {
|
|
84
|
-
const match = filename.match(/^(\d+(
|
|
89
|
+
const match = filename.match(/^(\d+(?:[.,]\d+)*)-?(.*)$/)
|
|
85
90
|
if (match) {
|
|
86
91
|
return { prefix: match[1], name: match[2] || match[1] }
|
|
87
92
|
}
|
|
@@ -89,7 +94,9 @@ function parseNumericPrefix(filename) {
|
|
|
89
94
|
}
|
|
90
95
|
|
|
91
96
|
/**
|
|
92
|
-
* Compare filenames for sorting by numeric prefix
|
|
97
|
+
* Compare filenames for sorting by numeric prefix.
|
|
98
|
+
* Both . and , are treated as separators for sorting purposes.
|
|
99
|
+
* This ensures correct ordering: 1, 1,1, 1.5, 2, 2,1, etc.
|
|
93
100
|
*/
|
|
94
101
|
function compareFilenames(a, b) {
|
|
95
102
|
const { prefix: prefixA } = parseNumericPrefix(parse(a).name)
|
|
@@ -99,8 +106,8 @@ function compareFilenames(a, b) {
|
|
|
99
106
|
if (!prefixA) return 1
|
|
100
107
|
if (!prefixB) return -1
|
|
101
108
|
|
|
102
|
-
const partsA = prefixA.split(
|
|
103
|
-
const partsB = prefixB.split(
|
|
109
|
+
const partsA = prefixA.split(/[.,]/).map(Number)
|
|
110
|
+
const partsB = prefixB.split(/[.,]/).map(Number)
|
|
104
111
|
|
|
105
112
|
for (let i = 0; i < Math.max(partsA.length, partsB.length); i++) {
|
|
106
113
|
const numA = partsA[i] ?? 0
|
|
@@ -155,7 +162,11 @@ async function processMarkdownFile(filePath, id, siteRoot) {
|
|
|
155
162
|
}
|
|
156
163
|
|
|
157
164
|
/**
|
|
158
|
-
* Build section hierarchy from flat list
|
|
165
|
+
* Build section hierarchy from flat list.
|
|
166
|
+
* Hierarchy is determined by comma separators:
|
|
167
|
+
* - "1", "1.5", "2" → all top-level (dots are for ordering)
|
|
168
|
+
* - "1,1", "1,2" → children of section "1"
|
|
169
|
+
* - "1.5,1" → child of section "1.5"
|
|
159
170
|
*/
|
|
160
171
|
function buildSectionHierarchy(sections) {
|
|
161
172
|
const sectionMap = new Map()
|
|
@@ -166,15 +177,15 @@ function buildSectionHierarchy(sections) {
|
|
|
166
177
|
sectionMap.set(section.id, section)
|
|
167
178
|
}
|
|
168
179
|
|
|
169
|
-
// Second pass: build hierarchy
|
|
180
|
+
// Second pass: build hierarchy (comma = hierarchy)
|
|
170
181
|
for (const section of sections) {
|
|
171
|
-
if (!section.id.includes('
|
|
182
|
+
if (!section.id.includes(',')) {
|
|
172
183
|
topLevel.push(section)
|
|
173
184
|
continue
|
|
174
185
|
}
|
|
175
186
|
|
|
176
|
-
const parts = section.id.split('
|
|
177
|
-
const parentId = parts.slice(0, -1).join('
|
|
187
|
+
const parts = section.id.split(',')
|
|
188
|
+
const parentId = parts.slice(0, -1).join(',')
|
|
178
189
|
const parent = sectionMap.get(parentId)
|
|
179
190
|
|
|
180
191
|
if (parent) {
|