question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`gatsby-plugin-mdx`: `remark-external-links` generates invalid `rel`

See original GitHub issue

Description

Using remark-external-links with gatsby-plugin-mdx generates an invalid rel attribute: nofollow,noopener,noreferrer instead of nofollow noopener noreferrer, how it is supposed to be.

Usage with gatsby-plugin-mdx and remarkPlugins

Screen Shot 2020-04-01 at 18 01 47

Usage alone

Screen Shot 2020-04-01 at 17 50 16

Steps to reproduce

Add the following code to Runkit (you can use this link: https://npm.runkit.com/remark-external-links). This generates the correct rel.

var remark = require('remark')
var externalLinks = require("remark-external-links")
var html = require('remark-html')
var input = '[remark](https://github.com/remarkjs/remark)'
remark().use(externalLinks).use(html).processSync(input).toString()

Try out my gatsby-plugin-mdx sandbox at the link below. This generates an invalid rel:

gatsby-plugin-mdx Sandbox: https://codesandbox.io/s/empty-cdn-u31qb

Expected result

The correct rel should be generated.

Actual result

An invalid rel is generated.

Environment

System:
    OS: Linux 4.19 Debian GNU/Linux 10 (buster) 10 (buster)
    CPU: (12) x64 Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz
    Shell: 5.0.3 - /bin/bash
  Binaries:
    Node: 10.18.1 - /tmp/yarn--1585757330032-0.1053501887919337/node
    Yarn: 1.21.1 - /tmp/yarn--1585757330032-0.1053501887919337/yarn
    npm: 6.13.4 - /usr/local/bin/npm
  Languages:
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    gatsby: 2.20.9 => 2.20.9
    gatsby-plugin-mdx: ^1.0.23 => 1.0.23

cc @ChristopherBiscardi

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:29 (17 by maintainers)

github_iconTop GitHub Comments

1reaction
karlhorkycommented, May 15, 2020

Yes, agree it’s unfortunate.

Wonder if the Gatsby team would be open to changing this for Remark plugins (the wrapper bit can also be absorbed into gatsby-transformer-remark, I guess?).

1reaction
karlhorkycommented, May 15, 2020

Ah it looks like publishing additional “wrapper” npm packages to wrap every remark plugin is the recommended way of doing things 😞 At least in 2018 it was like this.

References:

So @wooorm I guess the process of writing extra wrapper packages you described the downsides about in https://github.com/gatsbyjs/gatsby/issues/22719#issuecomment-622305670 is actually recommended 😞

Read more comments on GitHub >

github_iconTop Results From Across the Web

gatsby-remark-external-links
Adds the target and rel attributes to external links in markdown. This is a gatsby port of the remark-external-links remark plugin.
Read more >
Rewriting my blog with Next.js - Dimitrios Lytras
Replacing Gatsby's Markdown plugins, and introducing MDX. Here's the juicy part. I wanted to create some custom components in my markdown files.
Read more >
npm - Cannot add plugins on gatsby - Stack Overflow
I have a dependency error trying to add any of the plugins available for gatsby. This issue is there immediately after the first ......
Read more >
gatsby-remark-code-repls - npm package - Snyk
Gatsby plugin to auto-generate links to popular REPLs like Babel and Codepen For more information about how to use this package see README...
Read more >
Migrating this Blog to Next.js from Gatsby
And I couldn't find external links to day archives on my blog, ... Gatsby's Markdown and MDX plugins use Remark, which in turn...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found