"use client"; import { Link, useNavigate, useRouterState } from "@tanstack/react-router"; import { chapters, getChapterByPath, getChapterNeighbors, type ChapterPath, } from "~/chapters/chapters"; import { cn } from "~/design-system/utils/cn"; export function ChapterSelect() { const navigate = useNavigate(); const pathname = useRouterState({ select: (state) => state.location.pathname }); const currentChapter = getChapterByPath(pathname); return ( ); } export function ChapterPager() { const pathname = useRouterState({ select: (state) => state.location.pathname }); const { current, previous, next } = getChapterNeighbors(pathname); if (!current) { return null; } return ( ); } function ChapterPagerLink(props: { direction: "previous" | "next"; chapter: (typeof chapters)[number] | undefined; }) { const { direction, chapter } = props; const isPrevious = direction === "previous"; if (!chapter) { return ( {isPrevious ? "Previous" : "Next"} End of sequence ); } return ( {isPrevious ? "Previous" : "Next"} {isPrevious ? "< " : ""} {chapter.number} / {chapter.title} {!isPrevious ? " >" : ""} ); }