--- import { YouTube } from "astro-embed"; import MainLayout from "../../../layouts/MainLayout.astro"; import Header from "../../../components/Header.astro"; import CarouselSection from "../../../components/section/CarouselSection.astro"; import { Image } from "@unpic/astro"; import { getCollection, render } from "astro:content"; import TitleSection from "../../../components/section/TitleSection.astro"; import FooterSection from "../../../components/section/FooterSection.astro"; import { getLocalizedRoute } from "@/i18n"; export const prerender = true; export async function getStaticPaths() { const paths = []; for (const collection of ["news", "editorial"]) { const posts = await getCollection(collection); for (const post of posts) { paths.push({ params: { id: post.id, locale: post.data.locale, section: getLocalizedRoute(collection, post.data.locale), }, props: { post }, }); } } return paths; } const { locale, section } = Astro.params; const { post } = Astro.props; const routeKey = post.collection; const { Content } = await render(post); const rawContent = post.body || ""; const plainText = rawContent .replace(/^#.*$/gm, "") .replace(/^###.*$/gm, "") .replace(/\*\*([^*]+)\*\*/g, "$1") .replace(/\*([^*]+)\*/g, "$1") .replace(/_([^_]+)_/g, "$1") .replace(/\[([^\]]+)\]\([^)]+\)/g, "$1") .replace(/^>.*$/gm, "") .replace(/`[^`]+`/g, "") .replace(/^[-*]\s+/gm, "") .trim(); const words = plainText .split(/\s+/) .filter((w) => w.length > 0) .slice(0, 35); const excerpt = words.join(" ") + (words.length === 35 ? "..." : ""); const canonicalUrl = new URL(`/${locale}/${section}/${post.id}`, Astro.site); const imageUrl = post.data.thumbnail ? new URL(post.data.thumbnail, Astro.site).toString() : null; const localeDate = new Intl.DateTimeFormat(locale || "es", { year: "numeric", month: "long", day: "numeric", }).format(post.data.date); const y = post.data.date.getFullYear(); const m = String(post.data.date.getMonth() + 1).padStart(2, "0"); const d = String(post.data.date.getDate()).padStart(2, "0"); const dateISO = `${y}-${m}-${d}`; const schemaType = routeKey === "news" ? "NewsArticle" : "Article"; ---
{ post.data.gallery?.length ? ( ) : post.data.thumbnail ? ( {post.data.title} ) : null }
{post.data.youtube && } { post.data.gallery && post.data.gallery.map((galleryImage, i) => ( )) }