diff --git a/app/posts/[slug]/page.tsx b/app/posts/[slug]/page.tsx index f2de3b6..a8cc6fe 100644 --- a/app/posts/[slug]/page.tsx +++ b/app/posts/[slug]/page.tsx @@ -2,8 +2,10 @@ import Link from "next/link"; import { getPostData, getAllPostIds } from "@/lib/posts"; import type { PostData } from "@/lib/posts"; import Window from "../../../components/window"; +import TableOfContents from "../../../components/table-of-contents"; import { MDXRemote } from "next-mdx-remote/rsc"; import rehypePrettyCode from "rehype-pretty-code"; +import rehypeSlug from "rehype-slug"; interface PageProps { params: { @@ -11,13 +13,11 @@ interface PageProps { }; } -// This function tells Next.js which blog posts exist at build time export async function generateStaticParams() { const paths = getAllPostIds(); return paths.map((path) => ({ slug: path.params.slug })); } -// Generates metadata (like the title tag) for each blog post page export async function generateMetadata({ params }: PageProps) { const postData = await getPostData(params.slug); return { @@ -26,12 +26,11 @@ export async function generateMetadata({ params }: PageProps) { } export default async function Post({ params }: PageProps) { - // Fetch the specific post's content based on the URL slug const postData: PostData = await getPostData(params.slug); return ( -
- +
+
@@ -41,30 +40,54 @@ export default async function Post({ params }: PageProps) { day: "numeric", })} - - {postData.readingTime} - + {postData.readingTime}
-
- + 🚧 + This post is a work in progress — content may change. +
+ )} + + {/* Mobile TOC — shown above article, hidden on lg+ */} + {postData.headings.length > 0 && ( +
+ +
+ )} + +
+
+ + }, + }} + /> +
+ + {/* Desktop TOC sidebar — hidden on mobile */} + {postData.headings.length > 0 && ( +
+ +
+ )}
+