gatsby-remark-relative-links
v0.0.3
Published
Rewrites absolute URLs to relative ones.
Downloads
87
Maintainers
Readme
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.