wooorm / xdm

Just a *really* good MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins
http://wooorm.com/xdm/
MIT License
595 stars 18 forks source link

question: Can interpolation occur in link urls and references? #88

Closed ElMassimo closed 3 years ago

ElMassimo commented 3 years ago

MDX supports interpolation in titles and link content. For example:

import { title } from 'introduction'

# {title}

[{title}](https://example.com)

is equivalent to:

<h1>Introduction</h1>
<a href="https://example.com">Introduction</a>

Question

Is there a way to interpolate link URLs and references? For example:

import { title, url } from 'introduction'

[this link]: {url}

Visit [this link] or [click here]({url})

To achieve the following:

<p>Visit <a href="/intro">this link</a> or <a href="/intro">click here</a></p> 
wooorm commented 3 years ago

I think it would become unclear where they do work. And in several cases people don’t want it to work.

![{here?}]({here?} "and {here?}")

[{here?}]({here?} "and {here?}")

```{here?} or {here?}
And {here?}


And the alternative is mostly fine and unambiguous in my opinion: `<a href={url}>click here</a>`.
ElMassimo commented 3 years ago

That makes sense, would be nice to support them when defining a reference though:

[title]: {title}

Thanks for the reply!