--- 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"; import Author from "../components/Author.astro"; import { formatDate } from "../utils/notes"; interface Props { title: string; description: string; publishDate: Date; updatedDate?: Date; image: any; tags?: string[]; } const { title, description, publishDate, updatedDate, image, tags } = Astro.props; const content = await Astro.slots.render("default"); const wordCount = content.split(/\s+/).length; const readingTime = Math.ceil(wordCount / 200); 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"), })); ---
{ image && (
{title}
) }

{title}

{description}

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

Table of Contents

) }