feat: blog reading time and table of contents - #135
Closed
Peolite1 wants to merge 3 commits into
Closed
Conversation
|
@Peolite001 is attempting to deploy a commit to the truthixify's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@Peolite1 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #123
Description
The MDX blog shipped in Wave 7 but posts lacked a reading-time hint and long posts had no navigation. This PR introduces a reading-time badge to give readers an expectation of length, and an inline Table of Contents (TOC) for longer posts (> 800 words) to help users easily navigate deeper technical posts (such as announcements or cryptography explainers). This significantly raises the perceived quality and user experience of the blog.
Key Features & Scope
Build-Time Reading Time Calculation (
src/utils/blog.ts)readingTime(e.g. "6 min read"),wordCount, andrawContentproperties on theBlogPostmodel.Reading Time Badges (
src/pages/Blog.tsx)Auto-Generated Inline Table of Contents (
src/components/BlogToc.tsx)h2andh3tags to create a dynamic table of contents.lg:breakpoint to ensure it remains accessible alongside long posts.prefers-reduced-motionfor smooth-scroll behavior vs instant jumps.rehype-slugto standardise and automatically add id attributes into markdown headings so that TOC linking functions flawlessly out-of-the-box.Files Added / Modified
src/components/BlogToc.tsx(new): Sticky/inline Table of contents component with intersection observer.src/pages/Blog.tsx: Adjusted layouts to include the TOC, and integrated reading time badges across the post lists and single posts.src/utils/blog.ts: Upgraded MDX parsing to include word counts and raw text.vite.config.ts: Addedrehype-slugplugin.package.json: Addedrehype-slugdependency.pr doc.md: PR documentation.Testing & Verification
/blogroutes.