@uniweb/build 1.15.4 → 1.15.6
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 +6 -6
- package/src/prerender.js +89 -4
- package/src/site/content-collector.js +31 -22
- package/src/site/file-links.js +91 -26
- package/src/site/index.js +3 -0
- package/src/site/mount-entries.js +46 -0
- package/src/uwx/body-splice.js +85 -0
- package/src/uwx/data-schema.js +4 -0
- package/src/uwx/emit-surface.json +0 -3
- package/src/uwx/index.js +3 -0
- package/src/uwx/page-files.js +255 -0
- package/src/uwx/project-writer.js +19 -3
- package/src/uwx/same-content.js +7 -4
- package/src/uwx/site-dirs.js +50 -6
- package/src/uwx/site-project.js +373 -49
- package/src/uwx/site.js +5 -2
- package/src/uwx/git-authored.js +0 -85
package/src/uwx/git-authored.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
// The pages a pull leaves alone: those authored in files a pull cannot write back.
|
|
2
|
-
//
|
|
3
|
-
// ⭐ Two kinds, decided 2026-10-23 [Diego: the pull leaves them alone, since the docs are written in
|
|
4
|
-
// git]. A push sends both whole, read by the build's own rules (`site.js`), so the backend holds
|
|
5
|
-
// the site as the build makes it. A pull writes neither:
|
|
6
|
-
//
|
|
7
|
-
// · every page under a `paths: { pages/<segment>: <dir> }` mount. Its files are another
|
|
8
|
-
// repository's, outside the site; the local folder of that name holds only how this site
|
|
9
|
-
// presents them, and a pull writing the mounted pages into it would grow a second copy there.
|
|
10
|
-
// · every `.md` page of a folder-mode folder. The file IS the page, and a pull writes a page as a
|
|
11
|
-
// folder (`page.yml` + its sections), which would turn the author's folder of pages into a
|
|
12
|
-
// folder of page folders.
|
|
13
|
-
//
|
|
14
|
-
// ⇒ An edit made to one of these pages in the app is not brought back, and the next push replaces
|
|
15
|
-
// it with the file. Pruning skips them too: a pull never deletes what it does not write.
|
|
16
|
-
//
|
|
17
|
-
// A leaf module, read synchronously as the pull projects (`site-project.js`), through the build's
|
|
18
|
-
// mode rule (`folderContentMode`) and its folder-mode page list (`folderModePageFiles`), so the set
|
|
19
|
-
// is the one the push walks.
|
|
20
|
-
|
|
21
|
-
import { existsSync, readdirSync, readFileSync } from 'node:fs'
|
|
22
|
-
import { join } from 'node:path'
|
|
23
|
-
import yaml from 'js-yaml'
|
|
24
|
-
import { YAML_OPTIONS } from '../utils/yaml-schema.js'
|
|
25
|
-
import { isIgnoredFolder } from '../utils/content-files.js'
|
|
26
|
-
import { folderContentMode, folderModePageFiles, mountEntriesOf, parseNumericPrefix } from '../site/content-collector.js'
|
|
27
|
-
|
|
28
|
-
const DYNAMIC_RE = /^\[(.+)\]$/
|
|
29
|
-
|
|
30
|
-
// The collector's own reading of a config file (`parseYaml`): absent or unreadable is empty.
|
|
31
|
-
function readYaml(filePath) {
|
|
32
|
-
try {
|
|
33
|
-
return yaml.load(readFileSync(filePath, 'utf8'), YAML_OPTIONS) || {}
|
|
34
|
-
} catch {
|
|
35
|
-
return {}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// A folder's mode, as `readFolderConfig` reads it.
|
|
40
|
-
function modeOf(dir, inheritedMode) {
|
|
41
|
-
const folderYml = readYaml(join(dir, 'folder.yml'))
|
|
42
|
-
const pageYml = Object.keys(folderYml).length > 0 ? {} : readYaml(join(dir, 'page.yml'))
|
|
43
|
-
return folderContentMode(folderYml, pageYml, existsSync(join(dir, 'folder.yml')), inheritedMode).mode
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* The pages of a site a pull leaves alone, by route: each a slug path with no leading slash
|
|
48
|
-
* (`docs/start/install`), as the pull composes a page's route from the document.
|
|
49
|
-
*
|
|
50
|
-
* @param {object|null} siteYml - the parsed `site.yml`
|
|
51
|
-
* @param {string} pagesDir - the site's pages directory (`siteContentDirs`)
|
|
52
|
-
* @returns {{ mounted: Set<string>, files: Set<string>, has: (route: string) => boolean }}
|
|
53
|
-
* `mounted` — the mounted segments, each leaving its whole route alone; `files` — the routes of
|
|
54
|
-
* folder-mode `.md` pages; `has` — whether a route is either
|
|
55
|
-
*/
|
|
56
|
-
export function gitAuthoredPages(siteYml, pagesDir) {
|
|
57
|
-
const mounted = new Set(mountEntriesOf(siteYml?.paths).map(([segment]) => segment))
|
|
58
|
-
const files = new Set()
|
|
59
|
-
const walk = (dir, prefix, inheritedMode) => {
|
|
60
|
-
let entries
|
|
61
|
-
try {
|
|
62
|
-
entries = readdirSync(dir, { withFileTypes: true })
|
|
63
|
-
} catch {
|
|
64
|
-
return
|
|
65
|
-
}
|
|
66
|
-
const mode = modeOf(dir, inheritedMode)
|
|
67
|
-
if (mode === 'pages') {
|
|
68
|
-
for (const { name } of folderModePageFiles(entries.map((e) => e.name)).files) {
|
|
69
|
-
files.add(prefix + name)
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
for (const e of entries) {
|
|
73
|
-
if (!e.isDirectory() || isIgnoredFolder(e.name)) continue
|
|
74
|
-
if (!prefix && mounted.has(e.name)) continue // the whole route is left alone
|
|
75
|
-
const dyn = e.name.match(DYNAMIC_RE)
|
|
76
|
-
walk(join(dir, e.name), `${prefix}${dyn ? dyn[1] : parseNumericPrefix(e.name).name}/`, mode)
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
if (existsSync(pagesDir)) walk(pagesDir, '', 'sections')
|
|
80
|
-
return {
|
|
81
|
-
mounted,
|
|
82
|
-
files,
|
|
83
|
-
has: (route) => mounted.has(String(route).split('/')[0]) || files.has(route),
|
|
84
|
-
}
|
|
85
|
-
}
|