MDX Content Pipeline
apps/web uses @next/mdx to render long-form content (currently: legal pages) from MDX files in apps/web/content/.
Pipeline
next.config.ts wraps the Next config with createMDX({...}) and pipes:
remark-gfm— GitHub-flavoured markdown (tables, strikethrough, task lists).rehype-slug— derivesidattributes from heading text.rehype-autolink-headings— appends an anchor link to each heading.
apps/web/mdx-components.tsx maps every MDX element (h2, p, table, blockquote, …) to Tailwind-styled React components using Lumio design tokens. No per-page overrides are needed — all legal pages inherit this mapping.
Current surface
The MDX pipeline currently powers the six legal pages under /legal:
imprintprivacytermscookiessecurityfaq
Adding a legal page
- Add the slug to
apps/web/src/components/legal/legal-pages.ts(pick an icon fromlucide-reactand setlastUpdated). - Add MDX files at
apps/web/content/en/legal/<slug>.mdxandapps/web/content/de/legal/<slug>.mdx. - Add translation keys under
legal.pages.<slug>inmessages/en.jsonandmessages/de.json(title,description,navLabel). - Register the EN + DE loader entries in
apps/web/src/lib/mdx-import.tsso the dynamicimport()specifiers stay string literals (required for Next.js to statically bundle them).
The route /legal/<slug> is produced automatically by the dynamic legal/[slug]/page.tsx handler.
Fallback behaviour
If /content/<locale>/legal/<slug>.mdx doesn't exist, importLegalMdx falls back to the English file. If the English file is also missing, the page calls notFound().
TOC generation
rehype-slug sets heading IDs at build time. The LegalToc component (client) reads the rendered DOM and drives the "On this page" sidebar using an IntersectionObserver. No manual TOC authoring is needed.
Adding bigger styling changes
All MDX typography lives in apps/web/mdx-components.tsx. Don't add Tailwind classes inside MDX body text — they'd apply to plain markdown as well and leak inconsistent styling.