Fixes for custom url view
This commit is contained in:
parent
01c68aa645
commit
1a809e58e2
@ -20,10 +20,9 @@ interface ContextState {
|
|||||||
export const customUrlView =
|
export const customUrlView =
|
||||||
(app: TheApp) => async (ctx: Context & ContextState, next: Next) => {
|
(app: TheApp) => async (ctx: Context & ContextState, next: Next) => {
|
||||||
try {
|
try {
|
||||||
console.log("CUSTOM URL VIEW");
|
|
||||||
if (ctx.body) return;
|
if (ctx.body) return;
|
||||||
console.log("doesn't have body");
|
|
||||||
const main_domain = new URL(BASE_URL).hostname;
|
const main_domain = new URL(BASE_URL).hostname;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
items: [page],
|
items: [page],
|
||||||
} = await app.collections.pages
|
} = await app.collections.pages
|
||||||
@ -49,9 +48,11 @@ export const customUrlView =
|
|||||||
const title = page.get("title");
|
const title = page.get("title");
|
||||||
const heading = page.get("heading");
|
const heading = page.get("heading");
|
||||||
const hideNavigation = page.get("hideNavigation") || false;
|
const hideNavigation = page.get("hideNavigation") || false;
|
||||||
|
const metaImage =
|
||||||
|
(page.get("imageForMetadata") as FilePointer) || undefined;
|
||||||
ctx.body = html({
|
ctx.body = html({
|
||||||
ctx,
|
ctx,
|
||||||
title: title || "Aspazja",
|
title: title || ctx.$app.manifest.name,
|
||||||
description: page.get("description") || "",
|
description: page.get("description") || "",
|
||||||
css_clumps: jdd.getAllCSSClumps(),
|
css_clumps: jdd.getAllCSSClumps(),
|
||||||
hideNavigation,
|
hideNavigation,
|
||||||
@ -66,12 +67,14 @@ export const customUrlView =
|
|||||||
),
|
),
|
||||||
makeHead: (...args) =>
|
makeHead: (...args) =>
|
||||||
tempstream`${defaultHead(...args)}${jdd.renderEarlyAssets()}`,
|
tempstream`${defaultHead(...args)}${jdd.renderEarlyAssets()}`,
|
||||||
metaImage: await imageRouter.singleImage(
|
metaImage: metaImage
|
||||||
await (page.get("imageForMetadata") as FilePointer).getPath(),
|
? await imageRouter.singleImage(
|
||||||
400,
|
await metaImage.getPath(),
|
||||||
"jpeg",
|
400,
|
||||||
false
|
"jpeg",
|
||||||
),
|
false
|
||||||
|
)
|
||||||
|
: "",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user