Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Medium Engineering 7 min read Case study mediumAdept

How we built the new Table of Contents feature

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.

Assumes: DOM and anchor linksTypeScript basics

Related posts

  • A Tool for Discussion

    Oxide mediumAdept

    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. The site adds full-text search via self-hosted Meilisearch with automatic reindexing on edits, hover previews for inter-RFD links, and keyboard-driven navigation menus. GitHub PR review comments are shown inline next to the relevant section by mapping comment line numbers to rendered blocks with asciidoctor.js's getLineNumber, and Remix deferred responses stream the comments in so they don't block page load. Planned work includes better filtering, tagging and collections, plus in-browser authoring so non-engineers can write RFDs without Git.

  • More Editorial Content, please.

    Zalando Engineering mediumAdept

    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. Pages are composed from reorderable module entries, and other teams can contribute new modules, as the Sustainability team did with a certificate module that enriches Contentful-stored IDs with data from the same service used on product detail pages. Time-to-go-live fell from 2 days to 4 hours, the 2-week lead time was removed, and published landing pages rose 82% year over year.

  • Supercharging Directus on Railway with a Static Frontend

    Railway mediumAdept

    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. A single GraphQL query pulls all published articles and issues. Jinja2 templates render pages into per-path index.html files and collect URLs for a sitemap. Deployment runs through GitHub Actions to GitHub Pages, and a Directus flow fires a repository_dispatch webhook so content edits trigger rebuilds. HTMX handles 'Read More' expansion by fetching the prebuilt article page and swapping in just the article element.

  • Rendering huge pull requests in the GitHub Copilot app

    GitHub Engineering mediumAdept

    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. A single idle- and scroll-gated measurement pass scoped to about 2400px around the viewport replaces per-block ResizeObserver write-back, which caused feedback loops. Observers only flag blocks for re-measurement, except for user-caused resizes, which commit synchronously at most once per frame. Identity-based scroll anchoring keeps corrections small, and a cache of recent diffs prevents an instantly drawn shell from sitting around an empty diff. Bugs were found with permanent in-app probes asserted as CI budgets and an autonomous headless change→measure→improve loop.

  • From latency to instant: Modernizing GitHub Issues navigation performance

    GitHub Engineering mediumAdept

    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. A persistent IndexedDB cache made about 22% of React soft navigations instant at a ~33% hit rate, with roughly 4.7% server/cache divergence. Rate-limited, low-priority preheating from issue lists and an in-memory cache tier raised the hit ratio to ~96%, so up to ~70% of React navigations became instant. A service worker extends the cache to Turbo and hard navigations by signalling cache hits via a request header, letting the server return a thin HTML shell instead of a full server-rendered page. The tradeoff on hard navigations is that the critical path shifts to JavaScript download and execution.

The quest for software engineering knowledge.

Look:
Layout: