Skip to content
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

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

itsmaty
Copy link

@itsmaty itsmaty commented Mar 13, 2024

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

instead of just having chat & project link to display links with icons next to the searchbar in the navbar now you can add as many "icon links" as you want

remain chat & project link for backwards compatibility but push them to the array of links that get rendered that also contains eventual custom links set from the config
Copy link

changeset-bot bot commented Mar 13, 2024

⚠️ No Changeset found

Latest commit: c017296

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

Copy link

vercel bot commented Mar 13, 2024

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

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
nextra ⬜️ Ignored (Inspect) Visit Preview Mar 13, 2024 0:53am

Copy link

vercel bot commented Mar 13, 2024

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

A member of the Team first needs to authorize it.

Copy link
Collaborator

@dimaMachina dimaMachina left a comment

Choose a reason for hiding this comment

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

why not to use navbar.extraContent to add customizable content?

@itsmaty
Copy link
Author

itsmaty commented Mar 14, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants