Skip to content

Conditional content / MDX content inside JSX? #2581

Closed Answered by wooorm
egnor asked this question in Q&A
Discussion options

You must be logged in to vote

Hi!

Right, so these are your options: a) write as JSX, b) move things to a component, c) some sort of <if>.

That seems like enough options to me.
The problem with a) you describe, namely loosing markdown, is solved by b)
The problem with b) you describe, namely little files, is solved by a) — if they are so little, you can write a couple tags

For c):

both branches are processed regardless of the condition

Everything is “processed”. Not entirely sure what you mean by that word. This approach c) is the only one that would be a good fit for not processing: if there are static conditions, then you can write a plugin to drop the non-matching branch.


Anyway, yeah, https://github.com/orgs/mdx…

Replies: 3 comments 10 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by egnor
Comment options

You must be logged in to vote
10 replies
@remcohaszing
Comment options

@egnor
Comment options

@wooorm
Comment options

@egnor
Comment options

@wooorm
Comment options

Comment options

You must be logged in to vote
0 replies
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