working i18n conf

This commit is contained in:
Nico 2022-12-05 20:50:35 +01:00
parent 15b825bd5d
commit 1ab35db47d
19 changed files with 479 additions and 369 deletions

View file

@ -18,10 +18,12 @@ const { pageTitle, titleColor } = Astro.props;
<title>{pageTitle} - Nicolas Arduin</title>
</head>
<body>
<Header />
<main id="skip-content" role="main">
<slot/>
</main>
<div class="wrapper">
<Header />
<main id="skip-content" role="main">
<slot/>
</main>
</div>
</body>
<style define:vars={{ titleColor }}>
h1 {

View file

@ -1,28 +1,42 @@
---
import { l, t, astroI18n } from "astro-i18n";
import AstroImage from "../components/AstroImage.astro";
import BaseLayout from "../layouts/BaseLayout.astro";
const { frontmatter, image, published, title } = Astro.props;
const publishedDate = new Intl.DateTimeFormat("fr", {
const currentLocale = astroI18n.langCode;
const { frontmatter, image, title } = Astro.props;
const publishedDate = new Date(frontmatter.pubDate);
const localizedDate = new Intl.DateTimeFormat(currentLocale, {
dateStyle: "long",
}).format(published);
}).format(publishedDate);
---
<BaseLayout pageTitle={title}>
<p>Publié le&nbsp;: {frontmatter.pubDate.slice(0, 10)}</p>
<time datetime={published}>
{publishedDate}.
</time>
<p>
Publié le&nbsp;: <time datetime={frontmatter.pubDate}>
{localizedDate}.
</time>
</p>
<p>
{
t("article.published", {
datetime: frontmatter.pubDate,
options: { dateStyle: "long" },
})
}
</p>
<div class="tags">
{
frontmatter.tags.map((tag) => (
<p class="tag">
<a href={`/tags/${tag}`}>{tag}</a>
<a href={l(`/tags/${[tag]}`)}>{tag}</a>
</p>
))
}
</div>
<p>{frontmatter.description}</p>
<pre></pre>
<hr />
{
!!image && (