--- import BaseLayout from "@/layouts/BaseLayout.astro"; import Schema from "@/components/seo/Schema.astro"; import Tags from "@/components/ui/Tags.astro"; import Categories from "@/components/ui/Categories.astro"; import Destinations from "@/components/ui/Destinations.astro"; import { toR2Url } from "@/utils/r2"; import Picture from "@/components/ui/Picture.astro"; import { getCollection, render, type CollectionEntry } from "astro:content"; interface Props { post: CollectionEntry<"blog">; } export async function getStaticPaths() { const blog = await getCollection("blog"); return blog.map((post) => ({ params: { slug: post.id }, props: { post }, })); } const { post } = Astro.props as Props; const { Content, remarkPluginFrontmatter } = await render(post); const { title, description, pubDate, author, image, categories, tags, destination, } = post.data; const coverImage = toR2Url(image); const formattedDate = pubDate.toLocaleDateString("vi-VN", { year: "numeric", month: "long", day: "numeric", }); const readingTime = remarkPluginFrontmatter?.minutesRead ? `${Math.ceil(remarkPluginFrontmatter.minutesRead)} phút đọc` : ""; const metadata = { title: title, description: description, ogImage: coverImage, }; ---
{ categories && categories.length > 0 && (
) }

{formattedDate} • {author} {readingTime && ` • ${readingTime}`}

{title}

{ destination && destination.length > 0 && (
) }
{ coverImage && (
) }
{ tags && tags.length > 0 && (
) }