primate 0.27.1 → 0.27.3
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 +1 -1
- package/src/app.js +12 -3
package/package.json
CHANGED
package/src/app.js
CHANGED
|
@@ -82,7 +82,11 @@ export default async (log, root, config) => {
|
|
|
82
82
|
default: await error.exists() ? (await import(error)).default : undefined,
|
|
83
83
|
},
|
|
84
84
|
handlers: { ...handlers },
|
|
85
|
-
extensions: {
|
|
85
|
+
extensions: {
|
|
86
|
+
".html": {
|
|
87
|
+
handle: handlers.html,
|
|
88
|
+
},
|
|
89
|
+
},
|
|
86
90
|
modules: await loaders.modules(log, root, config),
|
|
87
91
|
...runtime,
|
|
88
92
|
// copy files to build folder, potentially transforming them
|
|
@@ -147,12 +151,17 @@ export default async (log, root, config) => {
|
|
|
147
151
|
return this.path.build.join(...directories);
|
|
148
152
|
},
|
|
149
153
|
async render({ body, head }, page = config.pages.index, placeholders = {}) {
|
|
154
|
+
["body", "head"].every(used => is(placeholders[used]).undefined());
|
|
150
155
|
const { assets, config: { location, pages } } = this;
|
|
151
156
|
|
|
152
|
-
return to(
|
|
157
|
+
return to(placeholders)
|
|
158
|
+
// replace given placeholders, defaulting to ""
|
|
153
159
|
.reduce((html, [key, value]) => html.replace(`%${key}%`, value ?? ""),
|
|
154
160
|
await index(this.runpath(location.pages), page, pages.index))
|
|
155
|
-
|
|
161
|
+
// replace non-given placeholders, aside from %body% / %head%
|
|
162
|
+
.replaceAll(/(?<keep>%(?:head|body)%)|%.*?%/gus, "$1")
|
|
163
|
+
// replace body and head
|
|
164
|
+
.replace("%body%", body).replace("%head%", render_head(assets, head));
|
|
156
165
|
},
|
|
157
166
|
async inline(code, type) {
|
|
158
167
|
const integrity = await this.hash(code);
|