templates2.Content.Next/components/content/Toc.tsx
w4c-templates 3caefb8833
Some checks are pending
CI / quality (push) Waiting to run
chore(template): publish Content.Next
2026-10-11 23:29:57 +03:00

20 lines
606 B
TypeScript

import type { Heading } from '@/lib/content';
export function Toc({ headings }: { headings: Heading[] }) {
if (headings.length === 0) return null;
return (
<nav aria-label="Table of contents" className="text-sm">
<p className="mb-2 font-semibold">On this page</p>
<ul className="space-y-1">
{headings.map((heading) => (
<li key={heading.id} className={heading.level === 3 ? 'pl-4' : ''}>
<a href={`#${heading.id}`} className="muted hover:opacity-80">
{heading.text}
</a>
</li>
))}
</ul>
</nav>
);
}