feat: add global and per-post timezone support (#491)

* refactor: replace embedded svg with svg icon

* feat: add global and per-post timezone support

- add `SITE.timezone` in config to define a global default timezone.
- allow per-post timezone overrides via `timezone` in frontmatter.
- update date formatting logic to use the correct timezone when rendering timestamps.
- ensure that posts without a timezone fallback to `SITE.timezone`.
- improve consistency between local and deployed timezones.

* refactor: replace `LOCALE` constant with  `SITE.lang`

* docs: update guides

* fix: update code word-break inside markdown table

Closes #466
This commit is contained in:
Sat Naing
2025-03-22 17:21:21 +07:00
committed by GitHub
parent a397677d84
commit 5cff7c50b9
16 changed files with 70 additions and 86 deletions
+1 -5
View File
@@ -1,7 +1,6 @@
---
import { ClientRouter } from "astro:transitions";
import { SITE } from "@/config";
import { LOCALE } from "@/constants";
import "@/styles/global.css";
const googleSiteVerification = import.meta.env.PUBLIC_GOOGLE_SITE_VERIFICATION;
@@ -50,10 +49,7 @@ const structuredData = {
---
<!doctype html>
<html
lang=`${LOCALE.lang ?? "en"}`
class={`${scrollSmooth && "scroll-smooth"}`}
>
<html lang=`${SITE.lang ?? "en"}` class={`${scrollSmooth && "scroll-smooth"}`}>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width" />
+2 -6
View File
@@ -29,6 +29,7 @@ const {
canonicalURL,
pubDatetime,
modDatetime,
timezone,
tags,
hideEditPost,
} = post.data;
@@ -97,12 +98,7 @@ const nextPost =
{title}
</h1>
<div class="flex items-center gap-4">
<Datetime
pubDatetime={pubDatetime}
modDatetime={modDatetime}
size="lg"
class="my-2"
/>
<Datetime {pubDatetime} {modDatetime} {timezone} size="lg" class="my-2" />
<EditPost class="max-sm:hidden" {hideEditPost} {post} />
</div>
<article id="article" class="mx-auto prose mt-8 max-w-3xl">