From a93db5fdf70fb0a6bf9c36284f0f5f60cbd26321 Mon Sep 17 00:00:00 2001 From: Mihkel Martin Kasterpalu Date: Wed, 22 Jan 2025 18:08:27 +0200 Subject: [PATCH] Fix metadata and og image handling --- src/lib/config.ts | 7 ++++++- src/routes/(games)/+layout.server.ts | 6 +++--- src/routes/(games)/+layout.svelte | 16 ++++++++-------- src/routes/+layout.svelte | 3 ++- src/routes/+page.svelte | 14 +++++++------- 5 files changed, 26 insertions(+), 20 deletions(-) diff --git a/src/lib/config.ts b/src/lib/config.ts index 39bcc8f..4aed43c 100644 --- a/src/lib/config.ts +++ b/src/lib/config.ts @@ -1,6 +1,11 @@ import type { GamesObj } from './types'; -export const siteName = 'Stuff.Kasterpalu'; +export const site = { + name: 'Stuff.Kasterpalu', + author: 'Mihkel Martin Kasterpalu', + description: 'Minimängud ja muud huvitavat.', + image: '/web-app-manifest-512x512.png' +}; export const baseURL = 'https://stuff.kasterpalu.ee'; diff --git a/src/routes/(games)/+layout.server.ts b/src/routes/(games)/+layout.server.ts index 4f7e758..911b523 100644 --- a/src/routes/(games)/+layout.server.ts +++ b/src/routes/(games)/+layout.server.ts @@ -1,5 +1,5 @@ import type { LayoutServerData } from './$types'; -import { games } from '$lib/config'; +import { games, site } from '$lib/config'; export const load: LayoutServerData = async ({ url }) => { if (!url?.pathname) { @@ -14,7 +14,7 @@ export const load: LayoutServerData = async ({ url }) => { return { name: game.name, - description: game.description, - image: game.image + description: game.description || site.description, + image: game.image || site.image }; }; diff --git a/src/routes/(games)/+layout.svelte b/src/routes/(games)/+layout.svelte index 2a4bf53..9d21c6d 100644 --- a/src/routes/(games)/+layout.svelte +++ b/src/routes/(games)/+layout.svelte @@ -1,22 +1,22 @@ - {#if data.name} - {data.name} | {siteName} - - {/if} + {title} + - {#if data.desctiption} + {#if data?.description} {/if} - {#if data.image} - + {#if data?.image} + {/if} diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index cfeb31c..465c3ae 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -9,6 +9,7 @@ import Sun from 'lucide-svelte/icons/sun'; import Moon from 'lucide-svelte/icons/moon'; import LaptopMinimal from 'lucide-svelte/icons/laptop-minimal'; + import { site } from '$lib/config'; let { children } = $props(); @@ -29,7 +30,7 @@ - + diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index d795cef..74e01d4 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -1,18 +1,18 @@ - {siteName} - + {site.name} + - - + + - + -
+

stuff.kasterpalu.ee