import Blog from './blog.mdx' and use <Blog>, TemplateDX’s bundler substitutes the imported file’s AST directly into the parent at parse time. There is no React render cycle, no hooks, no event handlers, just template composition.
Constraints
- TemplateDX accepts only default imports.
import { Thing } from './file.mdx'throws at bundle time; the bundler explicitly rejects named imports perbundler.ts:209. - The bundler parses imports as MDX regardless of extension. It inlines any file the content loader can read; use
.mdxor.mdby convention. - Use
{props.*}for data,{props.children}for body content. The bundler populates both from the parent’s JSX attributes and child nodes. - No React runtime. Hooks, event handlers, and refs do nothing inside a TemplateDX component. If you find yourself reaching for them, you probably want a custom tag plugin instead.
Example
Givenblog.mdx:
blog.mdx
index.mdx
<Blog> tag with the contents of blog.mdx, resolving props.title to "Turtles" and props.children to the child body.
When to use a component vs. a tag
- Components: for static template fragments you want to compose. Think partials: a shared
<SystemPrompt>header, a reusable<FewShotExamples>block. - Tags: for logic that needs runtime behavior such as conditional rendering (
<If>), iteration (<ForEach>), raw passthrough (<Raw>), or custom extensions you implement as aTagPlugin.