Intercepts local links from markdown and other non-react pages and does a client-side pushState to avoid the browser having to refresh the page.
npm install gatsby-plugin-catch-linksThis plugin intercepts all local links that have not been created in React using gatsby-link, and replaces their behavior with that of the gatsby-link navigate. This avoids the browser having to refresh the whole page when navigating between local pages, preserving the Single Page Application (SPA) feel.
Example use cases:
- A markdown file with relative links (transformed
to a tags by
gatsby-transformer-remark)
- An a tag that has been created by a Content Management System (CMS) WYSIWYG editor
``shell`
npm install gatsby-plugin-catch-links
`javascriptgatsby-plugin-catch-links
// In your gatsby-config.js
plugins: []`
excludePattern [Regular Expression][optional]
Regular expression for paths to be excluded from being handled by this plugin.
`javascriptgatsby-plugin-catch-links
{
resolve: ,``
options: {
excludePattern: /(excluded-link|external)/,
},
},
- Check out this live example _Using Remark_ to see this plugin in action. The full source code for this example can be found here.