Fix metadata and og image handling

This commit is contained in:
Mihkel Martin Kasterpalu 2025-01-22 18:08:27 +02:00
parent 4d24b90afa
commit a93db5fdf7
5 changed files with 26 additions and 20 deletions

View file

@ -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';

View file

@ -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
};
};

View file

@ -1,22 +1,22 @@
<script lang="ts">
import { siteName } from '$lib/config.js';
import { baseURL, site } from '$lib/config.js';
let { children, data } = $props();
const title = data?.name ? `${data.name} | ${site.name}` : site.name;
</script>
<svelte:head>
{#if data.name}
<title>{data.name} | {siteName}</title>
<meta property="og:title" content={data.name + ' | ' + siteName} />
{/if}
<title>{title}</title>
<meta property="og:title" content={title} />
{#if data.desctiption}
{#if data?.description}
<meta name="description" content={data.description} />
<meta property="og:description" content={data.description} />
{/if}
{#if data.image}
<meta property="og:image" content={data.image} />
{#if data?.image}
<meta property="og:image" content={baseURL + data.image} />
{/if}
</svelte:head>

View file

@ -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 @@
</script>
<svelte:head>
<meta name="author" content="Mihkel Martin Kasterpalu" />
<meta name="author" content={site.author} />
</svelte:head>
<ModeWatcher />

View file

@ -1,18 +1,18 @@
<script lang="ts">
import { games, siteName, baseURL } from '$lib/config';
import { games, site, baseURL } from '$lib/config';
</script>
<svelte:head>
<title>{siteName}</title>
<meta property="og:title" content={siteName} />
<title>{site.name}</title>
<meta property="og:title" content={site.name} />
<meta name="description" content="Minimängud ja muud huvitavat." />
<meta property="og:description" content="Minimängud ja muud huvitavat." />
<meta name="description" content={site.description} />
<meta property="og:description" content={site.description} />
<meta property="og:image" content={baseURL + '/favicon.svg'} />
<meta property="og:image" content={baseURL + site.image} />
</svelte:head>
<header class="font-title mb-24 flex flex-col items-center">
<header class="mb-24 flex flex-col items-center font-title">
<h1 class="mb-1 scroll-m-20 text-5xl font-extrabold tracking-tight lg:text-6xl">
stuff.kasterpalu.ee
</h1>