Diesan Romero
Diesan Romero

Reputation: 1658

How can I use target="blank" in an external link on MDX?

I am creating a blog with NextJS and MDX, and I would like to add a target="_blank" to external links.

Normally I do it with regular Markdown using the following format [words](link){:target="blank"} but this is not working properly in MDX.

Upvotes: 2

Views: 1715

Answers (1)

dz24
dz24

Reputation: 66

What I believe you are looking for is this: https://stackoverflow.com/a/71677705,

i.e. adding

<base target="_blank"></base>

to your <Head> element in i.e. your _app.js or layout.js script.

This makes the rendered markdown urls to be opened in a new tab.

Upvotes: 5

Related Questions