MDX Deep Dive
Creating Custom Components
In Morph markdown files, you can use React components.
Create and use custom components in markdown files
1
Create a tsx file and export the component
Create a tsx file in the src directory. It is recommended to create it in the src/components
directory, but it can be anywhere.
src/components/CustomComponent.tsx
2
Use the custom component in an mdx file
In the mdx file, you can import and use the tsx file with a relative path.
index.mdx
Use API endpoints from custom components
To execute Python functions from within a custom component, do the following.
To understand this sample code, refer to Alias, loadData(), and postData().