diff --git a/src/pages/posts/[id].astro b/src/pages/posts/[id].astro index 720d3c0..79a5580 100644 --- a/src/pages/posts/[id].astro +++ b/src/pages/posts/[id].astro @@ -1,5 +1,9 @@ --- import { getCollection, render } from 'astro:content'; +import RelatedPosts from "../../components/PostsRelacionados.astro"; // Componente para posts relacionados +import Navbar from "../../components/Navbar.astro"; +import Footer from "../../components/Footer.astro"; + // 1. Generate a new path for every collection entry export async function getStaticPaths() { const posts = await getCollection('posts'); @@ -11,6 +15,263 @@ export async function getStaticPaths() { // 2. For your template, you can get the entry directly from the prop const { post } = Astro.props; const { Content } = await render(post); + + +const postMD = await import(/* @vite-ignore */ `../../../${post.filePath}`); +const headings = postMD.getHeadings(); +const description = post.data.descripcion; + + +// URLs para compartir en redes sociales +const shareUrl = new URL(Astro.url.pathname, Astro.site).toString(); +const facebookShareUrl = `https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(shareUrl)}`; +const twitterShareUrl = `https://twitter.com/intent/tweet?url=${encodeURIComponent(shareUrl)}&text=${encodeURIComponent(post.titulo)}`; +const linkedinShareUrl = `https://www.linkedin.com/shareArticle?mini=true&url=${encodeURIComponent(shareUrl)}&title=${encodeURIComponent(post.titulo)}`; + +const blogJsonLd = { + "@context": "https://schema.org", + "@type": "BlogPosting", + "headline": post.data.titulo, + "image": post.data.imagen && new URL(post.data.imagen, Astro.site), + "datePublished": post.data.fecha, + "dateModified": post.data.fecha, + "author": { + "@type": "Person", + "name": post.data.autor + }, + "publisher": { + "@type": "Organization", + "name": "Ecobjetivos", + "logo": { + "@type": "ImageObject", + "url": new URL('/logo.png', Astro.site) + } + }, + "description": description +}; --- -