@zeropress/build-core 0.1.5 → 0.1.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 +1 -1
- package/src/api/build-site.js +22 -4
package/package.json
CHANGED
package/src/api/build-site.js
CHANGED
|
@@ -192,7 +192,10 @@ async function renderRoute(state, templateName, route) {
|
|
|
192
192
|
const currentUrl = normalizeRoutePath(route.path);
|
|
193
193
|
let html = await state.engine.render(
|
|
194
194
|
templateName,
|
|
195
|
-
{
|
|
195
|
+
{
|
|
196
|
+
...route,
|
|
197
|
+
meta: buildPageMeta(state.previewData.site),
|
|
198
|
+
},
|
|
196
199
|
createRenderContext(state.previewData.site, currentUrl),
|
|
197
200
|
);
|
|
198
201
|
html = state.assetProcessor.updateAssetReferences(html, state.assetMap);
|
|
@@ -204,7 +207,10 @@ async function renderPost(state, post) {
|
|
|
204
207
|
const currentUrl = `/posts/${encodeSlugSegment(post.slug)}/`;
|
|
205
208
|
let html = await state.engine.render(
|
|
206
209
|
'post',
|
|
207
|
-
{
|
|
210
|
+
{
|
|
211
|
+
post,
|
|
212
|
+
meta: buildPageMeta(state.previewData.site, post.excerpt),
|
|
213
|
+
},
|
|
208
214
|
createRenderContext(state.previewData.site, currentUrl),
|
|
209
215
|
);
|
|
210
216
|
html = state.assetProcessor.updateAssetReferences(html, state.assetMap);
|
|
@@ -225,7 +231,10 @@ async function renderPost(state, post) {
|
|
|
225
231
|
async function renderPage(state, page) {
|
|
226
232
|
let html = await state.engine.render(
|
|
227
233
|
'page',
|
|
228
|
-
{
|
|
234
|
+
{
|
|
235
|
+
page,
|
|
236
|
+
meta: buildPageMeta(state.previewData.site),
|
|
237
|
+
},
|
|
229
238
|
createRenderContext(state.previewData.site, `/${encodeSlugSegment(page.slug)}/`),
|
|
230
239
|
);
|
|
231
240
|
html = state.assetProcessor.updateAssetReferences(html, state.assetMap);
|
|
@@ -244,7 +253,9 @@ async function maybeRenderNotFoundPage(state) {
|
|
|
244
253
|
|
|
245
254
|
let html = await state.engine.render(
|
|
246
255
|
'404',
|
|
247
|
-
{
|
|
256
|
+
{
|
|
257
|
+
meta: buildPageMeta(state.previewData.site),
|
|
258
|
+
},
|
|
248
259
|
createRenderContext(state.previewData.site, '/404.html'),
|
|
249
260
|
);
|
|
250
261
|
html = state.assetProcessor.updateAssetReferences(html, state.assetMap);
|
|
@@ -820,6 +831,13 @@ function createRenderContext(site, currentUrl) {
|
|
|
820
831
|
};
|
|
821
832
|
}
|
|
822
833
|
|
|
834
|
+
function buildPageMeta(site, description = site.description) {
|
|
835
|
+
const resolvedDescription = normalizeNonEmptyString(description, site.description);
|
|
836
|
+
return {
|
|
837
|
+
description: escapeHtml(resolvedDescription),
|
|
838
|
+
};
|
|
839
|
+
}
|
|
840
|
+
|
|
823
841
|
async function writeOutput(writer, summaries, path, content, contentType) {
|
|
824
842
|
const normalizedPath = normalizeOutputPath(path);
|
|
825
843
|
await writer.write({ path: normalizedPath, content, contentType });
|