---
title: "How we built the new Table of Contents feature"
description: "Medium replaced a popular Chrome extension that injected a static table of contents into post bodies with a native, render-time TOC derived from the post's heading paragraphs."
url: "https://swe.quest/articles/how-we-built-the-new-table-of-contents-feature-3970e42d2277d3b5"
canonical: "https://medium.engineering/how-we-built-the-new-table-of-contents-feature-c3825d8c279d"
source: "Medium Engineering"
published: "2026-07-23"
difficulty: "medium"
kind: "Case study"
reading_minutes: 7
tags: ["product-engineering","frontend","typescript"]
---

# How we built the new Table of Contents feature

A post on [Medium Engineering](https://swe.quest/sources/medium-eng.md), published 2026-07-23, 7 min read, Case study. Original: [https://medium.engineering/how-we-built-the-new-table-of-contents-feature-c3825d8c279d](https://medium.engineering/how-we-built-the-new-table-of-contents-feature-c3825d8c279d)

## Summary

Medium replaced a popular Chrome extension that injected a static table of contents into post bodies with a native, render-time TOC derived from the post's heading paragraphs. Because posts are stored as layered revisions rather than final documents, the TOC is built from the rendered body model, nesting H4 sub-headings under H2/H3 entries, so it stays accurate without mutating the post. The UI evolved from a menu item to a scroll-tracking right-margin indicator with smooth scrolling, a translucent background for full-width images, hiding for single-heading posts, and a sliding window for very long posts; mobile needs a separate design.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Product engineering](https://swe.quest/tags/product-engineering.md) (Engineering organization)
- [Frontend](https://swe.quest/tags/frontend.md) (Web & mobile)
- [TypeScript](https://swe.quest/tags/typescript.md) (Languages)

## Prerequisites

- DOM and anchor links
- TypeScript basics ([easy posts on TypeScript](https://swe.quest/tags/typescript.md?difficulty=easy))

## Keywords

Medium, Chrome extension, table of contents

## Related posts

- [A Tool for Discussion](https://swe.quest/articles/a-tool-for-discussion-5fe113c6c82e2e75.md): Oxide · 2023-02-02 · Medium · 4 min read · Documentation, Developer tools, Frontend, Search
  Oxide built an internal site for its RFDs (Requests for Discussion), which live as AsciiDoc files in a GitHub repo, because the repo gave a poor reading experience, limited AsciiDoc support and was hard to share externally.
- [More Editorial Content, please.](https://swe.quest/articles/more-editorial-content-please-3a9ab301c97b6ae2.md): Zalando Engineering · 2022-09-28 · Medium · 10 min read · Product engineering, GraphQL, System design, Frontend
  Zalando replaced a legacy, engineering-heavy landing page tool with a system built on the headless CMS Contentful, integrated into its Interface Framework via a Contentful proxy service behind the Fashion Store GraphQL aggregator, with modules mapped to renderers shared across web and app.
- [Supercharging Directus on Railway with a Static Frontend](https://swe.quest/articles/supercharging-directus-on-railway-with-a-static-frontend-06dcb86215b2424e.md): Railway · 2024-12-13 · Medium · 8 min read · Python, GraphQL, Web performance, CI/CD, Frontend
  A custom Python static site generator replaces per-request GraphQL fetching from a Directus CMS, which was slow and loaded the server, for a school newspaper site.
- [Rendering huge pull requests in the GitHub Copilot app](https://swe.quest/articles/rendering-huge-pull-requests-in-the-github-copilot-app-dfdd1afcfdc347d9.md): GitHub Engineering · 2026-09-23 · Medium · 13 min read · Frontend, Web performance, Performance engineering, Testing, Observability
  The GitHub Copilot app's pull request view stays responsive on a 2,200-file, million-line diff with 400+ review comments by splitting document height into two geometries: exact, precomputed prefix-summed code rows and lazily measured dynamic blocks for comments, drafts and composers.
- [From latency to instant: Modernizing GitHub Issues navigation performance](https://swe.quest/articles/from-latency-to-instant-modernizing-github-issues-navigation-performance-d76fe4f2daa6064a.md): GitHub Engineering · 2026-05-14 · Medium · 13 min read · Web performance, Caching, Frontend, Local-first & sync, Browsers
  GitHub made Issues navigation feel instant by moving to a local-first, stale-while-revalidate model: render issue pages from client-side data first, then revalidate in the background.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
