Update project configuration and enhance translation support. Added caching mechanism for CMS responses with a new script, updated .gitignore to include cache files, and introduced translation handling in various components. Enhanced package.json with new scripts for cache warming and deployment. Added new translation-related components and improved existing ones for better localization support.

This commit is contained in:
Peter Meier
2026-03-17 22:32:31 +01:00
parent 1f5454d04e
commit daa4ea17b1
46 changed files with 5207 additions and 781 deletions
+23 -4
View File
@@ -4,6 +4,8 @@
import Pagination from "./Pagination.svelte";
import type { PostEntry } from "../lib/cms";
import { postHref } from "../lib/blog-utils";
import { t as tStatic, T } from "../lib/translations";
import type { Translations } from "../lib/translations";
interface TagEntry {
_slug?: string;
@@ -18,6 +20,7 @@
totalPages = 1,
totalPosts = 0,
basePath = "/posts",
translations = {},
}: {
posts: PostEntry[];
tags: TagEntry[];
@@ -26,8 +29,14 @@
totalPages: number;
totalPosts?: number;
basePath?: string;
translations?: Translations | null;
} = $props();
/** Immer Übersetzungen von der Astro-Seite nutzen (SSR + Insel), damit Keys wie blog_tag_all ankommen. */
function t(key: string, replacements?: Record<string, string | number>) {
return tStatic(translations ?? null, key, replacements);
}
function tagHref(tagSlug: string | null): string {
if (!tagSlug) return basePath;
return `${basePath}/tag/${encodeURIComponent(tagSlug)}`;
@@ -39,9 +48,9 @@
<div class="blog-overview">
{#if tags.length > 0}
<div class="mb-2">
<div class="flex flex-wrap gap-2" role="navigation" aria-label="Nach Tag filtern">
<div class="flex flex-wrap gap-2" role="navigation" aria-label={t(T.blog_filter_aria)}>
<Tag
label="Alle"
label={t(T.blog_tag_all)}
href={tagHref(null)}
variant={activeTag ? "blue" : "green"}
active={!activeTag}
@@ -87,9 +96,19 @@
<div class="bg-white rounded-md font-thin">
<div class="inline-flex text-xs p-2">
{#if totalCount > 0}
{posts.length} von {totalCount} Beiträgen, Seite {currentPage} von {totalPages}
{t(T.blog_count, {
visible: posts.length,
total: totalCount,
current: currentPage,
totalPages,
})}
{:else}
Seite {currentPage} von {totalPages}
{t(T.blog_count, {
visible: 0,
total: 0,
current: currentPage,
totalPages,
})}
{/if}
</div>
</div>