-
-
Notifications
You must be signed in to change notification settings - Fork 201
feat: support download links in nav #2926
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
Conversation
✅ Deploy Preview for rspress-v2 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
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.
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
downloadproperty to theNavItemWithLinktype definition - Updated English and Chinese documentation to reflect the new
downloadproperty - Propagated the
downloadproperty 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; |
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.
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?
|
...emmm, It is relatively difficult to maintain, this feature should also be added 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'; |
I didn't read the source codes carefully yet, but doesn't it automatically supported?
We fetch data at runtime and change nav dynamically, and that also doesn't work with current |
|
Did real hack way to implement without changes. alauda/doom#231 |
Summary
support download links in nav
Related Issue
kind of related to #2822, I think changing
navat runtime would be a better solution for our case, but download link is not supported yetChecklist