added content

This commit is contained in:
Nico 2022-12-28 10:36:15 +01:00
parent bf2221b9a9
commit 9b91b02d90
79 changed files with 3053 additions and 284 deletions

View file

@ -17,23 +17,24 @@ const localizedSections = allSections.filter((section) => {
return section.frontmatter.lang === astroI18n.langCode;
});
// get all articles
const allArticles = await Astro.glob("../data/articles/**/*.{md,mdx}");
// only keep the right locale version
const localizedArticles = allArticles.filter((article) => {
return article.frontmatter.lang === astroI18n.langCode;
// New astro content collections
import { getCollection } from "astro:content";
// Only return posts with correct lang in the frontmatter
const localizedArticles = await getCollection("articles", ({ data }) => {
return data.lang === astroI18n.langCode;
});
// sort articles by descending publication date
const sortedArticles = localizedArticles.sort(
(a, b) => b.frontmatter.pubDate - a.frontmatter.pubDate
(a, b) => b.data.createdAt - a.data.createdAt
);
// New astro content collections
import { getCollection } from "astro:content";
// Only return posts with `draft: true` in the frontmatter
const newLocalizedArticles = await getCollection("articles", ({ data }) => {
// Only return snippets with correct lang in the frontmatter
const localizedSnippets = await getCollection("fragments", ({ data }) => {
return data.lang === astroI18n.langCode;
});
// sort articles by descending publication date
const sortedSnippets = localizedSnippets.sort(
(a, b) => b.data.createdAt - a.data.createdAt
);
---
<BaseLayout pageTitle={pageTitle}>
@ -74,10 +75,16 @@ const newLocalizedArticles = await getCollection("articles", ({ data }) => {
))
}
<section class="latest">
<div class="latest__work">
<section class="region latest">
<div class="flow latest__articles">
<h2>{t("index.latestArticles")}</h2>
<ListCards list={newLocalizedArticles} routeName={t("article.titre")} />
<ListCards list={sortedArticles} routeName={t("article.titre")} />
<p><a href={l("/articles")}>{t("index.allArticles")}</a></p>
</div>
<div class="flow latest__snippets">
<h2>{t("index.latestSnippets")}</h2>
<ListCards list={sortedSnippets} routeName={t("fragments.titre")} />
<p><a href={l("/fragments")}>{t("index.allSnippets")}</a></p>
</div>
</section>
</BaseLayout>
@ -92,9 +99,9 @@ const newLocalizedArticles = await getCollection("articles", ({ data }) => {
position: absolute;
top: -30%;
left: -10%;
max-width: 100vw;
width: 320px;
height: 320px;
max-inline-size: 100vw;
inline-size: 320px;
block-size: 320px;
z-index: -1;
border-radius: 50%;
background-color: var(--color-light-blue);
@ -121,7 +128,7 @@ const newLocalizedArticles = await getCollection("articles", ({ data }) => {
color: var(--color-dark-blue);
}
.quick-access {
margin-top: var(--space-xl-2xl);
margin-block-start: var(--space-xl-2xl);
container-type: inline-size;
container-name: intro;
}
@ -171,7 +178,7 @@ const newLocalizedArticles = await getCollection("articles", ({ data }) => {
.section__content {
order: 2;
flex-basis: 0;
min-width: 40ch;
min-inline-size: 40ch;
}
}
</style>