Socket
Socket
Sign inDemoInstall

gatsby-rehype-ghost-links

Package Overview
Dependencies
2
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    gatsby-rehype-ghost-links

Gatsby rehype plugin that rewrites absolute links to relative links coming from a Ghost CMS.


Version published
Weekly downloads
35
decreased by-2.78%
Maintainers
1
Install size
219 kB
Created
Weekly downloads
 

Readme

Source

Released under MIT license. gatsby-rehype-ghost-links npm package version. PRs welcome!

Rewrites absolute links to relative links coming from a Ghost CMS.

Install

yarn add gatsby-transformer-rehype gatsby-rehype-ghost-links

How to use

// In your gatsby-config.js
plugins: [
  {
    resolve: `gatsby-transformer-rehype`,
    options: {
      plugins: [
        {
          resolve: `gatsby-rehype-ghost-links`,
        },
      ],
    },
  },
]

Details

Due to current limitations of the Ghost Content API, links within posts and pages are always returned as absolute URLs rather than relative ones. For example, if you have a link in one of your pages that refers to an internal post (e.g. /welcome-post/) the Ghost Content API will always return an absolute URL such as https://your-ghost-cms.org/welcome-post/.

Those links won't work on your Gatsby site as you host them on a different siteUrl. gatsby-rehype-ghost-links is part of the rehype collection and rewrites https://your-ghost-cms.org/welcome-post/ into /welcome-post/ so internal links work as expected.

Limitations

Currently the detection mechanism for the CMS site URL is limited to content coming from a headless Ghost CMS, but it should be easy to add some options, so this plugin becomes useful in other contexts.

Contributions

PRs are welcome! Consider contributing to this project if you are missing feature that is also useful for others. Explore this guide, to get some more ideas.

Copyright (c) 2020 styxlab - Released under the MIT license.

Keywords

FAQs

Last updated on 02 Mar 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc