Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/suin/gatsby-rehype-replace-urls
Gatsby rehype plugin that rewrites URLs of src/href attributes.
https://github.com/suin/gatsby-rehype-replace-urls
gatsby gatsby-plugin rehype
Last synced: about 2 months ago
JSON representation
Gatsby rehype plugin that rewrites URLs of src/href attributes.
- Host: GitHub
- URL: https://github.com/suin/gatsby-rehype-replace-urls
- Owner: suin
- License: mit
- Created: 2020-05-22T15:53:19.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-01-07T21:45:35.000Z (about 2 years ago)
- Last Synced: 2024-11-15T04:22:38.248Z (2 months ago)
- Topics: gatsby, gatsby-plugin, rehype
- Language: TypeScript
- Homepage: https://suin.github.io/gatsby-rehype-replace-urls/
- Size: 3.22 MB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 30
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# @suin/gatsby-rehype-replace-urls
Gatsby rehype plugin that rewrites URLs of src/href attributes.
## Install
```
yarn add gatsby-transformer-rehype @suin/gatsby-rehype-replace-urls
```## How to use
```js
// In your gatsby-config.js
module.exports = {
plugins: [
{
resolve: `gatsby-transformer-rehype`,
options: {
plugins: [
{
resolve: '@suin/gatsby-rehype-replace-urls',
options: {
replace({ url }) {
const u = new URL(url)
if (u.protocol === 'http:') {
u.protocol = 'https'
}
return u
},
},
},
],
},
},
]
}
```* To know the parameter of the `replace` function, see [API doc](https://suin.github.io/gatsby-rehype-replace-urls/modules/_index_.plugin.html#replaceparams).
* To learn more examples, see [index.test.ts](./index.test.ts).