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

45 lines
1.0 KiB
Plaintext
Raw Normal View History

2022-12-02 11:21:18 +01:00
---
2022-12-05 20:50:35 +01:00
import { l, t, astroI18n } from "astro-i18n";
2022-12-26 23:15:27 +01:00
astroI18n.init(Astro);
2022-12-05 20:50:35 +01:00
2022-12-26 23:15:27 +01:00
// New astro content collections
import { getCollection } from "astro:content";
2022-12-02 11:21:18 +01:00
import BaseLayout from "../../layouts/BaseLayout.astro";
2022-12-28 10:36:15 +01:00
import ListCards from "../../components/ListCards.astro";
2022-12-02 11:21:18 +01:00
2022-12-26 23:15:27 +01:00
const localizedPost = await getCollection("articles", ({ data }) => {
return data.lang === astroI18n.langCode;
2022-12-05 20:50:35 +01:00
});
2022-12-28 10:36:15 +01:00
// sort articles by descending publication date
const sortedArticles = localizedPost.sort(
(a, b) => b.data.createdAt - a.data.createdAt
);
2022-12-02 17:29:11 +01:00
const pageTitle = t("index.articles.pageName");
2022-12-02 11:21:18 +01:00
---
2022-12-05 20:50:35 +01:00
<BaseLayout pageTitle={pageTitle}>
2022-12-28 10:36:15 +01:00
<section class="region flow">
<h1>{t("index.articles.pageName")}</h1>
<h2>{t("index.articles.subtitle")}</h2>
<ListCards list={sortedArticles} routeName={t("article.titre")} />
</section>
2022-12-02 11:21:18 +01:00
</BaseLayout>
2022-12-28 10:36:15 +01:00
<style>
.flow h2 + :global(*) {
margin-block-start: var(--space-m-l);
}
h1 {
text-transform: capitalize;
}
h1,
h2 {
padding-inline-start: var(--space-xs-s);
}
h2 {
color: var(--color-brique);
}
</style>