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

fix(dev-portal): fix broken hash router links #2497

Merged
merged 1 commit into from
Jan 4, 2024

Conversation

daniel-white
Copy link
Contributor

when using elements-dev-portal and the hash router, a custom toc with slugs would result in a broken page. this fixes the route matching and makes the routes absolute

@daniel-white daniel-white requested a review from a team as a code owner January 4, 2024 17:54
@daniel-white daniel-white marked this pull request as draft January 4, 2024 17:54
Copy link

netlify bot commented Jan 4, 2024

Deploy Preview for stoplight-elements ready!

Name Link
🔨 Latest commit 3615963
🔍 Latest deploy log https://app.netlify.com/sites/stoplight-elements/deploys/6596fb72bb7db00008b75d70
😎 Deploy Preview https://deploy-preview-2497--stoplight-elements.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Jan 4, 2024

Deploy Preview for stoplight-elements-demo ready!

Name Link
🔨 Latest commit 3615963
🔍 Latest deploy log https://app.netlify.com/sites/stoplight-elements-demo/deploys/6596fb722431f30008f8aa67
😎 Deploy Preview https://deploy-preview-2497--stoplight-elements-demo.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

@EdVinyard EdVinyard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Had one tiny question/suggestion. Feel free to take it or leave it.

return (
<Box
as={LinkComponent}
to={makeSlugAbsoluteRoute && !/^\//.test(item.slug) ? `/${item.slug}` : item.slug}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It took me a minute to find this change, so I'm just marking it for other reviewers.

Is there an advantage to using a regular expression here instead of !item.slug.startsWith('/')?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

old habits die hard

@daniel-white daniel-white marked this pull request as ready for review January 4, 2024 18:54
@daniel-white daniel-white merged commit c28eaed into main Jan 4, 2024
7 checks passed
@daniel-white daniel-white deleted the fix/dev-portal-hash-route branch January 4, 2024 18:58
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

Successfully merging this pull request may close these issues.

2 participants