Coder Social home page Coder Social logo

gatsby-remark-external-links's Introduction

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.

Usage

  1. Install plugin to your site:
yarn add gatsby-remark-external-links
  1. Add following to your gatsby-config.js:
    plugins: [      
      {
        resolve: `gatsby-transformer-remark`,
        options: {
          plugins: [
          {
            resolve: "gatsby-remark-external-links",
            options: {
              target: "_self",
              rel: "nofollow"
            }
          }
          ]
        }
      },
  1. Restart gatsby.

API

options

target

Type: string Default: _blank

Specifies where to display the linked URL. The value should be one of : _self, _blank, _parent, _top

You can specify null to not add the target attribute to your links

rel

Type: string Default: nofollow noopener noreferrer

Specifies the relationship of the target object to the link object. The value is a space-separated list of link types.

You can specify null to not add the rel attribute to your links

When using target, consider adding rel="noopener noreferrer" to avoid exploitation of the window.opener API.

License

MIT

gatsby-remark-external-links's People

Contributors

calyhre avatar jd-carroll avatar jlongley avatar kafkas avatar zslabs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

gatsby-remark-external-links's Issues

Detect protocol less urls

Contentful upload links are like //mysupercoollink.pdf can you add detection for urls that start with a double slash and no protocol like these?

Please publish the latest package on npm

The version on npm / yarn is from 2 years ago and doesn't have the change to use remark-external-links code. Could you please release the latest version of gatsby-remark-external-links to npm?

Doesn't work on reference style link

With

This is [GatsbyJS][ref] link

[ref]: https://www.gatsbyjs.org

The resulting HTML will be

This is <a href="https://www.gatsbyjs.org">GatsbyJS</a> link

No attribute added, while the normal style ([]()) works as expected.

Stumped. I cant get this to work at all...

plugins: [
    "gatsby-plugin-react-helmet",
    "gatsby-plugin-less",
    "gatsby-transformer-json",
    {
    resolve: 'gatsby-transformer-remark',
      options: {
        plugins: [
          {
            resolve: 'gatsby-remark-external-links',
            options: {
              target: '_blank',
              rel: 'noopener nofollow'
            }
          }
        ]
      }
    },
    "gatsby-plugin-catch-links",
    {
      resolve: "gatsby-source-filesystem",
      options: {
        name: "images",
        path: `${__dirname}/src/images`,
      },
    },
    // Plugin to read files in /src/pages
    {
      resolve: "gatsby-source-filesystem",
      options: {
        name: "pages",
        path: `${__dirname}/src/pages/`,
      },
    },    
    "gatsby-transformer-sharp",
    "gatsby-plugin-sharp",
    {
      resolve: "gatsby-plugin-manifest",
      options: {
        name: "hazardous-frog-website",
        short_name: "HF",
        start_url: "/",
        background_color: "#663399",
        theme_color: "#663399",
        display: "minimal-ui",
        icon: "src/images/hf-icon.png", // This path is relative to the root of the site.
      },
    },

  ],

Sample link in code:
<a href="https://www.apple.com">apple</a>

I'm expecting this to be replaced with

<a href="https://www.apple.com" target="_blank" rel="noopener nofollow">apple</a>

but the link remains unchanged : no target or rel attributes added.

from my package.json

    "gatsby-transformer-remark": "^2.3.12",
    "gatsby-remark-external-links": "0.0.4",

What am I doing wrong?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.