Skip to content

fix(theme/Link): Link and HomeHero should support relative url#2456

Merged
SoonIter merged 6 commits intomainfrom
syt/fix-relative-url
Aug 11, 2025
Merged

fix(theme/Link): Link and HomeHero should support relative url#2456
SoonIter merged 6 commits intomainfrom
syt/fix-relative-url

Conversation

@SoonIter
Copy link
Copy Markdown
Member

@SoonIter SoonIter commented Aug 8, 2025

Summary

fix(theme): relative url

---
pageType: home
hero:
  name: E2E 用例 title
  text: E2E 用例 subTitle
  tagline: E2E 用例 tagline
  actions:
    - text: 操作 1
      link: ./guide/action-1.html  <------ relative link
    - text: 操作 2
      link: ./guide/action-2.html <------ relative link
      theme: brand
    - text: External
      link: https://example.com/
      theme: alt
---

Related Issue

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copilot AI review requested due to automatic review settings August 8, 2025 09:07
@netlify
Copy link
Copy Markdown

netlify Bot commented Aug 8, 2025

Deploy Preview for rspress ready!

Name Link
🔨 Latest commit 3ab3d0a
🔍 Latest deploy log https://app.netlify.com/projects/rspress/deploys/689995070a6c490008a80c8f
😎 Deploy Preview https://deploy-preview-2456--rspress.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 82 (🔴 down 12 from production)
Accessibility: 97 (no change from production)
Best Practices: 92 (🟢 up 9 from production)
SEO: 100 (no change from production)
PWA: -
View the detailed breakdown and full score reports

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

@netlify
Copy link
Copy Markdown

netlify Bot commented Aug 8, 2025

Deploy Preview for rspress-v2 ready!

Name Link
🔨 Latest commit 3ab3d0a
🔍 Latest deploy log https://app.netlify.com/projects/rspress-v2/deploys/68999507ff46330008a67f54
😎 Deploy Preview https://deploy-preview-2456--rspress-v2.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 project configuration.

This comment was marked as outdated.

@SoonIter SoonIter marked this pull request as draft August 8, 2025 09:08
@SoonIter SoonIter changed the title fix(theme): relative url fix(theme/Link): relative url Aug 8, 2025
@SoonIter SoonIter force-pushed the syt/fix-relative-url branch from b2963e0 to 34ddaba Compare August 8, 2025 10:07
@SoonIter SoonIter changed the title fix(theme/Link): relative url fix(theme/Link): should support relative url Aug 8, 2025
@SoonIter SoonIter force-pushed the syt/fix-relative-url branch from 26b3a06 to 6261cbe Compare August 11, 2025 04:10
@SoonIter SoonIter force-pushed the syt/fix-relative-url branch from 6261cbe to a5d6e92 Compare August 11, 2025 05:37
@SoonIter SoonIter requested a review from Timeless0911 August 11, 2025 07:00
@SoonIter SoonIter marked this pull request as ready for review August 11, 2025 07:00
@SoonIter SoonIter changed the title fix(theme/Link): should support relative url fix(theme/Link): Link and HomeHero should support relative url Aug 11, 2025
@SoonIter SoonIter requested a review from Copilot August 11, 2025 07:23
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 useNavigate hook 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

Comment thread packages/theme-default/src/components/Link/useNavigate.ts
Comment thread packages/theme-default/src/components/Link/useNavigate.ts
Comment thread packages/theme-default/src/components/Link/index.tsx
@SoonIter SoonIter merged commit 5adabda into main Aug 11, 2025
13 checks passed
@SoonIter SoonIter deleted the syt/fix-relative-url branch August 11, 2025 07:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants