🌜
🌞
gatsby-plugin-catch-links

gatsby-plugin-catch-links

v4.20.0

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-links

README

This 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

Installation

npm install gatsby-plugin-catch-links

How to use

// In your gatsby-config.js
plugins: [`gatsby-plugin-catch-links`]

Plugin Options

excludePattern [Regular Expression][optional]

Regular expression for paths to be excluded from being handled by this plugin.

{
  resolve: `gatsby-plugin-catch-links`,
  options: {
    excludePattern: /(excluded-link|external)/,
  },
},

Examples

  • Check out this live example Using Remark to see this plugin in action. The full source code for this example can be found here.

General

License
MIT
Typescript Types
None found
Tree-shakeable
No

Popularity

GitHub Stargazers
53.6K
Community Interest
62.7K
Number of Forks
10.4K

Maintenance

Commits
10/219/220200
Last Commit
Open Issues
92
Closed Issues
13.5K
Open Pull Requests
156
Closed Pull Requests
3,510

Versions

Versions Released
10/219/2208
Latest Version Released
Aug 2, 2022
Current Tags
latest4.20.0
next4.21.0-next.0
v3rc3.0.0-v3rc.0
otp-test2.1.6-otp-test.69
latest-v11.0.26
alpha-qe-sm3.14.0-alpha-qe-sm.46
alpha-9689ff4.0.0-alpha-9689ff.13
alpha-ts-jit4.6.0-alpha-ts-jit.60
asset-prefix2.0.12-asset-prefix.226
reach-router3.0.0-reach-router.186
image-helpers2.5.0-image-helpers.58
image-service4.8.0-alpha-image-service.24
unifiedroutes2.2.3-unifiedroutes.76
wp-image-cdn-auth4.15.0-alpha-wp-image-cdn-auth.48
drupal-self-reference4.18.0-alpha-drupal-self-reference.18

Contributors

KyleAMathews
KyleAMathews
Commits: 3,014
pieh
pieh
Commits: 884
wardpeet
wardpeet
Commits: 506
LekoArts
LekoArts
Commits: 436
sidharthachatterjee
sidharthachatterjee
Commits: 436
DSchau
DSchau
Commits: 354
m-allanson
m-allanson
Commits: 354
muescha
muescha
Commits: 301
shannonbux
shannonbux
Commits: 268
vladar
vladar
Commits: 268
ascorbic
ascorbic
Commits: 240
pvdz
pvdz
Commits: 240
fk
fk
Commits: 217
ChristopherBiscardi
ChristopherBiscardi
Commits: 186
tesseralis
tesseralis
Commits: 158