--- 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 DynamicForm from "@/components/forms/DynamicForm.vue"; import { createTranslator, getRouteKeyFromSlug } from '@/i18n'; const tl = createTranslator(Astro.currentLocale); const { locale, section } = Astro.params; const routeKey = getRouteKeyFromSlug(section); if (routeKey === "formulario") { if (!["es", "en", "pt"].includes(Astro.currentLocale)) { return Astro.redirect(`/${Astro.currentLocale}/`); } } else if (routeKey === "terminos") { // rendered client-side } else { var items = await getCollection(routeKey, (post)=>{ const currentLocale = Astro.currentLocale; return post.data.locale == currentLocale }); var 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) }); var 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() : []; var allYears = routeKey === "news" ? [...new Set( sortedPosts.map(p => new Date(p.data.date).getFullYear()) )].sort((a, b) => b - a) : []; } --- {routeKey === "formulario" && (
)} {routeKey !== "formulario" && (
)} {routeKey === "formulario" && (

{tl("form.page_title")}

)} {routeKey === "terminos" && (

{tl("terminos.title")}

{tl("terminos.text")}...

)} {routeKey !== "formulario" && routeKey !== "terminos" && (

{tl(routeKey + ".title")}

{tl(routeKey + ".text")}

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