Skip to content

feat: add blog reading-time badges and inline table of contents - #136

Merged
truthixify merged 3 commits into
wraith-protocol:developfrom
Peolite1:feature/issue-123
Aug 26, 2026
Merged

feat: add blog reading-time badges and inline table of contents#136
truthixify merged 3 commits into
wraith-protocol:developfrom
Peolite1:feature/issue-123

Conversation

@Peolite1

Copy link
Copy Markdown
Contributor

Title

feat: add blog reading-time badges and inline table of contents (#123)

Description

This PR implements the features requested in #123, which improve the perceived quality and navigability of the blog. Specifically, it introduces reading-time badges and an auto-generated table of contents for longer posts.

Changes Made

  • Dependencies: Added rehype-slug to generate anchor IDs for h2 and h3 tags in MDX files during the Vite build, and github-slugger for generating matching hashes in the TOC logic.
  • TOC Extraction & Reading Time: Updated src/utils/blog.ts to compute reading time (based on 200 words per minute) and extract h2/h3 headings from the raw MDX body at build time.
  • UI Additions (Blog.tsx): The reading-time badge (e.g. "6 min read") is now rendered on the blog index cards and the single-post header next to the date and author.
  • TOC Component (BlogToc.tsx): Created a new sticky sidebar component that lists TOC links and uses IntersectionObserver to highlight the currently active section. The TOC only displays on posts over 800 words with at least one heading.
  • Accessibility & Motion:
    • html scroll-behavior is set to smooth but respects @media (prefers-reduced-motion: reduce).
    • TOC anchors are keyboard navigable, include focus outlines, and the navigation block uses aria-label="Table of Contents" for screen readers.

Fixes Issue

Closes #123

Acceptance Criteria Verified

  • Every existing post shows a reading-time badge
  • Posts under the length threshold do not render an empty TOC
  • TOC anchors work with keyboard focus and are announced by a screen reader
  • Build passes
  • Respects prefers-reduced-motion for smooth-scroll behavior

@vercel

vercel Bot commented Aug 24, 2026

Copy link
Copy Markdown

@Peolite1 is attempting to deploy a commit to the truthixify's projects Team on Vercel.

A member of the Team first needs to authorize it.

@truthixify

Copy link
Copy Markdown
Contributor

Merged. Reading-time and the TOC both honour reduced-motion, appreciate that not being an afterthought @Peolite1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Blog reading-time badges + inline table of contents

2 participants