@uniweb/kit 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.
- package/package.json +2 -2
- package/src/index.js +2 -0
- package/src/utils/index.js +6 -0
- package/src/utils/splitContent.js +23 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniweb/kit",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.2",
|
|
4
4
|
"description": "Standard component library for Uniweb foundations",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"fuse.js": "^7.0.0",
|
|
39
39
|
"shiki": "^3.0.0",
|
|
40
40
|
"tailwind-merge": "^2.6.0",
|
|
41
|
-
"@uniweb/core": "0.6.
|
|
41
|
+
"@uniweb/core": "0.6.1"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"react": "^18.0.0 || ^19.0.0",
|
package/src/index.js
CHANGED
package/src/utils/index.js
CHANGED
|
@@ -237,6 +237,12 @@ export function isFileUrl(url) {
|
|
|
237
237
|
return fileExtensions.some(ext => lowerUrl.includes(ext))
|
|
238
238
|
}
|
|
239
239
|
|
|
240
|
+
// ─────────────────────────────────────────────────────────────────
|
|
241
|
+
// Content Utilities
|
|
242
|
+
// ─────────────────────────────────────────────────────────────────
|
|
243
|
+
|
|
244
|
+
export { splitContent } from './splitContent.js'
|
|
245
|
+
|
|
240
246
|
/**
|
|
241
247
|
* Detect media type from URL
|
|
242
248
|
* @param {string} url
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Split parsed content at divider elements in the sequence.
|
|
3
|
+
*
|
|
4
|
+
* Returns an array of content-like objects — one per region between
|
|
5
|
+
* dividers. Each object is a shallow copy of the original content
|
|
6
|
+
* with its own `sequence` slice. Grouped fields (title, paragraphs,
|
|
7
|
+
* items, etc.) are preserved from the original — only `sequence` is
|
|
8
|
+
* split. If no divider exists, returns a single-element array
|
|
9
|
+
* containing the original content.
|
|
10
|
+
*
|
|
11
|
+
* @param {Object} content - Parsed content from semantic parser
|
|
12
|
+
* @returns {Array<Object>} Array of content objects with split sequences
|
|
13
|
+
*/
|
|
14
|
+
export function splitContent(content) {
|
|
15
|
+
const seq = content.sequence || []
|
|
16
|
+
const segments = [[]]
|
|
17
|
+
for (const el of seq) {
|
|
18
|
+
if (el.type === 'divider') segments.push([])
|
|
19
|
+
else segments[segments.length - 1].push(el)
|
|
20
|
+
}
|
|
21
|
+
if (segments.length === 1) return [content]
|
|
22
|
+
return segments.map(s => ({ ...content, sequence: s }))
|
|
23
|
+
}
|