Render OG data on every page

This commit is contained in:
Alex Gleason 2024-08-07 21:06:51 -05:00
parent 5f1b87c3b6
commit 2f2fda2ac3
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7

View file

@ -28,15 +28,13 @@ export const frontendController: AppMiddleware = async (c, next) => {
if (content.includes(META_PLACEHOLDER)) { if (content.includes(META_PLACEHOLDER)) {
const params = getPathParams(c.req.path); const params = getPathParams(c.req.path);
if (params) { try {
try { const entities = await getEntities(params ?? {});
const entities = await getEntities(params); const meta = renderMetadata(c.req.url, entities);
const meta = renderMetadata(c.req.url, entities); return c.html(content.replace(META_PLACEHOLDER, meta));
return c.html(content.replace(META_PLACEHOLDER, meta)); } catch (e) {
} catch (e) { console.log(`Error building meta tags: ${e}`);
console.log(`Error building meta tags: ${e}`); return c.html(content);
return c.html(content);
}
} }
} }
return c.html(content); return c.html(content);