primate 0.27.2 → 0.27.4
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 +7 -2
- package/src/dispatch.js +3 -0
package/package.json
CHANGED
package/src/app.js
CHANGED
|
@@ -151,12 +151,17 @@ export default async (log, root, config) => {
|
|
|
151
151
|
return this.path.build.join(...directories);
|
|
152
152
|
},
|
|
153
153
|
async render({ body, head }, page = config.pages.index, placeholders = {}) {
|
|
154
|
+
["body", "head"].every(used => is(placeholders[used]).undefined());
|
|
154
155
|
const { assets, config: { location, pages } } = this;
|
|
155
156
|
|
|
156
|
-
return to(
|
|
157
|
+
return to(placeholders)
|
|
158
|
+
// replace given placeholders, defaulting to ""
|
|
157
159
|
.reduce((html, [key, value]) => html.replace(`%${key}%`, value ?? ""),
|
|
158
160
|
await index(this.runpath(location.pages), page, pages.index))
|
|
159
|
-
|
|
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));
|
|
160
165
|
},
|
|
161
166
|
async inline(code, type) {
|
|
162
167
|
const integrity = await this.hash(code);
|
package/src/dispatch.js
CHANGED