Creating a snippet
Pre-condition: Snippet files must live in thesnippets directory.
Files in the
snippets directory are treated as components, not standalone pages. To render a snippet as a page, import it into an MDX file outside of snippets.Default export
- Create a snippet with the content you want to reuse. You can accept props as variables.
snippets/my-snippet.mdx
- Import and use the snippet in any page:
destination-file.mdx
Reusable variables
- Export variables from a snippet:
snippets/variables.mdx
- Import and use them:
destination-file.mdx
Reusable components
- Export a component as an arrow function:
snippets/custom-component.mdx
- Import and use it:
destination-file.mdx