@uniweb/unipress 0.9.1 → 0.9.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 +5 -5
- package/src/content-loader.js +10 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniweb/unipress",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.2",
|
|
4
4
|
"description": "Compile a content directory into a document (PDF, EPUB, Paged.js HTML, Typst source bundle, DOCX, XLSX) using a Uniweb foundation. Five built-in templates: book, monograph, report, data-report, directory.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -49,11 +49,11 @@
|
|
|
49
49
|
"prompts": "^2.4.2",
|
|
50
50
|
"react": "^19.0.0",
|
|
51
51
|
"react-dom": "^19.0.0",
|
|
52
|
-
"@uniweb/build": "^0.
|
|
53
|
-
"@uniweb/semantic-parser": "^1.4.0",
|
|
52
|
+
"@uniweb/build": "^0.35.0",
|
|
54
53
|
"@uniweb/content-reader": "^1.2.4",
|
|
55
|
-
"@uniweb/
|
|
56
|
-
"@uniweb/
|
|
54
|
+
"@uniweb/runtime": "^0.13.7",
|
|
55
|
+
"@uniweb/semantic-parser": "^1.4.0",
|
|
56
|
+
"@uniweb/core": "^0.18.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"vitest": "^4.1.7"
|
package/src/content-loader.js
CHANGED
|
@@ -20,20 +20,22 @@ import { ContentDirectoryError, DocumentYmlError } from './errors.js'
|
|
|
20
20
|
// the inverse: pull the collection name back out of the resolved path.
|
|
21
21
|
const COLLECTION_PATH_RE = /^\/data\/(.+)\.json$/
|
|
22
22
|
|
|
23
|
-
function attachData(section,
|
|
24
|
-
if (!section || !
|
|
23
|
+
function attachData(section, key, data) {
|
|
24
|
+
if (!section || !key) return
|
|
25
25
|
if (!section.parsedContent) section.parsedContent = {}
|
|
26
26
|
if (!section.parsedContent.data) section.parsedContent.data = {}
|
|
27
27
|
// Don't clobber a section-level value with a cascaded page-level one.
|
|
28
28
|
// The Block constructor will spread parsedContent.data through, so the
|
|
29
29
|
// first writer wins for a given schema.
|
|
30
|
-
if (section.parsedContent.data[
|
|
31
|
-
section.parsedContent.data[
|
|
30
|
+
if (section.parsedContent.data[key] === undefined) {
|
|
31
|
+
section.parsedContent.data[key] = data
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
function findQueryRecords(fetchConfig, resolved) {
|
|
36
|
-
|
|
36
|
+
// `as` is the binding key; `schema` is its pre-2026-09-02 name, still on any
|
|
37
|
+
// payload written before then.
|
|
38
|
+
if (!fetchConfig?.path || !(fetchConfig.as ?? fetchConfig.schema)) return null
|
|
37
39
|
const m = COLLECTION_PATH_RE.exec(fetchConfig.path)
|
|
38
40
|
if (!m) return null
|
|
39
41
|
const records = resolved[m[1]]
|
|
@@ -52,8 +54,8 @@ function attachSectionFetches(sections, resolved, cascade = null) {
|
|
|
52
54
|
if (!Array.isArray(sections)) return
|
|
53
55
|
for (const section of sections) {
|
|
54
56
|
const records = findQueryRecords(section.fetch, resolved)
|
|
55
|
-
if (records) attachData(section, section.fetch.schema, records)
|
|
56
|
-
if (cascade) attachData(section, cascade.
|
|
57
|
+
if (records) attachData(section, section.fetch.as ?? section.fetch.schema, records)
|
|
58
|
+
if (cascade) attachData(section, cascade.key, cascade.records)
|
|
57
59
|
if (Array.isArray(section.subsections) && section.subsections.length) {
|
|
58
60
|
attachSectionFetches(section.subsections, resolved, cascade)
|
|
59
61
|
}
|
|
@@ -120,7 +122,7 @@ async function resolveLocalQueries(siteContent, sitePath) {
|
|
|
120
122
|
// section tree; a section's own fetch still takes priority.
|
|
121
123
|
const pageRecords = findQueryRecords(page.fetch, resolved)
|
|
122
124
|
const cascade = pageRecords
|
|
123
|
-
? {
|
|
125
|
+
? { key: page.fetch.as ?? page.fetch.schema, records: pageRecords }
|
|
124
126
|
: null
|
|
125
127
|
attachSectionFetches(page.sections, resolved, cascade)
|
|
126
128
|
}
|