From 5ecaa5560d8c8db944f92a2c265e1a57d257cc4c Mon Sep 17 00:00:00 2001 From: Luca Bosin Date: Fri, 25 Aug 2023 16:48:04 +0200 Subject: [PATCH] Begin SEO and accessibility optimizations --- src/app.d.ts | 7 ++++++- src/app.html | 2 +- src/hooks.server.ts | 12 ++++++++++++ src/lib/components/Photo.svelte | 6 +++--- src/lib/data/language.ts | 2 ++ src/lib/util/links.ts | 4 +++- src/routes/+layout.svelte | 6 ++++++ 7 files changed, 33 insertions(+), 6 deletions(-) create mode 100644 src/hooks.server.ts diff --git a/src/app.d.ts b/src/app.d.ts index f59b884..4c8db7c 100644 --- a/src/app.d.ts +++ b/src/app.d.ts @@ -2,7 +2,12 @@ // for information about these interfaces declare global { namespace App { - // interface Error {} + /* + interface Error { + code: string; + id: string; + } + */ // interface Locals {} // interface PageData {} // interface Platform {} diff --git a/src/app.html b/src/app.html index effe0d0..5d898a9 100644 --- a/src/app.html +++ b/src/app.html @@ -1,5 +1,5 @@ - + diff --git a/src/hooks.server.ts b/src/hooks.server.ts new file mode 100644 index 0000000..02292ca --- /dev/null +++ b/src/hooks.server.ts @@ -0,0 +1,12 @@ +import type { Handle } from '@sveltejs/kit'; + +function getLanguage(event: any) { + console.log("Getting language from event", event); + return 'de'; +} + +export const handle: Handle = ({ event, resolve }) => { + return resolve(event, { + transformPageChunk: ({ html }) => html.replace('%lang%', getLanguage(event)), + }); +}; diff --git a/src/lib/components/Photo.svelte b/src/lib/components/Photo.svelte index 7d21bd1..1202138 100644 --- a/src/lib/components/Photo.svelte +++ b/src/lib/components/Photo.svelte @@ -1,5 +1,5 @@ -
  • +
  • @@ -57,7 +57,7 @@ {author}
    - +
  • diff --git a/src/lib/data/language.ts b/src/lib/data/language.ts index a841901..58ac23f 100644 --- a/src/lib/data/language.ts +++ b/src/lib/data/language.ts @@ -16,6 +16,7 @@ const translations: Record> = { 'medium': 'Mittel', 'large': 'Groß', 'open': 'Öffnen', + 'open-name': '{0} öffnen', 'download': 'Herunterladen', 'download-all': 'Alle herunterladen', }, @@ -32,6 +33,7 @@ const translations: Record> = { 'medium': 'Medium', 'large': 'Large', 'open': 'Open', + 'open-name': 'Open {0}', 'download': 'Download', 'download-all': 'Download all', } diff --git a/src/lib/util/links.ts b/src/lib/util/links.ts index 70222f6..1b19d23 100644 --- a/src/lib/util/links.ts +++ b/src/lib/util/links.ts @@ -1,3 +1,5 @@ +import { base } from '$app/paths'; + export function safe(str: string): string { return str.replace(/[^\w.-]/gi, ''); } @@ -18,5 +20,5 @@ export function getZipName(params: any): string { export function getAlbumUri(params: any): string { const { slug, timestamp } = params; - return `/g/${safe(slug)}${timestamp ? '/' + safe(timestamp) :''}`; + return `${base}/${safe(slug)}${timestamp ? '/' + safe(timestamp) :''}`; } diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index c8c4bd2..48e9c68 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -1,5 +1,11 @@ + + {$page.data.title || 'Galerie'} | bosin.ch + + +