From 4ded1c127d45758a463b1290af8ee70c0c6f926a Mon Sep 17 00:00:00 2001 From: ebby Date: Fri, 21 Aug 2026 14:04:52 +0200 Subject: [PATCH] date changed to german --- blog/src/components/PostPreviewLarge.astro | 3 ++- blog/src/components/PostPreviewSmall.astro | 3 ++- blog/src/layouts/BlogPostLayout.astro | 3 ++- blog/src/lib/formatDate.ts | 3 +++ 4 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 blog/src/lib/formatDate.ts diff --git a/blog/src/components/PostPreviewLarge.astro b/blog/src/components/PostPreviewLarge.astro index d124d7b..6ae8110 100644 --- a/blog/src/components/PostPreviewLarge.astro +++ b/blog/src/components/PostPreviewLarge.astro @@ -2,6 +2,7 @@ import type { Post } from "../types/global"; import { findImageByPath } from "../lib/findImage"; import { Image } from "astro:assets"; +import { formatLocalizedDateString } from "../lib/formatDate"; interface Props { post: Post; @@ -11,7 +12,7 @@ interface Props { const { post, url } = Astro.props; const img = findImageByPath(post.image.path); -const localeDate = new Date(post.date).toLocaleDateString() +const localeDate = formatLocalizedDateString(post.date) ---
diff --git a/blog/src/components/PostPreviewSmall.astro b/blog/src/components/PostPreviewSmall.astro index 24ab8ad..af28c0b 100644 --- a/blog/src/components/PostPreviewSmall.astro +++ b/blog/src/components/PostPreviewSmall.astro @@ -1,6 +1,7 @@ --- import { findImageByPath } from "../lib/findImage"; +import { formatLocalizedDateString } from "../lib/formatDate"; import type { Post } from "../types/global"; interface Props { @@ -11,7 +12,7 @@ interface Props { const { post, url } = Astro.props; const img = findImageByPath(post.image.path) -const localeDate = new Date(post.date).toLocaleDateString() +const localeDate = formatLocalizedDateString(post.date) --- diff --git a/blog/src/layouts/BlogPostLayout.astro b/blog/src/layouts/BlogPostLayout.astro index 0c7744e..d53e633 100644 --- a/blog/src/layouts/BlogPostLayout.astro +++ b/blog/src/layouts/BlogPostLayout.astro @@ -4,6 +4,7 @@ import BackNav from "../components/BackNav.astro"; import { findImageByPath } from "../lib/findImage"; import type { Post } from "../types/global"; import Main from "./Main.astro"; +import { formatLocalizedDateString } from "../lib/formatDate"; interface Props { frontmatter: Post; @@ -12,7 +13,7 @@ interface Props { const { frontmatter } = Astro.props; const titleImg = findImageByPath(frontmatter.image.path); -const localeDate = new Date(frontmatter.date).toLocaleDateString() +const localeDate = formatLocalizedDateString(frontmatter.date) ---
diff --git a/blog/src/lib/formatDate.ts b/blog/src/lib/formatDate.ts new file mode 100644 index 0000000..7108707 --- /dev/null +++ b/blog/src/lib/formatDate.ts @@ -0,0 +1,3 @@ +export function formatLocalizedDateString(date: string): string { + return new Date(date).toLocaleDateString('de-DE') +} \ No newline at end of file