Fixes for custom url view

This commit is contained in:
Kuba Orlik 2025-03-02 22:27:17 +01:00
parent 01c68aa645
commit 1a809e58e2

View File

@ -20,10 +20,9 @@ interface ContextState {
export const customUrlView =
(app: TheApp) => async (ctx: Context & ContextState, next: Next) => {
try {
console.log("CUSTOM URL VIEW");
if (ctx.body) return;
console.log("doesn't have body");
const main_domain = new URL(BASE_URL).hostname;
const {
items: [page],
} = await app.collections.pages
@ -49,9 +48,11 @@ export const customUrlView =
const title = page.get("title");
const heading = page.get("heading");
const hideNavigation = page.get("hideNavigation") || false;
const metaImage =
(page.get("imageForMetadata") as FilePointer) || undefined;
ctx.body = html({
ctx,
title: title || "Aspazja",
title: title || ctx.$app.manifest.name,
description: page.get("description") || "",
css_clumps: jdd.getAllCSSClumps(),
hideNavigation,
@ -66,12 +67,14 @@ export const customUrlView =
),
makeHead: (...args) =>
tempstream`${defaultHead(...args)}${jdd.renderEarlyAssets()}`,
metaImage: await imageRouter.singleImage(
await (page.get("imageForMetadata") as FilePointer).getPath(),
metaImage: metaImage
? await imageRouter.singleImage(
await metaImage.getPath(),
400,
"jpeg",
false
),
)
: "",
});
}
} catch (err) {