leadtype/mdx
leadtype/mdx
The leadtype/mdx subpath is the consumer-facing MDX surface — everything you need to compile leadtype-authored MDX in your own renderer (fumadocs, Next App Router, Vite + @mdx-js, Astro content collections).
It exports three things:
- Tag type contracts — typed prop shapes for every custom MDX tag.
createMdxSourcePlugins()/mdxSourcePlugins— a remark preset that performs build-time resolution only (expand includes, resolve<ExtractedTypeTable>, strip authoringimports) and leaves every other custom tag as JSX.- Include-resolution helpers —
resolveInclude,parseIncludeSpecifier,extractMdxSectionfor direct use.
Pair it with leadtype/remark (markdown flattening for the agent/LLM pipeline) — they are sibling surfaces, not alternatives. Most projects use both.
The MDX-source preset
Use the mdxSourcePlugins constant only when the default path inference is enough for your project. When <ExtractedTypeTable path="./packages/..." /> should resolve from a known source root (.c15t, .leadtype, the repo root, or a docs folder), prefer createMdxSourcePlugins({ typeTableBasePath }). If you intentionally keep type files inside docs/, pass path.resolve(process.cwd(), "docs").
The preset is intentionally minimal — only the transforms that must run at build time:
| Plugin | Purpose |
|---|---|
remarkInclude | Expands <include src="…" />, <import>, <include-c15t> |
remarkResolveTypeTableJsx | <ExtractedTypeTable name path /> → <TypeTable properties={…} /> |
remarkResolveDocPlaceholders | Resolves {{...}} placeholders against doc context |
remarkRemoveImports | Strips authoring import statements that aren't needed at runtime |
Every other custom tag (<Callout>, <Tabs>, <Steps>, <Mermaid>, …) stays JSX so your runtime components render them.
Framework-neutral by design
Tag types describe the author surface — the attributes that appear on a tag in source MDX. They deliberately do not import from any UI framework: children is typed as unknown so you can intersect with your framework's native child type.
The same shape works in React, Vue, Svelte, Solid, Astro, Qwik, or anything else with an MDX compiler that accepts remark plugins.
React
Vue
Svelte
Solid
Astro
Full type inventory
Every prop name is part of the 1.0 contract — bumping a shape is a breaking change. New optional props are minor.
Build-time only: <ExtractedTypeTable>
<ExtractedTypeTable name="X" path="..." /> is an authoring convenience. The source preset replaces it at build time with <TypeTable properties={…extracted} />, so consumers only implement the runtime <TypeTable> component:
<ExtractedTypeTable> requires typescript to be installed as an optional peer dep in your docs project. Failed extraction emits a visible warning by default; pass typeTableStrict: true to createMdxSourcePlugins() when a missing type should fail the build.
Include resolution
resolveInclude reads + classifies an include target without going through remark — useful when loading a partial outside of the bundler pipeline:
parseIncludeSpecifier(specifier) and extractMdxSection(root, id) are exposed for callers that want to compose their own pipeline.
Re-exported path helpers
Routing primitives that previously lived under leadtype/internal are re-exported for consumer use: