added content collections base config
This commit is contained in:
parent
23c79e579c
commit
346c154259
10 changed files with 532 additions and 20 deletions
|
@ -6,7 +6,6 @@ astroI18n.init(Astro);
|
|||
// import stuff
|
||||
import BaseLayout from "../layouts/BaseLayout.astro";
|
||||
import QuickAccessCard from "../components/QuickAccessCard.astro";
|
||||
import CardEditorial from "../components/CardEditorial.astro";
|
||||
import ListCards from "../components/ListCards.astro";
|
||||
|
||||
const pageTitle = t("accueil");
|
||||
|
@ -28,6 +27,13 @@ const localizedArticles = allArticles.filter((article) => {
|
|||
const sortedArticles = localizedArticles.sort(
|
||||
(a, b) => b.frontmatter.pubDate - a.frontmatter.pubDate
|
||||
);
|
||||
|
||||
// New astro content collections
|
||||
import { getCollection } from "astro:content";
|
||||
// Only return posts with `draft: true` in the frontmatter
|
||||
const newLocalizedArticles = await getCollection("articles", ({ data }) => {
|
||||
return data.lang === astroI18n.langCode;
|
||||
});
|
||||
---
|
||||
|
||||
<BaseLayout pageTitle={pageTitle}>
|
||||
|
@ -71,7 +77,7 @@ const sortedArticles = localizedArticles.sort(
|
|||
<section class="latest">
|
||||
<div class="latest__work">
|
||||
<h2>{t("index.latestArticles")}</h2>
|
||||
<ListCards list={sortedArticles} routeName={t("article.titre")} />
|
||||
<ListCards list={newLocalizedArticles} routeName={t("article.titre")} />
|
||||
</div>
|
||||
</section>
|
||||
</BaseLayout>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue