--- import MainLayout from "@/layouts/MainLayout.astro" import Header from "@/components/Header.astro" import NewsList from "@/components/cards/NewsList.astro"; import { getCollection } from "astro:content"; import FooterSection from "@/components/section/FooterSection.astro"; import { createTranslator, getRouteKeyFromSlug } from '@/i18n'; const tl = createTranslator(Astro.currentLocale); const { locale, section } = Astro.params; const routeKey = getRouteKeyFromSlug(section); const items = await getCollection(routeKey, (post)=>{ const currentLocale = Astro.currentLocale; return post.data.locale == currentLocale }); const sortedPosts = [...items] .sort((a, b) => { const dateDiff = new Date(b.data.date).getTime() - new Date(a.data.date).getTime() if (dateDiff !== 0) return dateDiff return (a.data.order ?? 0) - (b.data.order ?? 0) }); const allTags = routeKey === "news" ? [...new Set( sortedPosts .filter(p => p.data.tags && p.data.tags.length > 0) .flatMap(p => p.data.tags) .filter((tag): tag is string => tag !== undefined) )].sort() : []; const allYears = routeKey === "news" ? [...new Set( sortedPosts.map(p => new Date(p.data.date).getFullYear()) )].sort((a, b) => b - a) : []; ---

{tl(routeKey + ".title")}

{tl(routeKey + ".text")}

{routeKey === "news" && allTags.length > 0 && (
{allTags.map((tag) => ( ))}
)}
{routeKey === "news" && allYears.length > 0 && (
)} { sortedPosts.map((item) => (
)) }