forked from CopilotKit/CopilotKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtoc-bridge.ts
More file actions
18 lines (16 loc) · 710 Bytes
/
Copy pathtoc-bridge.ts
File metadata and controls
18 lines (16 loc) · 710 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// Bridge shell-docs's TocHeading shape into Fumadocs's `TOCItemType`
// so `<DocsPage toc={...}>` can render the right-rail TOC for the same
// headings shell-docs's hand-rolled `DocsToc` was rendering.
//
// shell-docs's TocHeading.slug already matches the `id` attribute the
// heading renders with (the same `slugify()` is used at heading-render
// time inside DocsPageView). So `url: "#" + slug` is a stable anchor.
import type { TableOfContents } from "fumadocs-core/toc";
import type { TocHeading } from "@/lib/toc";
export function tocHeadingsToFumadocs(headings: TocHeading[]): TableOfContents {
return headings.map((h) => ({
title: h.text,
url: `#${h.slug}`,
depth: h.depth,
}));
}