Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can disable this plugin except one page? #43

Open
vsolanogo opened this issue Mar 23, 2020 · 4 comments
Open

How can disable this plugin except one page? #43

vsolanogo opened this issue Mar 23, 2020 · 4 comments

Comments

@vsolanogo
Copy link

I need it only for single page

@vsolanogo vsolanogo changed the title How can disable this plugin excep one page? How can disable this plugin except one page? Mar 23, 2020
@shawngrona
Copy link

shawngrona commented Apr 1, 2020

+1 @wardpeet even tho i know you mentioned you were not interested in supporting this plug in this thread :) gatsbyjs/gatsby#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 gatsbyjs/gatsby#4337 (comment) 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 gatsbyjs/gatsby#4337 (comment) 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!!

@wardpeet
Copy link
Owner

wardpeet commented Apr 3, 2020

@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?

@vsolanogo
Copy link
Author

@wardpeet yep

@HashemKhalifa
Copy link

@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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants