Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wardpeet/gatsby-plugin-static-site",
"version": "0.3.0",
"version": "0.4.0",
"description": "A plugin that disables client side routing for gatsby",
"main": "index.js",
"author": "Ward Peeters <[email protected]>",
Expand All @@ -17,7 +17,7 @@
},
"license": "MIT",
"peerDependencies": {
"gatsby": "^3.0.0"
"gatsby": "^3.0.0 || ^4.0.0"
},
"files": [
"gatsby-browser.js",
Expand Down
18 changes: 12 additions & 6 deletions src/gatsby-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@ exports.onClientEntry = () => {

loader.loadPageSync = path => {
let pageResources;
// if the path is the same as our current page we know it's not a prefetch
if (path === location.pathname) {
// With Gatsby V4, path has been appended with window.location.search when invoking loadPageSync
const pathWithoutQueryParams = path.replace(location.search, '');

// if the pathWithoutQueryParams is the same as our current page we know it's not a prefetch
if (pathWithoutQueryParams === location.pathname) {
pageResources = originalLoadPageSync(pagePath);
} else {
pageResources = originalLoadPageSync(path);
pageResources = originalLoadPageSync(pathWithoutQueryParams);
}

if (pageResources.page) {
Expand All @@ -37,11 +40,14 @@ exports.onClientEntry = () => {

loader.loadPage = path => {
let pageResources;
// if the path is the same as our current page we know it's not a prefetch
if (path === location.pathname) {
// With Gatsby V4, path has been appended with window.location.search when invoking loadPage
const pathWithoutQueryParams = path.replace(location.search, '');

// if the pathWithoutQueryParams is the same as our current page we know it's not a prefetch
if (pathWithoutQueryParams === location.pathname) {
pageResources = originalLoadPage(pagePath);
} else {
pageResources = originalLoadPage(path);
pageResources = originalLoadPage(pathWithoutQueryParams);
}

if (pageResources.page) {
Expand Down