gatsby-remark-relative-links

0.0.3 • Public • Published

gatsby-remark-relative-links

Rewrites absolute URLs to relative ones with remark

Why?

I created this plugin to use in tandem with remark-external-links so that any links that content creators have used absolute versions of can be corrected before that plugin's logic takes effect.

Important

Use this before gatsby-remark-external-links

Installation

yarn add gatsby-remark-relative-links

Usage

Add following to your gatsby-config.js:

    plugins: [
      {
        resolve: `gatsby-transformer-remark`,
        options: {
          plugins: [
          {
            resolve: "gatsby-remark-relative-links",
            options: {
              domainRegex: /http[s]*:\/\/[www.]*yoursite\.com[/]?/,
            }
          },
          'gatsby-remark-external-links',
          ]
        }
      },

API

options.domainRegex Required

Type: string Default: null

Regex used to decipher what domain to "relative-ize". The example provided should handle most cases.

License

MIT

Package Sidebar

Install

npm i gatsby-remark-relative-links

Weekly Downloads

15

Version

0.0.3

License

MIT

Unpacked Size

3.23 kB

Total Files

4

Last publish

Collaborators

  • zachschnackel