better sitemap organization

This commit is contained in:
nico 2024-12-29 14:49:35 +01:00
parent b2b6887fdf
commit 65c6003313
7 changed files with 57 additions and 27 deletions

View file

@ -5,12 +5,18 @@ import BaseLayout from '../layouts/BaseLayout.astro'
import { getCollection } from 'astro:content'
// get all articles
const allArticles = await getCollection('articles', ({ data }) => {
return !data.draft
const frArticles = await getCollection('articles', ({ data }) => {
return !data.draft && data.lang === 'fr'
})
const enArticles = await getCollection('articles', ({ data }) => {
return !data.draft && data.lang === 'en'
})
// get all snippets
const allFragments = await getCollection('fragments', ({ data }) => {
return !data.draft
const frFragments = await getCollection('fragments', ({ data }) => {
return !data.draft && data.lang === 'fr'
})
const enFragments = await getCollection('fragments', ({ data }) => {
return !data.draft && data.lang === 'en'
})
const pageTitle = 'Plan du site'
@ -29,36 +35,63 @@ const pageTitle = 'Plan du site'
<h2>
<a href='/articles'>Articles</a>
</h2>
<h3>Articles en français</h3>
<ul>
{
allArticles.map((article) => (
frArticles.map((article) => (
<li>
<a href={`/articles/${article.data.slug}`}>
{article.data.title} <sup>({article.data.lang})</sup>
{article.data.title}
</a>
</li>
))
}
</ul>
<div lang='en'>
<h3>Articles in english</h3>
<ul>
{
enArticles.map((article) => (
<li>
<a href={`/articles/${article.data.slug}`}>
{article.data.title}
</a>
</li>
))
}
</ul>
</div>
</li>
<li>
<h2>
<a href='/fragments'>Fragments</a>
</h2>
<h3>Fragments en français</h3>
<ul>
{
allFragments.map((fragment) => (
frFragments.map((fragment) => (
<li>
<a
href={`/fragments/${fragment.id}`}
lang={fragment.data.lang !== 'fr' ? fragment.data.lang : null}
>
{fragment.data.title} <sup>({fragment.data.lang})</sup>
<a href={`/fragments/${fragment.data.slug}`}>
{fragment.data.title}
</a>
</li>
))
}
</ul>
<div lang='en'>
<h3>Snippets in english</h3>
<ul>
{
enFragments.map((fragment) => (
<li>
<a href={`/fragments/${fragment.data.slug}`}>
{fragment.data.title}
</a>
</li>
))
}
</ul>
</div>
</li>
<li>
<h2>