This is a plugin that adds a table of contents inspector to navigate your page builder arrays and Portable Text in documents, letting you quickly jump to a specific heading or custom block - even for nested Portable Text fields.
- Table of contents inspector: Navigate your portable text in documents and quickly jump to a specific heading or custom block.
- Customisable: Choose which types and fields to include in the table of contents.
- Easy to use: Simple setup and configuration.
- Lightweight: Minimal impact on your Studio's performance.
npm install sanity-plugin-table-of-contentsAdd it as a plugin in sanity.config.ts (or .js):
import { defineConfig } from 'sanity'
import { tableOfContentsPlugin } from 'sanity-plugin-table-of-contents'
export default defineConfig({
//...
plugins: [
//...
tableOfContentsPlugin({
fieldNames: ['content', 'body'], // all array and Portable Text fields that should be included in the TOC
documentTypes: ['page', 'news'], // add the TOC to specific document types
}),
],
})MIT © Saskia Bobinska
This plugin uses @sanity/plugin-kit with default configuration for build & watch scripts.
See Testing a plugin in Sanity Studio on how to run this plugin with hotreload in the studio.
Thanks to @jordanl17 for his help getting this over the line!
Run "CI & Release" workflow. Make sure to select the main branch and check "Release new version".
Semantic release will only release on configured branches, so it is safe to run release on any branch.