--- import Layout from "./Layout.astro"; import { Image } from "astro:assets"; import TagBadge from "../components/TagBadge.astro"; import BackToTop from "../components/BackToTop.astro"; import { ChevronLeft } from "@lucide/astro"; import { parse } from "node-html-parser"; interface Props { title: string; description: string; publishDate: Date; updatedDate?: Date; image: any; tags?: string[]; } const { title, description, publishDate, updatedDate, image, tags } = Astro.props; function formatDate(date: Date) { return date.toLocaleDateString("en-US", { month: "long", day: "numeric", year: "numeric", }); } // Calculate reading time (rough estimate based on word count) const content = await Astro.slots.render("default"); const wordCount = content.split(/\s+/).length; const readingTime = Math.ceil(wordCount / 200); // Average reading speed: 200 words/min const root = parse(content); const headers = root.querySelectorAll("h1, h2, h3"); const toc = headers.map((header) => ({ depth: parseInt(header.tagName.replace("H", "")), text: header.innerText.trim(), slug: header.getAttribute("id"), // Astro génère l'id automatiquement })); ---
{ image && (
{title}
) }

{title}

{description}

{readingTime} min read { updatedDate && ( <> Updated: {formatDate(updatedDate)} ) }
{ tags && tags.length > 0 && (
{tags.map((tag) => ( ))}
) }
{ toc.length > 0 && (

Table of Contents

) }