@nera-static/core 4.15.2 → 4.16.1
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 +2 -2
- package/src/core.js +6 -1
- package/src/render.js +15 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nera-static/core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.16.1",
|
|
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": {
|
|
@@ -63,8 +63,8 @@
|
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"dotenv": "^18.0.4",
|
|
65
65
|
"fs-readdir-recursive": "^1.1.0",
|
|
66
|
+
"js-beautify": "^2.0.3",
|
|
66
67
|
"markdown-it": "^15.0.0",
|
|
67
|
-
"pretty": "^2.0.0",
|
|
68
68
|
"pug": "^3.0.2",
|
|
69
69
|
"rimraf": "^6.0.1",
|
|
70
70
|
"semver": "^7.8.5",
|
package/src/core.js
CHANGED
|
@@ -96,11 +96,16 @@ export const computeFolders = (
|
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
const themeFolderExists = fs.existsSync(path.join(cwd, 'theme'))
|
|
99
|
+
// A site that names a theme package but has no presentation of its own —
|
|
100
|
+
// neither `theme/` nor a legacy root `views/` — takes the theme layout too:
|
|
101
|
+
// the theme supplies every view, and a later override lands in `theme/`.
|
|
102
|
+
const themeOnly =
|
|
103
|
+
Boolean(appConfig.theme) && !fs.existsSync(path.join(cwd, 'views'))
|
|
99
104
|
const usesDefault = (key) =>
|
|
100
105
|
folders[key] === defaultSettings.folders[key] &&
|
|
101
106
|
appConfig.folders?.[key] === undefined
|
|
102
107
|
|
|
103
|
-
if (themeFolderExists) {
|
|
108
|
+
if (themeFolderExists || themeOnly) {
|
|
104
109
|
if (usesDefault('views')) folders.views = './theme/views'
|
|
105
110
|
if (usesDefault('assets')) folders.assets = './theme/assets'
|
|
106
111
|
} else if (warn && usesDefault('views')) {
|
package/src/render.js
CHANGED
|
@@ -3,7 +3,7 @@ import fssync from 'fs'
|
|
|
3
3
|
import path from 'path'
|
|
4
4
|
import { createHash } from 'crypto'
|
|
5
5
|
import pug from 'pug'
|
|
6
|
-
import
|
|
6
|
+
import beautify from 'js-beautify'
|
|
7
7
|
import { rimraf } from 'rimraf'
|
|
8
8
|
import dotenv from 'dotenv'
|
|
9
9
|
import { makeLayeredResolver, resolveEntry } from './resolve.js'
|
|
@@ -14,6 +14,16 @@ dotenv.config({ quiet: true })
|
|
|
14
14
|
|
|
15
15
|
const SUCCESS_COLOR = '\x1b[32m%s\x1b[0m'
|
|
16
16
|
|
|
17
|
+
// The defaults of the `pretty` package, which core used until 4.16.0: calling
|
|
18
|
+
// js-beautify 2 directly keeps the output and drops the deprecated `glob@10`
|
|
19
|
+
// that `pretty` pulled in through js-beautify 1.
|
|
20
|
+
const HTML_FORMAT = {
|
|
21
|
+
unformatted: ['code', 'pre', 'em', 'strong', 'span'],
|
|
22
|
+
indent_inner_html: true,
|
|
23
|
+
indent_char: ' ',
|
|
24
|
+
indent_size: 2,
|
|
25
|
+
}
|
|
26
|
+
|
|
17
27
|
// --- Base-path URL rewriting (config `base_path` → `app.basePath`) ------------
|
|
18
28
|
//
|
|
19
29
|
// A site served from a subdirectory (e.g. GitHub *project* Pages under
|
|
@@ -449,7 +459,9 @@ export const createHtmlFiles = async (
|
|
|
449
459
|
publicFolder,
|
|
450
460
|
theme = null
|
|
451
461
|
) => {
|
|
452
|
-
|
|
462
|
+
// With a theme the site's own views folder is optional: the theme supplies
|
|
463
|
+
// every layout, and the resolver falls through a missing site root.
|
|
464
|
+
if (theme || fssync.existsSync(viewsFolder)) {
|
|
453
465
|
// No theme → single root, no resolve hook: byte-identical to before.
|
|
454
466
|
const roots = theme ? [viewsFolder, theme.viewsRoot] : [viewsFolder]
|
|
455
467
|
const resolver = theme ? makeLayeredResolver(roots) : null
|
|
@@ -510,7 +522,7 @@ export const createHtmlFiles = async (
|
|
|
510
522
|
)
|
|
511
523
|
|
|
512
524
|
await fs.mkdir(path.dirname(htmlPath), { recursive: true })
|
|
513
|
-
await fs.writeFile(htmlPath,
|
|
525
|
+
await fs.writeFile(htmlPath, beautify.html(html, HTML_FORMAT), 'utf-8')
|
|
514
526
|
|
|
515
527
|
// Name the file actually written, as its path under `public/`
|
|
516
528
|
// (`/de/index.html`), so every page gets a distinct line.
|