Writing Content
Reusable Snippets
Reusable, custom snippets to keep content in sync
To maintain DRY (Don’t Repeat Yourself) principles in documentation, use custom snippets to keep repeated content in sync across multiple pages.
Creating Custom Snippets
All snippets must be created in the snippets
directory. These files won’t be rendered as standalone pages unless imported and used as components.
Basic Snippet Usage
Create a snippet with optional variables:
snippets/my-snippet.mdx
Import and use in your destination file:
destination-file.mdx
Variables and Components
Export variables:
snippets/custom-variables.mdx
Create reusable components:
snippets/custom-component.mdx
MDX doesn’t compile inside arrow functions. Use HTML syntax or default exports for MDX content.
Client-Side Content
For client-side rendering, check for document
availability:
snippets/client-component.mdx
Was this page helpful?