@uniweb/build 0.2.1 → 0.2.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 +3 -3
- package/src/prerender.js +9 -20
- package/src/site/content-collector.js +16 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniweb/build",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Build tooling for the Uniweb Component Web Platform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"sharp": "^0.33.2"
|
|
51
51
|
},
|
|
52
52
|
"optionalDependencies": {
|
|
53
|
-
"@uniweb/content-reader": "1.0.
|
|
53
|
+
"@uniweb/content-reader": "1.0.5",
|
|
54
54
|
"@uniweb/runtime": "0.3.0"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"@tailwindcss/vite": "^4.0.0",
|
|
61
61
|
"@vitejs/plugin-react": "^4.0.0 || ^5.0.0",
|
|
62
62
|
"vite-plugin-svgr": "^4.0.0",
|
|
63
|
-
"@uniweb/core": "0.2.
|
|
63
|
+
"@uniweb/core": "0.2.2"
|
|
64
64
|
},
|
|
65
65
|
"peerDependenciesMeta": {
|
|
66
66
|
"vite": {
|
package/src/prerender.js
CHANGED
|
@@ -458,18 +458,9 @@ export async function prerenderSite(siteDir, options = {}) {
|
|
|
458
458
|
const website = uniweb.activeWebsite
|
|
459
459
|
|
|
460
460
|
for (const page of pages) {
|
|
461
|
-
//
|
|
462
|
-
// Index pages
|
|
463
|
-
|
|
464
|
-
if (page.isIndex) {
|
|
465
|
-
const navRoute = page.getNavRoute()
|
|
466
|
-
if (navRoute !== page.route) {
|
|
467
|
-
routesToRender.push(navRoute)
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
// Render once, output to multiple paths
|
|
472
|
-
onProgress(`Rendering ${routesToRender[0]}...`)
|
|
461
|
+
// Each page has a single canonical route
|
|
462
|
+
// Index pages already have their parent route as their canonical route
|
|
463
|
+
onProgress(`Rendering ${page.route}...`)
|
|
473
464
|
|
|
474
465
|
// Set this as the active page
|
|
475
466
|
uniweb.activeWebsite.setActivePage(page.route)
|
|
@@ -493,15 +484,13 @@ export async function prerenderSite(siteDir, options = {}) {
|
|
|
493
484
|
// Inject into shell
|
|
494
485
|
const html = injectContent(htmlShell, renderedContent, page, siteContent)
|
|
495
486
|
|
|
496
|
-
// Output to
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
await writeFile(outputPath, html)
|
|
487
|
+
// Output to the canonical route
|
|
488
|
+
const outputPath = getOutputPath(distDir, page.route)
|
|
489
|
+
await mkdir(dirname(outputPath), { recursive: true })
|
|
490
|
+
await writeFile(outputPath, html)
|
|
501
491
|
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
}
|
|
492
|
+
renderedFiles.push(outputPath)
|
|
493
|
+
onProgress(` → ${outputPath.replace(distDir, 'dist')}`)
|
|
505
494
|
}
|
|
506
495
|
|
|
507
496
|
onProgress(`Pre-rendered ${renderedFiles.length} pages`)
|
|
@@ -479,24 +479,31 @@ async function processPage(pagePath, pageName, siteRoot, { isIndex = false, pare
|
|
|
479
479
|
}
|
|
480
480
|
|
|
481
481
|
// Determine route
|
|
482
|
-
//
|
|
483
|
-
//
|
|
484
|
-
let route
|
|
482
|
+
// Index pages get the parent route as their canonical route (no dual routes)
|
|
483
|
+
// sourcePath stores the original folder-based path for ancestor checking
|
|
485
484
|
const isDynamic = isDynamicRoute(pageName)
|
|
486
485
|
const paramName = isDynamic ? extractRouteParam(pageName) : null
|
|
487
486
|
|
|
487
|
+
// First, calculate the folder-based route (what the route would be without index handling)
|
|
488
|
+
let folderRoute
|
|
488
489
|
if (pageName.startsWith('@')) {
|
|
489
490
|
// Special pages (layout areas) keep their @ prefix
|
|
490
|
-
|
|
491
|
+
folderRoute = parentRoute === '/' ? `/@${pageName.slice(1)}` : `${parentRoute}/@${pageName.slice(1)}`
|
|
491
492
|
} else if (isDynamic) {
|
|
492
493
|
// Dynamic routes: /blog/[slug] → /blog/:slug (for route matching)
|
|
493
|
-
|
|
494
|
-
route = parentRoute === '/' ? `/:${paramName}` : `${parentRoute}/:${paramName}`
|
|
494
|
+
folderRoute = parentRoute === '/' ? `/:${paramName}` : `${parentRoute}/:${paramName}`
|
|
495
495
|
} else {
|
|
496
496
|
// Normal pages get parent + their name
|
|
497
|
-
|
|
497
|
+
folderRoute = parentRoute === '/' ? `/${pageName}` : `${parentRoute}/${pageName}`
|
|
498
498
|
}
|
|
499
499
|
|
|
500
|
+
// For index pages, the canonical route is the parent route
|
|
501
|
+
// For non-index pages, the canonical route is the folder-based route
|
|
502
|
+
const route = isIndex ? parentRoute : folderRoute
|
|
503
|
+
// sourcePath is the original folder-based path (used for ancestor checking)
|
|
504
|
+
// Only set for index pages where it differs from route
|
|
505
|
+
const sourcePath = isIndex ? folderRoute : null
|
|
506
|
+
|
|
500
507
|
// Extract configuration
|
|
501
508
|
const { seo = {}, layout = {}, ...restConfig } = pageConfig
|
|
502
509
|
|
|
@@ -510,8 +517,9 @@ async function processPage(pagePath, pageName, siteRoot, { isIndex = false, pare
|
|
|
510
517
|
return {
|
|
511
518
|
page: {
|
|
512
519
|
route,
|
|
520
|
+
sourcePath, // Original folder-based path (for ancestor checking in navigation)
|
|
513
521
|
id: pageConfig.id || null, // Stable page ID for page: links (survives reorganization)
|
|
514
|
-
isIndex, // Marks this page as the index for its parent route
|
|
522
|
+
isIndex, // Marks this page as the index for its parent route
|
|
515
523
|
title: pageConfig.title || pageName,
|
|
516
524
|
description: pageConfig.description || '',
|
|
517
525
|
label: pageConfig.label || null, // Short label for navigation (defaults to title)
|