Context
The repo currently maintains two near-duplicate copies of MarkdownFormatter.tsx:
app/src/components/blog/MarkdownFormatter.tsx (Vite / legacy)
website/src/components/blog/MarkdownFormatter.tsx (Next.js)
Several recent bugs existed only in one copy:
A drift check (scripts/check-markdown-drift.ts) was added in the bug-audit batch to catch top-level API divergence, but the real fix is to extract the shared component into a package consumed by both sub-apps.
Plan
- Create a new workspace package (e.g.
packages/blog) exporting MarkdownFormatter, HighlightedBlock, PlotlyChartCode, blog styles, useDisplayCategory, LazyPlot.
- Factor out sub-app-specific dependencies (e.g.
OptimisedImage in app/) via a small props/context surface so the shared component is framework-agnostic.
- Replace both
app/src/components/blog/MarkdownFormatter.tsx and website/src/components/blog/MarkdownFormatter.tsx with re-exports from the shared package.
- Delete
scripts/check-markdown-drift.ts and its PR check once dedup is complete.
Notes
Context
The repo currently maintains two near-duplicate copies of
MarkdownFormatter.tsx:app/src/components/blog/MarkdownFormatter.tsx(Vite / legacy)website/src/components/blog/MarkdownFormatter.tsx(Next.js)Several recent bugs existed only in one copy:
useEffectdependencies (app/ only)HighlightedBlockparts[1]crash (both, fixed in the bug-audit batch)as anytype assertions (app/ only)<a>href not routed throughisSafeHref(app/ only)A drift check (
scripts/check-markdown-drift.ts) was added in the bug-audit batch to catch top-level API divergence, but the real fix is to extract the shared component into a package consumed by both sub-apps.Plan
packages/blog) exportingMarkdownFormatter,HighlightedBlock,PlotlyChartCode, blog styles,useDisplayCategory,LazyPlot.OptimisedImagein app/) via a small props/context surface so the shared component is framework-agnostic.app/src/components/blog/MarkdownFormatter.tsxandwebsite/src/components/blog/MarkdownFormatter.tsxwith re-exports from the shared package.scripts/check-markdown-drift.tsand its PR check once dedup is complete.Notes
"use client"pragma in the website adapter (Next.js RSC requirement).safeHrefhelper (from Anchor renderer in MarkdownFormatter does not run href through isSafeHref #989) should live alongside the shared component.