@uniweb/build 0.1.29 → 0.1.31
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.
|
|
3
|
+
"version": "0.1.31",
|
|
4
4
|
"description": "Build tooling for the Uniweb Component Web Platform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
"sharp": "^0.33.2"
|
|
51
51
|
},
|
|
52
52
|
"optionalDependencies": {
|
|
53
|
-
"@uniweb/
|
|
54
|
-
"@uniweb/
|
|
53
|
+
"@uniweb/content-reader": "1.0.4",
|
|
54
|
+
"@uniweb/runtime": "0.2.17"
|
|
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.
|
|
63
|
+
"@uniweb/core": "0.1.14"
|
|
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
|
|
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:
|
|
20
|
+
* path: library/articles
|
|
21
21
|
* sort: date desc
|
|
22
22
|
*
|
|
23
23
|
* // Usage
|
|
@@ -58,11 +58,11 @@ try {
|
|
|
58
58
|
*
|
|
59
59
|
* @example
|
|
60
60
|
* // Simple form
|
|
61
|
-
* parseCollectionConfig('articles', '
|
|
61
|
+
* parseCollectionConfig('articles', 'library/articles')
|
|
62
62
|
*
|
|
63
63
|
* // Extended form
|
|
64
64
|
* parseCollectionConfig('articles', {
|
|
65
|
-
* path: '
|
|
65
|
+
* path: 'library/articles',
|
|
66
66
|
* sort: 'date desc',
|
|
67
67
|
* filter: 'published != false',
|
|
68
68
|
* limit: 100
|
|
@@ -301,8 +301,8 @@ async function collectItems(siteDir, config) {
|
|
|
301
301
|
*
|
|
302
302
|
* @example
|
|
303
303
|
* const collections = await processCollections('/path/to/site', {
|
|
304
|
-
* articles: { path: '
|
|
305
|
-
* products: '
|
|
304
|
+
* articles: { path: 'library/articles', sort: 'date desc' },
|
|
305
|
+
* products: 'library/products'
|
|
306
306
|
* })
|
|
307
307
|
* // { articles: [...], products: [...] }
|
|
308
308
|
*/
|
package/src/site/plugin.js
CHANGED
|
@@ -37,6 +37,79 @@ import { collectSiteContent } from './content-collector.js'
|
|
|
37
37
|
import { processAssets, rewriteSiteContentPaths } from './asset-processor.js'
|
|
38
38
|
import { processAdvancedAssets } from './advanced-processors.js'
|
|
39
39
|
import { processCollections, writeCollectionFiles } from './collection-processor.js'
|
|
40
|
+
import { executeFetch, mergeDataIntoContent } from './data-fetcher.js'
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Execute all fetches for site content (used in dev mode)
|
|
44
|
+
* Populates section.cascadedData with fetched data
|
|
45
|
+
*
|
|
46
|
+
* @param {Object} siteContent - The collected site content
|
|
47
|
+
* @param {string} siteDir - Path to site directory
|
|
48
|
+
*/
|
|
49
|
+
async function executeDevFetches(siteContent, siteDir) {
|
|
50
|
+
const fetchOptions = { siteRoot: siteDir, publicDir: 'public' }
|
|
51
|
+
|
|
52
|
+
// Site-level fetch
|
|
53
|
+
let siteCascadedData = {}
|
|
54
|
+
const siteFetch = siteContent.config?.fetch
|
|
55
|
+
if (siteFetch) {
|
|
56
|
+
const result = await executeFetch(siteFetch, fetchOptions)
|
|
57
|
+
if (result.data && !result.error) {
|
|
58
|
+
siteCascadedData[siteFetch.schema] = result.data
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Process each page
|
|
63
|
+
for (const page of siteContent.pages || []) {
|
|
64
|
+
let pageCascadedData = { ...siteCascadedData }
|
|
65
|
+
|
|
66
|
+
// Page-level fetch
|
|
67
|
+
const pageFetch = page.fetch
|
|
68
|
+
if (pageFetch) {
|
|
69
|
+
const result = await executeFetch(pageFetch, fetchOptions)
|
|
70
|
+
if (result.data && !result.error) {
|
|
71
|
+
pageCascadedData[pageFetch.schema] = result.data
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Process sections
|
|
76
|
+
await processDevSectionFetches(page.sections, pageCascadedData, fetchOptions)
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Process fetches for sections recursively
|
|
82
|
+
*
|
|
83
|
+
* @param {Array} sections - Sections to process
|
|
84
|
+
* @param {Object} cascadedData - Data from parent levels
|
|
85
|
+
* @param {Object} fetchOptions - Options for executeFetch
|
|
86
|
+
*/
|
|
87
|
+
async function processDevSectionFetches(sections, cascadedData, fetchOptions) {
|
|
88
|
+
if (!sections || !Array.isArray(sections)) return
|
|
89
|
+
|
|
90
|
+
for (const section of sections) {
|
|
91
|
+
// Execute section-level fetch
|
|
92
|
+
const sectionFetch = section.fetch
|
|
93
|
+
if (sectionFetch) {
|
|
94
|
+
const result = await executeFetch(sectionFetch, fetchOptions)
|
|
95
|
+
if (result.data && !result.error) {
|
|
96
|
+
// Merge fetched data into cascadedData for this section
|
|
97
|
+
cascadedData = {
|
|
98
|
+
...cascadedData,
|
|
99
|
+
[sectionFetch.schema]: result.data
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Attach cascaded data to section
|
|
105
|
+
section.cascadedData = { ...cascadedData }
|
|
106
|
+
|
|
107
|
+
// Process subsections recursively
|
|
108
|
+
if (section.subsections && section.subsections.length > 0) {
|
|
109
|
+
await processDevSectionFetches(section.subsections, cascadedData, fetchOptions)
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
40
113
|
import { generateSearchIndex, isSearchEnabled, getSearchIndexFilename } from '../search/index.js'
|
|
41
114
|
import { mergeTranslations } from '../i18n/merge.js'
|
|
42
115
|
|
|
@@ -372,6 +445,12 @@ export function siteContentPlugin(options = {}) {
|
|
|
372
445
|
await writeCollectionFiles(resolvedSitePath, collections)
|
|
373
446
|
}
|
|
374
447
|
|
|
448
|
+
// Execute data fetches in dev mode
|
|
449
|
+
// In production, prerender handles this
|
|
450
|
+
if (!isProduction) {
|
|
451
|
+
await executeDevFetches(siteContent, resolvedSitePath)
|
|
452
|
+
}
|
|
453
|
+
|
|
375
454
|
// Update localesDir from site config
|
|
376
455
|
if (siteContent.config?.i18n?.localesDir) {
|
|
377
456
|
localesDir = siteContent.config.i18n.localesDir
|
|
@@ -402,6 +481,8 @@ export function siteContentPlugin(options = {}) {
|
|
|
402
481
|
console.log('[site-content] Content changed, rebuilding...')
|
|
403
482
|
try {
|
|
404
483
|
siteContent = await collectSiteContent(resolvedSitePath)
|
|
484
|
+
// Execute fetches for the updated content
|
|
485
|
+
await executeDevFetches(siteContent, resolvedSitePath)
|
|
405
486
|
console.log(`[site-content] Rebuilt ${siteContent.pages?.length || 0} pages`)
|
|
406
487
|
|
|
407
488
|
// Send full reload to client
|