Skip to content

Conversation

@JounQin
Copy link
Collaborator

@JounQin JounQin commented Dec 24, 2025

Summary

support download links in nav

Related Issue

kind of related to #2822, I think changing nav at runtime would be a better solution for our case, but download link is not supported yet

Checklist

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

Copilot AI review requested due to automatic review settings December 24, 2025 10:10
@netlify
Copy link

netlify bot commented Dec 24, 2025

Deploy Preview for rspress-v2 ready!

Name Link
🔨 Latest commit e6c38c0
🔍 Latest deploy log https://app.netlify.com/projects/rspress-v2/deploys/694bbc346d87100008c69437
😎 Deploy Preview https://deploy-preview-2926--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.

Copy link
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 PR adds support for download links in navigation items by introducing a download property to the NavItemWithLink type. This allows navigation links to trigger file downloads when clicked, instead of navigating to a new page.

  • Added optional download property to the NavItemWithLink type definition
  • Updated English and Chinese documentation to reflect the new download property
  • Propagated the download property through all navigation components that render links

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/shared/src/types/theme/nav.ts Added optional download boolean property to NavItemWithLink type definition
website/docs/en/api/config/config-theme.mdx Documented the new download property for English documentation
website/docs/zh/api/config/config-theme.mdx Documented the new download property for Chinese documentation
packages/core/src/theme/components/NavScreen/NavScreenMenuItem.tsx Added download parameter to NavScreenMenuItemRaw and propagated it to the Link component for mobile navigation
packages/core/src/theme/components/Nav/NavMenu.tsx Passed download property to Link component in NavMenuItemWithLink for desktop navigation
packages/core/src/theme/components/HoverGroup/index.tsx Extracted and passed download property to Link component in hover group dropdown items

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

link: string;
download?: boolean;
tag?: string;
activeMatch?: string;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmm... Just found it's impossible to match different external links here(in our case, versions are external, /v1, /v2, /v3, etc), maybe functional activeMatch could be supported?

@SoonIter
Copy link
Member

...emmm, It is relatively difficult to maintain, this feature should also be added _nav.json

how about this workaround

// theme/index.tsx
import { Link as BasicLink } from '@rspress/theme/original'

const Link = (props) => {
  if(props.href === "mylink") {
    return <a></a>
  }
  return <BasicLink {...props} />
}

export { Link }
export * from '@rspress/core/theme-original';

@JounQin
Copy link
Collaborator Author

JounQin commented Dec 24, 2025

this feature should also be added _nav.json

I didn't read the source codes carefully yet, but doesn't it automatically supported?

how about this workaround

We fetch data at runtime and change nav dynamically, and that also doesn't work with current activeMatch which could not match external links like /external/v1 as I pointed at #2926 (comment).

@JounQin
Copy link
Collaborator Author

JounQin commented Dec 24, 2025

Did real hack way to implement without changes. alauda/doom#231

@JounQin JounQin closed this Dec 24, 2025
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.

2 participants