@uniweb/build 0.4.9 → 0.4.10
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/site/asset-processor.js +12 -0
- package/src/site/assets.js +24 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniweb/build",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.10",
|
|
4
4
|
"description": "Build tooling for the Uniweb Component Web Platform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
},
|
|
52
52
|
"optionalDependencies": {
|
|
53
53
|
"@uniweb/content-reader": "1.1.2",
|
|
54
|
-
"@uniweb/runtime": "0.5.
|
|
54
|
+
"@uniweb/runtime": "0.5.11"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
57
|
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0",
|
|
@@ -261,6 +261,18 @@ export function rewriteParamPaths(params, pathMapping) {
|
|
|
261
261
|
}
|
|
262
262
|
}
|
|
263
263
|
|
|
264
|
+
// Rewrite nested paths in structured background object
|
|
265
|
+
if (result.background && typeof result.background === 'object') {
|
|
266
|
+
const bg = { ...result.background }
|
|
267
|
+
if (bg.image?.src && pathMapping[bg.image.src]) {
|
|
268
|
+
bg.image = { ...bg.image, src: pathMapping[bg.image.src] }
|
|
269
|
+
}
|
|
270
|
+
if (bg.video?.src && pathMapping[bg.video.src]) {
|
|
271
|
+
bg.video = { ...bg.video, src: pathMapping[bg.video.src] }
|
|
272
|
+
}
|
|
273
|
+
result.background = bg
|
|
274
|
+
}
|
|
275
|
+
|
|
264
276
|
return result
|
|
265
277
|
}
|
|
266
278
|
|
package/src/site/assets.js
CHANGED
|
@@ -130,8 +130,9 @@ export function resolveAssetPath(src, contextPath, siteRoot) {
|
|
|
130
130
|
return { src, resolved: null, external: true }
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
// Already absolute path on filesystem
|
|
134
|
-
|
|
133
|
+
// Already absolute path on filesystem (e.g., /Users/foo/bar.jpg)
|
|
134
|
+
// Must actually exist — otherwise it's a site-relative path like /images/hero.jpg
|
|
135
|
+
if (isAbsolute(src) && existsSync(src)) {
|
|
135
136
|
return { src, resolved: src, external: false }
|
|
136
137
|
}
|
|
137
138
|
|
|
@@ -281,6 +282,27 @@ export function collectSectionAssets(section, markdownPath, siteRoot) {
|
|
|
281
282
|
}
|
|
282
283
|
}
|
|
283
284
|
|
|
285
|
+
// Collect from structured background object
|
|
286
|
+
// Background can be { image: { src }, video: { src } } with nested asset paths
|
|
287
|
+
const bg = section.params?.background
|
|
288
|
+
if (bg && typeof bg === 'object') {
|
|
289
|
+
const bgSources = [bg.image?.src, bg.video?.src].filter(Boolean)
|
|
290
|
+
for (const src of bgSources) {
|
|
291
|
+
if (typeof src === 'string') {
|
|
292
|
+
const result = resolveAssetPath(src, markdownPath, siteRoot)
|
|
293
|
+
if (!result.external && result.resolved) {
|
|
294
|
+
assets[src] = {
|
|
295
|
+
original: src,
|
|
296
|
+
resolved: result.resolved,
|
|
297
|
+
isImage: result.isImage,
|
|
298
|
+
isVideo: result.isVideo,
|
|
299
|
+
isPdf: result.isPdf
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
284
306
|
// Collect from tagged code blocks (JSON/YAML data)
|
|
285
307
|
if (section.content) {
|
|
286
308
|
walkDataBlockAssets(section.content, (assetPath) => {
|