--- import { getCollection, render } from 'astro:content'; import BaseLayout from '../../layouts/BaseLayout.astro'; import BookNavigation from '../../components/BookNavigation.astro'; import "katex/dist/katex.min.css"; // @ts-expect-error Theme is not provided as ".css" import "rehype-callouts/theme/obsidian"; import "../../styles/md-custom.css"; export async function getStaticPaths() { const pages = await getCollection('book'); pages.sort((a, b) => a.id.localeCompare(b.id)); return pages.map((page, index) => { return { params: { slug: page.id }, props: { page, prevPage: index > 0 ? pages[index - 1] : null, nextPage: index < pages.length - 1 ? pages[index + 1] : null, allPages: pages } }; }); } const { page, prevPage, nextPage, allPages } = Astro.props; const { Content } = await render(page); const chapters = allPages.reduce((acc, p) => { const [chapter] = p.id.split('/'); if (!acc[chapter]) acc[chapter] = []; acc[chapter].push(p); return acc; }, {} as Record); ---

{page.data.title}

{Object.entries(chapters).map(([chapter, items]) => (

{chapter.replace(/-/g, ' ').toUpperCase()}

))}