Emma d0cb74bea8 ttcmd: adds hr element
help pages: adds a way to extract the table of contents to the parent,
smoothes out the rough loading on help pages
2024-03-13 02:52:59 -06:00

39 lines
950 B
TypeScript

"use client";
import { TTCMD, TTCMDRenderer } from "@/components/ttcmd";
import { FC, use, useCallback, useState } from "react";
export const HelpClient: FC<{ body: Promise<string>; title: string }> = ({
body: bodyPromise,
title,
}) => {
const body = use(bodyPromise);
const [toc, setToc] = useState<Token[]>();
const escapeTOC = useCallback((t: Token[]) => {
setToc(t);
return true;
}, []);
return (
<>
<section className="heading">
<h2 className="strapline">Help</h2>
<h1>{decodeURIComponent(title)}</h1>
</section>
<section className="grid grid-cols-3 gap-x-8 gap-y-6 my-6">
<div className="col-span-2">
<TTCMD
body={body}
escapeTOC={escapeTOC}
/>
</div>
{toc && (
<div className="sticky top-8 h-min">
<TTCMDRenderer tokens={toc} />
</div>
)}
</section>
</>
);
};