Eyas's Blog

Year Archives for 2022

Writing a React Table of Contents Component

Last year, I wrote about migrating this blog to Next.js. It ended up being a huge post, so I wrote a <TOC> React component to make it more navigable. You can also see the TOC in action on this page:

The bulk of the logic for this component is based on Emma Goto’s great examples in her ”How to build a table of contents in React”, with a few improvements worth discussing. If you haven’t yet, go read that post! Emma does a great job showing both the final working solution and explaining the thinking behind it step-by-step.

Read more →

1