gatsby-plugin-static-site
gatsby-plugin-static-site copied to clipboard
How can disable this plugin except one page?
I need it only for single page
+1 @wardpeet even tho i know you mentioned you were not interested in supporting this plug in this thread :) https://github.com/gatsbyjs/gatsby/issues/4337 i'm trying to dig into your code here to understand whats happening but finding it a bit tricky!
in my use case, i noticed your plugin works fine but disabling client side routing with this method also appears to disable client-only routes (which i need)
EDIT:
I ended up just following your advice from last year here https://github.com/gatsbyjs/gatsby/issues/4337#issuecomment-465497418 and editing gatsby-node.js as follows:
exports.onCreatePage = async({page, actions}) => {
if (page.path.match(/^\/network\/profile/)){
page.matchPath = `*`;
createPage(page);
}
}
Now the network/profile page does not attempt to change the url in the case where the route is instead network/{some other name}
This works for my use case, it may work for vsolanogo too...
There was some concern from ethagnawl here https://github.com/gatsbyjs/gatsby/issues/4337#issuecomment-465612238 on this approach calling it "hard to document and potentially fragile". Can you weigh in on the 'risk' here? You seem really plugged into this project, and its hard to tell who the players are in that 'Disable client side routing?' thread.
Thanks for your work/help!!
@shawngrona Haha, I'm OK with managing this, I don't think many modifications are necessary. I'm part of the gatsby team and I have e2e-tests in place so I should catch breaking changes.
@vsolanogo can you give a better description of what you mean? You want a specific page to disable routing but for everything else, not?
@wardpeet yep
@wardpeet I need this too.
In case you are using a dynamic route for specific page for example.
if (page.path.match(/^/app/)) {
page.matchPath = "/app/*"
createPage(page)
}
I'm using an API in the app page to create a dynamic route @react-reach but it's not possible with the plugin.
example:
<Component path="/form/c/:results" />
Hope it's clear now!