@nera-static/core 4.11.3 → 4.12.0
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/README.md +5 -1
- package/package.json +1 -1
- package/src/index.js +3 -0
- package/src/theme.js +19 -2
package/README.md
CHANGED
|
@@ -113,7 +113,11 @@ Rendering uses [Pug](https://pugjs.org/). Templates receive:
|
|
|
113
113
|
- `t(key)`: translation helper — resolves `app.translations[meta.lang || app.lang][key]`, falling back to the key itself
|
|
114
114
|
- `url(path)`: prefixes a root-absolute path with the site's `base_path` (a no-op when unset)
|
|
115
115
|
|
|
116
|
-
Views resolve **layered**: a site's `theme/views/<file>` overrides an installed theme package's same-path file, WordPress child-theme style. A themeless site renders exactly as before this layer existed.
|
|
116
|
+
Views resolve **layered**: a site's `theme/views/<file>` overrides an installed theme package's same-path file, WordPress child-theme style. A themeless site renders exactly as before this layer existed.
|
|
117
|
+
|
|
118
|
+
The `NERA_THEME` environment variable overrides `theme:` in `config/app.yaml` for one run, in any of its forms (`NERA_THEME=./themes/classic nera build`), so you can build or preview another design without editing the config. An empty value falls back to `app.yaml`.
|
|
119
|
+
|
|
120
|
+
The design lives in [`ROADMAP-themes.md`](./ROADMAP-themes.md); the consolidation that made this package importable is in [`ROADMAP-core.md`](./ROADMAP-core.md).
|
|
117
121
|
|
|
118
122
|
---
|
|
119
123
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nera-static/core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.12.0",
|
|
4
4
|
"description": "The Nera static site generator engine — the build pipeline and the layered theme/view resolver, importable by the Nera CLI, @nera-static/validate and tooling",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"exports": {
|
package/src/index.js
CHANGED
|
@@ -15,6 +15,9 @@ const run = async (settings = defaultSettings) => {
|
|
|
15
15
|
// Discover the configured theme (ROADMAP-themes.md §1). Null when no
|
|
16
16
|
// `theme:` key is set, in which case render behaves exactly as before.
|
|
17
17
|
const theme = resolveTheme({ app: data.app })
|
|
18
|
+
if (theme && process.env.NERA_THEME) {
|
|
19
|
+
console.log(`🎨 Nera: using theme "${theme.name}" (from NERA_THEME)`)
|
|
20
|
+
}
|
|
18
21
|
|
|
19
22
|
// Verify the theme's compatibility declarations before doing any work (§5):
|
|
20
23
|
// a nera.generator range that excludes THIS generator fails the build (a
|
package/src/theme.js
CHANGED
|
@@ -24,8 +24,18 @@ import { satisfies, validRange } from 'semver'
|
|
|
24
24
|
// The returned `config` is the theme's `config/theme.yaml` defaults deep-merged
|
|
25
25
|
// with the site's optional `config/theme.yaml` (§1c). The pipeline exposes the
|
|
26
26
|
// whole result to templates as `app.theme = { name, package, config }`.
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
//
|
|
28
|
+
// The NERA_THEME environment variable, when set and non-empty, takes the place
|
|
29
|
+
// of `app.theme` — in any of the three forms — so a site can build or preview
|
|
30
|
+
// another design without editing app.yaml (`NERA_THEME=./themes/classic nera
|
|
31
|
+
// build`). It is read here, the one place every consumer resolves a theme
|
|
32
|
+
// through, so build, dev and validate (via resolveSiteModel) all agree on it.
|
|
33
|
+
export function resolveTheme({
|
|
34
|
+
app,
|
|
35
|
+
cwd = process.cwd(),
|
|
36
|
+
env = process.env,
|
|
37
|
+
} = {}) {
|
|
38
|
+
const spec = themeSpec(app, env)
|
|
29
39
|
if (!spec) return null
|
|
30
40
|
|
|
31
41
|
const isLocal = spec.startsWith('.')
|
|
@@ -55,6 +65,13 @@ export function resolveTheme({ app, cwd = process.cwd() } = {}) {
|
|
|
55
65
|
}
|
|
56
66
|
}
|
|
57
67
|
|
|
68
|
+
// The theme spec in effect: NERA_THEME over `app.theme`. An empty NERA_THEME is
|
|
69
|
+
// treated as unset, so `NERA_THEME= nera build` falls back to app.yaml rather
|
|
70
|
+
// than silently building themeless.
|
|
71
|
+
export function themeSpec(app, env = process.env) {
|
|
72
|
+
return env?.NERA_THEME || app?.theme || null
|
|
73
|
+
}
|
|
74
|
+
|
|
58
75
|
// §1c: the theme package ships `config/theme.yaml` (at its root) with real
|
|
59
76
|
// defaults; the site's `config/theme.yaml` (at the site's config folder — config
|
|
60
77
|
// stays out of `theme/`) is optional and deep-merges OVER those defaults.
|