Skip to content

bobinska-dev/sanity-plugin-table-of-contents-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Table of Contents for your Sanity Studio

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.

Screenshot 2025-08-26 at 21 00 18

Features

  • 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.

Installation

npm install sanity-plugin-table-of-contents

Usage

Add 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
    }),
  ],
})

License

MIT © Saskia Bobinska

Develop & test

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.

Kudos

Thanks to @jordanl17 for his help getting this over the line!

Release new version

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.

About

A table of contents for Portable Text and pagebuilder in Sanity

Resources

License

Stars

Watchers

Forks

Packages

No packages published