@uniweb/build 0.1.30 → 0.1.32

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": "@uniweb/build",
3
- "version": "0.1.30",
3
+ "version": "0.1.32",
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.0.4",
54
- "@uniweb/runtime": "0.2.17"
54
+ "@uniweb/runtime": "0.2.18"
55
55
  },
56
56
  "peerDependencies": {
57
57
  "vite": "^5.0.0 || ^6.0.0 || ^7.0.0",
@@ -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.1.13"
63
+ "@uniweb/core": "0.1.15"
64
64
  },
65
65
  "peerDependenciesMeta": {
66
66
  "vite": {
@@ -5,7 +5,7 @@
5
5
  * Collections are defined in site.yml and processed at build time.
6
6
  *
7
7
  * Features:
8
- * - Discovers markdown files in content folders
8
+ * - Discovers markdown files in collection folders
9
9
  * - Parses frontmatter for metadata
10
10
  * - Converts markdown body to ProseMirror JSON
11
11
  * - Supports filtering, sorting, and limiting
@@ -17,7 +17,7 @@
17
17
  * // site.yml
18
18
  * collections:
19
19
  * articles:
20
- * path: content/articles
20
+ * path: library/articles
21
21
  * sort: date desc
22
22
  *
23
23
  * // Usage
@@ -58,11 +58,12 @@ try {
58
58
  *
59
59
  * @example
60
60
  * // Simple form
61
- * parseCollectionConfig('articles', 'content/articles')
61
+ * parseCollectionConfig('articles', 'library/articles')
62
62
  *
63
63
  * // Extended form
64
64
  * parseCollectionConfig('articles', {
65
- * path: 'content/articles',
65
+ * path: 'library/articles',
66
+ * route: '/blog',
66
67
  * sort: 'date desc',
67
68
  * filter: 'published != false',
68
69
  * limit: 100
@@ -73,6 +74,7 @@ function parseCollectionConfig(name, config) {
73
74
  return {
74
75
  name,
75
76
  path: config,
77
+ route: null,
76
78
  sort: null,
77
79
  filter: null,
78
80
  limit: 0,
@@ -83,6 +85,7 @@ function parseCollectionConfig(name, config) {
83
85
  return {
84
86
  name,
85
87
  path: config.path,
88
+ route: config.route || null,
86
89
  sort: config.sort || null,
87
90
  filter: config.filter || null,
88
91
  limit: config.limit || 0,
@@ -274,6 +277,15 @@ async function collectItems(siteDir, config) {
274
277
  // Filter out nulls (unpublished items)
275
278
  items = items.filter(Boolean)
276
279
 
280
+ // Add routes to items if collection has a route configured
281
+ if (config.route) {
282
+ const baseRoute = config.route.replace(/\/$/, '') // Remove trailing slash
283
+ items = items.map(item => ({
284
+ ...item,
285
+ route: `${baseRoute}/${item.slug}`
286
+ }))
287
+ }
288
+
277
289
  // Apply custom filter
278
290
  if (config.filter) {
279
291
  items = applyFilter(items, config.filter)
@@ -301,8 +313,8 @@ async function collectItems(siteDir, config) {
301
313
  *
302
314
  * @example
303
315
  * const collections = await processCollections('/path/to/site', {
304
- * articles: { path: 'content/articles', sort: 'date desc' },
305
- * products: 'content/products'
316
+ * articles: { path: 'library/articles', sort: 'date desc' },
317
+ * products: 'library/products'
306
318
  * })
307
319
  * // { articles: [...], products: [...] }
308
320
  */
@@ -488,7 +488,7 @@ function determineIndexPage(orderConfig, availableFolders) {
488
488
  * @param {string} siteRoot - Site root directory for asset resolution
489
489
  * @param {Object} orderConfig - { pages: [...], index: 'name' } from parent's config
490
490
  * @param {Object} parentFetch - Parent page's fetch config (for dynamic child routes)
491
- * @returns {Promise<Object>} { pages, assetCollection, header, footer, left, right }
491
+ * @returns {Promise<Object>} { pages, assetCollection, header, footer, left, right, notFound }
492
492
  */
493
493
  async function collectPagesRecursive(dirPath, parentRoute, siteRoot, orderConfig = {}, parentFetch = null) {
494
494
  const entries = await readdir(dirPath)
@@ -502,6 +502,7 @@ async function collectPagesRecursive(dirPath, parentRoute, siteRoot, orderConfig
502
502
  let footer = null
503
503
  let left = null
504
504
  let right = null
505
+ let notFound = null
505
506
 
506
507
  // First pass: discover all page folders and read their order values
507
508
  const pageFolders = []
@@ -545,7 +546,7 @@ async function collectPagesRecursive(dirPath, parentRoute, siteRoot, orderConfig
545
546
  const { page, assetCollection: pageAssets } = result
546
547
  assetCollection = mergeAssetCollections(assetCollection, pageAssets)
547
548
 
548
- // Handle special pages (layout areas) - only at root level
549
+ // Handle special pages (layout areas and 404) - only at root level
549
550
  if (parentRoute === '/') {
550
551
  if (entry === '@header') {
551
552
  header = page
@@ -555,6 +556,8 @@ async function collectPagesRecursive(dirPath, parentRoute, siteRoot, orderConfig
555
556
  left = page
556
557
  } else if (entry === '@right') {
557
558
  right = page
559
+ } else if (entry === '404') {
560
+ notFound = page
558
561
  } else {
559
562
  pages.push(page)
560
563
  }
@@ -575,7 +578,7 @@ async function collectPagesRecursive(dirPath, parentRoute, siteRoot, orderConfig
575
578
  }
576
579
  }
577
580
 
578
- return { pages, assetCollection, header, footer, left, right }
581
+ return { pages, assetCollection, header, footer, left, right, notFound }
579
582
  }
580
583
 
581
584
  /**
@@ -608,7 +611,7 @@ export async function collectSiteContent(sitePath) {
608
611
  }
609
612
 
610
613
  // Recursively collect all pages
611
- const { pages, assetCollection, header, footer, left, right } =
614
+ const { pages, assetCollection, header, footer, left, right, notFound } =
612
615
  await collectPagesRecursive(pagesPath, '/', sitePath, siteOrderConfig)
613
616
 
614
617
  // Sort pages by order
@@ -632,6 +635,7 @@ export async function collectSiteContent(sitePath) {
632
635
  footer,
633
636
  left,
634
637
  right,
638
+ notFound,
635
639
  assets: assetCollection.assets,
636
640
  hasExplicitPoster: assetCollection.hasExplicitPoster,
637
641
  hasExplicitPreview: assetCollection.hasExplicitPreview