import { useState } from 'react'; import { useAsync } from '../lib/useAsync'; import { cn } from '../lib/utils'; interface Chapter { title: string; paragraphs: Record; } interface Confession { title: string; chapters: Record; } // Served from public/ rather than bundled — it's a large static document. const loadConfession = async (): Promise => { const res = await fetch('/data/1689-confession.json'); if (!res.ok) throw new Error('could not load the confession'); return res.json(); }; export default function ConfessionPage() { const { data, loading, error } = useAsync(loadConfession, []); const [selected, setSelected] = useState(null); if (loading) return

Loading the confession…

; if (error || !data) return

The confession could not be loaded.

; const numbers = Object.keys(data.chapters).sort((a, b) => Number(a) - Number(b)); const current = selected ?? numbers[0]; const chapter = data.chapters[current]; return (

{data.title}

Chapter {current} — {chapter.title}

    {Object.keys(chapter.paragraphs) .sort((a, b) => Number(a) - Number(b)) .map((p) => (
  1. {p}. {chapter.paragraphs[p]}
  2. ))}
); }