Allow ability to pass scope to MDX document
See original GitHub issueIt’d be nice to be able pass in additional components and props to the component scope.
import React from 'react'
import { Box } from './ui'
import Document from './doc.md'
export default () => <Document scope={{ title: 'Hello', Box }} />
# This is some markdown
That has `Box` and `title` in scope:
<Box>{title}</Box>
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
MDX and React - Docusaurus
Docusaurus has built-in support for MDX v1, which allows you to write JSX within your Markdown files and render them as React components....
Read more >Adding MDX Pages | Gatsby
Importing JSX components into MDX documents MDX allows you to use React components alongside Markdown. You can import components from third-party libraries ( ......
Read more >Advanced Features: Using MDX - Next.js
It sources data from local files, allowing you to create pages with a .mdx extension, directly in your /pages directory. Setup @next/mdx in...
Read more >Building Cell Calculations in MDX (MDX) | Microsoft Learn
Learn how to build cell calculations in MDX to define a specific slice of cells, called a calculation subcube.
Read more >next-mdx-remote - npm
The file content must be local. You cannot store MDX files in another repo, a database, etc. For a large enough operation, there...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We thought about giving MDX files to editors of a website. Having them import components from a remote location doesn’t sound particularly usable or safe, so we wondered if we could handle the imports at build time.
Docs for a custom loader would be very appreciated!
I def hear you there. Probably isn’t the best solution.
I’ve run into this once so far on a project (basically wanted to add scope to a collection of MDX documents without having to explicitly import), but I ended up writing a custom loader.
I wonder if we perhaps write up a doc instead on how to write your own MDX loader? There isn’t much to the loader itself since all the logic/transpilation is in core.