Get TOC
Parse Table of contents from markdown/mdx content
Parse Table of contents from markdown/mdx content.
Usage
Note: If you're using a CMS, you should use the API provided by the CMS instead.
Markdown/MDX
Portable Text (Sanity)
getTableOfContents
Parse markdown content and return an array of TOC items.
getTableOfContentsFromPortableText
Takes a portable text and slug function, return an array of TOC items with their slug generated using the slug function.
TOCItemType
Prop | Type | Description |
---|---|---|
title | string | Title of heading |
url | string | Href url |
depth | number | From 1 to 6 |
Last updated on