generated from mantinedev/vite-template
-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
Summary
Migrate the blog system from plain Markdown (rendered via ReactMarkdown) to MDX to enable embedding React components directly in blog posts.
Current State
- Blog posts are
.mdfiles inapp/src/data/posts/articles/ - Rendered using
ReactMarkdownwithrehype-rawinMarkdownFormatter.tsx - ~100+ existing markdown posts
- Some posts are Jupyter notebooks (
.ipynb) - Currently using iframe workarounds to embed React components (e.g., OrgLogos)
Benefits of MDX
- Embed React components directly -
<OrgLogos />,<PolicyChart />, custom calculators - Interactive blog posts - live code examples, toggleable sections
- Reusable components - consistent styling across posts
- Better DX - TypeScript support, props validation
- Backward compatible - plain markdown still works
Implementation Steps
-
Add MDX dependencies:
@mdx-js/react@mdx-js/rollup(for Vite) or@mdx-js/loader
-
Configure Vite to handle
.mdxfiles -
Create MDX component provider with allowed components
-
Update
MarkdownFormatter.tsxto use MDX renderer for.mdxfiles (keep ReactMarkdown for legacy.mdfiles) -
Update
posts.jsonor post loading logic to handle both.mdand.mdx -
Document component usage for blog authors
-
Gradually migrate posts that would benefit from components
Considerations
- Keep backward compatibility with existing
.mdposts - Jupyter notebooks (
.ipynb) need separate handling - Consider build performance with many MDX files
- Document available components for non-technical contributors
Related
- Current iframe workaround:
/embed/org-logosroute added for blog embedding
Metadata
Metadata
Assignees
Labels
No labels