-
Notifications
You must be signed in to change notification settings - Fork 156
feat(browse): Implement dynamic tab titles for files and folders #560
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
feat(browse): Implement dynamic tab titles for files and folders #560
Conversation
feat(utils): Add parseRepoPath function to extract repository name and revision from URL path
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Want me to fix the changelog thing? I think I just need to add an entry in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! If you could add a Changelog entry, that will unblock the changelog gate that is failing.
Closes #538
Description
This pull request addresses the issue where the browser tab title remained generic ("Sourcebot") while navigating the code browser. The goal was to make the title dynamic and context-aware, displaying the current file or folder name to improve user experience and navigability.
Solution
This PR implements the recommended Next.js approach for dynamic metadata by using the server-side
generateMetadata
function within thebrowse/[...path]/page.tsx
file.The core changes include:
generateMetadata
Export: Added theasync function generateMetadata({ params })
tosrc/app/[domain]/browse/[...path]/page.tsx
. This allows Next.js to set the page title on the server during the rendering process.parsePathForTitle
Helper Function: A robust, provider-agnostic parsing function was created to interpret the URLpath
array. This function:owner/repo @ HEAD
).blob
), a directory (tree
), or the repository root.filename.ts - owner/repo @ revision
folder/path/ - owner/repo @ revision
owner/repo @ revision
How to Test
/~/browse/github.com/sourcebot-dev/sourcebot@HEAD
).sourcebot-dev/sourcebot @ HEAD | Sourcebot
.~/browse/github.com/sourcebot-dev/sourcebot@HEAD/-/tree/packages%2Fweb
).packages/web/ - sourcebot-dev/sourcebot @ HEAD | Sourcebot
.~/browse/github.com/sourcebot-dev/sourcebot@HEAD/-/blob/packages%2Fweb%2Fsrc%2Fauth.ts
).auth.ts - sourcebot-dev/sourcebot @ HEAD | Sourcebot
.