General structure
Table of contents
Configure chapter and page metadata
Use toc.ts in chapter and page folders to define titles, ordering, and sidebar entries.
Chapter TOC
src/book/01_Chapter/toc.ts
import type { TOCChapter } from "virtual:toc";
export const TOC: TOCChapter = {
title: "Chapter 1",
subtitle: "Optional subtitle",
};Page TOC
src/book/01_Chapter/020/toc.ts
import type { TOCPage } from "virtual:toc";
export const TOC: TOCPage = {
page_n: 20, // Page number (defines order)
slug: "my-page", // URL slug (optional)
additionalTocEntries: [ // Extra sidebar entries starting at this page
"1.2 Lesson 2",
"1.3 Summary",
],
};| Property | Description |
|---|---|
page_n | Numeric page order; can be negative (e.g. -2 for cover pages) |
slug | URL path segment; defaults to page${page_n} if omitted |
additionalTocEntries | Array of subchapter titles that start at this page |
Ordering
By default, pages and chapters are ordered alphabetically by folder name. Override with page_n in the page toc.ts or by using numeric prefixes on folder names (e.g. 001, 002).
Autocomplete
Use editor autocomplete on TOCChapter and TOCPage to discover other options.