✨Discover storytelling in the AI age with Pixar's Matthew Luhn at Sanity Connect, May 8th—register now

Seeking help to generate a table of contents for a blog post using portable text and block-content-to-react.

8 replies
Last updated: Jul 1, 2020
Hi everyone. I want to create table of content for a blog post and I'm using portable text to render the post using block-content-to-react. Is there a plugin/lib that can generate that from the portable text ? I couldn't find one. Has anyone else already solved this ?
Jun 30, 2020, 8:07 PM
user Y
yeah something like this....the links are not working on clicking in the codesandbox...but I get the idea. Thanks !
Jun 30, 2020, 8:21 PM
It’s because it’s in a iframe I think. Should work in the standalone window :)
Jun 30, 2020, 8:24 PM
user Y
This might be a bug
Jun 30, 2020, 10:35 PM
If you add a list in block content under h2 it is still showing in the serialized component even when I'm returning null for everything except header tags
Jun 30, 2020, 10:36 PM
user Y
This might be a BUG. I'm using the above example and If I add a list after header tag no matter where ...it shows up in the serialized content even though I'm returning
for everything except header tags in
I reproduced it here :
Jun 30, 2020, 10:50 PM
user M
can u help with ^ ? Am I doing something wrong or is this a bug?
Jul 1, 2020, 5:53 PM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?