Conditionally Render Markdown in MDX files

65 views Asked by At

I want to conditionally render some markdown in an MDX file based on a prop passed from the parent.

I've tried this:

# Manufacturers Warranty

{props.nz && (
<>    
    ## New Zealand Made
    Our panels are New Zealand made in our Silverdale factory. 
</>
)}

This kind of works, but it renders the markdown as is, not converting it to HTML. The ## markdown above renders as two hashes, not a heading.

Is conditional markdown possible in MDX, or once flicking to JSX am I stuck with JSX's HTML?

I'm using MDX in Astro - but I don't think that is impacting anything.

0

There are 0 answers