--- import { getCollection, render } from "astro:content"; import { Image } from "astro:assets"; import ContentLayout from "@/layouts/content.astro"; import { getArticleSchema } from "@/lib/structuredData"; import { blogWebsite } from "@/lib/structuredData"; import { Comments } from "@/components/blog/comments"; // This is a dynamic route in SSR mode const { slug } = Astro.params; // Fetch blog posts const posts = await getCollection("blog"); const post = posts.find(post => post.id === slug); if (!post || (!import.meta.env.DEV && post.data.isDraft === true)) { return new Response(null, { status: 404, statusText: "Not found" }); } // Dynamically render the content const { Content } = await render(post); // Format the date const formattedDate = new Date(post.data.date).toLocaleDateString("en-US", { year: "numeric", month: "long", day: "numeric" }); const articleStructuredData = getArticleSchema(post); const breadcrumbsStructuredData = { "@context": "https://schema.org", "@type": "BreadcrumbList", itemListElement: [ { "@type": "ListItem", position: 1, name: "Blog", item: `${import.meta.env.SITE}/blog/`, }, { "@type": "ListItem", position: 2, name: post.data.title, item: `${import.meta.env.SITE}/blog/${post.id}/`, }, ], }; const jsonLd = { "@context": "https://schema.org", "@graph": [articleStructuredData, breadcrumbsStructuredData, blogWebsite], }; ---