fix(theme/Link): Link and HomeHero should support relative url#2456
Merged
fix(theme/Link): Link and HomeHero should support relative url#2456
Conversation
✅ Deploy Preview for rspress ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for rspress-v2 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
b9a39f0 to
3716650
Compare
b2963e0 to
34ddaba
Compare
26b3a06 to
6261cbe
Compare
6261cbe to
a5d6e92
Compare
Timeless0911
approved these changes
Aug 11, 2025
Contributor
There was a problem hiding this comment.
Pull Request Overview
This pull request adds support for relative URLs in the Link component and HomeHero actions, allowing developers to use relative paths like ./guide/action-1.html instead of absolute paths. The changes primarily refactor the Link component to handle different types of URLs (external, hash-only, relative, and internal) more efficiently.
- Extracted navigation logic into a new
useNavigatehook with proper relative URL handling - Refactored Link component to handle relative URLs without requiring base path manipulation
- Updated HomeHero and HomeFeature components to use the new Link component for consistent navigation
Reviewed Changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
packages/theme-default/src/components/Link/useNavigate.ts |
New hook that handles URL type detection and navigation logic with relative URL support |
packages/theme-default/src/components/Link/index.tsx |
Refactored to use new navigation hook and handle different link types separately |
packages/theme-default/src/components/HomeHero/index.tsx |
Simplified to pass through raw action links without manual URL normalization |
packages/theme-default/src/components/HomeFeature/index.tsx |
Updated to use new navigate hook instead of direct window.location assignment |
packages/theme-default/src/components/Button/index.tsx |
Removed external prop and simplified to always use Link component |
packages/shared/src/runtime-utils/utils.ts |
Added early return for relative URLs in normalizeHref function |
| Other files | Test updates and documentation changes to use relative URLs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
fix(theme): relative url
Related Issue
Checklist