website-astro/src/pages/articles/index.astro

33 lines
751 B
Plaintext

---
import { l, t, astroI18n } from "astro-i18n";
astroI18n.init(Astro);
// New astro content collections
import { getCollection } from "astro:content";
import BaseLayout from "../../layouts/BaseLayout.astro";
import ContentPost from "../../components/ContentPost.astro";
const localizedPost = await getCollection("articles", ({ data }) => {
return data.lang === astroI18n.langCode;
});
const pageTitle = t("index.articles.pageName");
---
<BaseLayout pageTitle={pageTitle}>
<h2>{t("index.articles.pageName")}</h2>
<p>{t("index.articles.subtitle")}</p>
<ul>
{
localizedPost.map((post) => (
<li>
<a href={l("/articles/[slug]", { slug: post.data.slug })}>
{post.data.title}
</a>
</li>
))
}
</ul>
</BaseLayout>