nextra icon indicating copy to clipboard operation
nextra copied to clipboard

feat(theme-docs): add ability to add custom links to navbar like project & chat links

Open itsmaty opened this issue 1 year ago • 4 comments

Previously you could add only two (project & chat link), you could change the icon & link to use these for completely other links but the internal names always where chat & project link and as said you where hardcoded limited to two links which in my opinion was a bad design decision, maybe there was a reason when it was developed. image

Now you can add as many links with icons as you want while still supporting "chat" & "project" in the config for backwards compatibility.

You can now use "links" in the config which is an array of link components with and "link" and an "icon" property. Internally this array just gets mapped over and renders all link components. To have said backwards compatibility the icon & chat link (if set), just get pushed to the links array.

Maybe there is a better solution than using useEffect to pus project & chat link to the links array as you can see i did in the code.

I tested the functionality, works great. image

Would love to see this feature in v3.

Best regards, Matthias

itsmaty avatar Mar 13 '24 12:03 itsmaty

⚠️ No Changeset found

Latest commit: b2c9ef6f81dc1bc2e9c0ace0a180624f5ce867d8

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

changeset-bot[bot] avatar Mar 13 '24 12:03 changeset-bot[bot]

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nextra-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 14, 2024 0:00am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
nextra ⬜️ Ignored (Inspect) Visit Preview Aug 14, 2024 0:00am

vercel[bot] avatar Mar 13 '24 12:03 vercel[bot]

@itsmaty is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Mar 13 '24 12:03 vercel[bot]

Technically you can use navbar.extraContent to add more "icon buttons", but its not a clear way when you intend to add more buttons and you have to add the linking functionality yourself.

I just think its easier that if you want to add more buttons you have an config where you can add a button object and it just works.

It's your decision whether you think it improves nextra and is useful or not. For me it is.

itsmaty avatar Mar 14 '24 11:03 itsmaty