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

In Autogen the route is appearing instead of the Label #69

Closed
gp1234 opened this issue Apr 17, 2020 · 7 comments
Closed

In Autogen the route is appearing instead of the Label #69

gp1234 opened this issue Apr 17, 2020 · 7 comments
Assignees

Comments

@gp1234
Copy link

gp1234 commented Apr 17, 2020

I am working with a route with subdirectories in autogen mode like so http://localhost:8000/page1/page-2/page-3 and in the label it is appearing me the pathname (without the slash) instead of the label I have previously set in each of the pages.
Expected result: Home - Page 1 - Page 2 - Page 3
Actual result: Home-page1-page-2-page-3

@sbardian
Copy link
Owner

sbardian commented Apr 17, 2020

@gp1234 the default is the page name for the crumb. If you would like to change it try using the crumbLabel prop. Let me know if this works out. See a list of props here.

@sbardian sbardian self-assigned this Apr 17, 2020
@sbardian
Copy link
Owner

@gp1234 read your issue again. . . Do you have a codesandbox I could take a look at, maybe I didn't understand it completely with my first reply.

@gp1234
Copy link
Author

gp1234 commented Apr 17, 2020

@sbardian thank you for answering me, I will do a codesandbox right now, in the meantime maybe I could explain myself better, I am using the crumLabel prop in each page where I use the breadcrumb component even though when I visit this page the crumLabel prop is taken when I continue down the herarchy they loose the crumbLabel I have define and take the url path.

@sbardian
Copy link
Owner

sbardian commented Apr 17, 2020

@gp1234 ah, I think I know what is going on here. See the following for the gatsby-config.js options here. I have to do this in my Books app also. I have a Breadcrumb structure like ( Home / Books / Eye of the World ). Where "Books" is my path like yours. Try using the gatsby-config.js option as follows for those path updates when not on the specific paths.

        // crumbLabelUpdates: optional, update specific crumbLabels in the path
        crumbLabelUpdates: [
          {
            pathname: '/book',
            crumbLabel: 'Books'
          }
        ]

This takes an array of objects, one for each path option you would like to provide a crumb label for. Let me know!

@sbardian
Copy link
Owner

@gp1234 This isn't documented very well, if you do a codesandbox I can show you how to use this option and confirm this is what is going on. Thanks!

@gp1234
Copy link
Author

gp1234 commented Apr 17, 2020

@sbardian Thank you! yes this is the way to do it. I was able to implement it in my project. It will be really cool if this was done automatically though. Have a nice day and thank you again!

@sbardian
Copy link
Owner

@gp1234 I'll look into this again to see if there is an option for that. Sadly when the breadcrumbs are auto generated (at build time) it doesn't have the props being sent via the <Breadcrumb/> component. Happy to hear it works for you! I'm going to close this out, feel free to reopen, or open a new issue if needed. Thanks!

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

2 participants