Skip to content
Discussion options

You must be logged in to vote

So taking a step back, how are you using MDX in the broader context of your application.
Generally, I've seen and used MDX to generate pages or content items.
But it sounds like you are interested in using it more a generic component builder? (Is that accurate?)


It's also worth nothing that there are a few options which could work with MDX today, without modifications.

first option - a get prop utility

If you don't want to customize MDX, and want the props to apply to all usages automatically, something like:

export function getProp(props, name) {
  const defaultProps = {
    // put defaults here
  }
  return {...defaultProps, ...props}[name]
}

# My Heading

My prop: {getProp(props, 'a')}

Replies: 1 comment 18 replies

Comment options

You must be logged in to vote
18 replies
@mattvague
Comment options

@mattvague
Comment options

@wooorm
Comment options

@mattvague
Comment options

@wooorm
Comment options

Answer selected by ChristianMurphy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants