From 45a2627ec6210697740803f56a9fe3f805570e45 Mon Sep 17 00:00:00 2001 From: itsfinniii <102350242+itsfinniii@users.noreply.github.com> Date: Mon, 27 Apr 2026 15:42:38 +0200 Subject: [PATCH] Fix thumbnail for web pages --- astro/src/lib/pages.ts | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/astro/src/lib/pages.ts b/astro/src/lib/pages.ts index e4708a5..2e16235 100644 --- a/astro/src/lib/pages.ts +++ b/astro/src/lib/pages.ts @@ -4,6 +4,8 @@ import { getAlbum } from "@/content/photos/albums"; import { getAllCategories, getPhotoCategory } from "@/content/photos/categories"; import { getPhotoFromHash } from "@/content/photos/photos"; import { getProject } from "@/content/projects/projects"; +import { getImageSize } from "./images"; +import { getImage } from "astro:assets"; export async function getPage(settings: GlobalSettings, route: string): Promise { // Blog Index @@ -198,7 +200,17 @@ export async function getPage(settings: GlobalSettings, route: string): Promise< } } } + + const resizedImage = getImageSize(webpageContent.searchEngine.thumbnail.width, + webpageContent.searchEngine.thumbnail.height, 0.756); + const thumbnail = await getImage({ + src: webpageContent.searchEngine.thumbnail.url, + width: resizedImage.width, + height: resizedImage.height, + format: "jpeg" + }); + return { route: route, pageType: "Webpage", @@ -208,7 +220,14 @@ export async function getPage(settings: GlobalSettings, route: string): Promise< id: webpageContent.id, lastModified: webpageContent.lastModified, url: webpageContent.url, - searchEngine: webpageContent.searchEngine, + searchEngine: { + ...webpageContent.searchEngine, + thumbnail: { + url: `${settings.website.domainName}${thumbnail.src}`, + width: resizedImage.width, + height: resizedImage.height + } + }, components: webpageContent.components } };