Files
blog-nextjs/components
gbanyan 2b1060dd45 Fix TOC showing wrong headings across navigation
Problem: Table of Contents displayed headings from previously viewed
articles when navigating between posts via client-side routing.

Root cause: PostToc component's useEffect with empty dependency array
only ran once on mount, so it retained stale heading data when React
reused the component instance during navigation.

Solution: Add contentKey prop flow:
- Blog/page routes pass slug to PostLayout
- PostLayout passes contentKey as key prop to PostToc instances
- React remounts PostToc when key changes, rebuilding TOC correctly

Files changed:
- components/post-layout.tsx: Add contentKey prop and key forwarding
- app/blog/[slug]/page.tsx: Pass slug as contentKey
- app/pages/[slug]/page.tsx: Pass slug as contentKey
2025-11-20 15:57:47 +08:00
..
2025-11-19 17:38:45 +08:00
2025-11-17 15:28:20 +08:00
2025-11-18 17:34:05 +08:00
2025-11-19 00:42:53 +08:00
2025-11-19 21:46:49 +08:00
2025-11-19 00:30:35 +08:00
2025-11-19 21:46:49 +08:00
2025-11-19 17:38:45 +08:00
2025-11-18 17:34:05 +08:00