question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow ability to pass scope to MDX document

See original GitHub issue

It’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:closed
  • Created 5 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
fabecommented, Jul 27, 2018

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!

2reactions
johnocommented, Jul 27, 2018

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found