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: allow activeBaseRegex for DocNavbarItem #8079

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

Conversation

juliusmarminge
Copy link

@juliusmarminge juliusmarminge commented Sep 10, 2022

Pre-flight checklist

  • I have read the Contributing Guidelines on pull requests.
  • If this is a code change: I have written unit tests and/or added dogfooding pages to fully verify the new behavior.
  • If this is a new API or substantial change: the PR has an accompanying issue (closes #0000) and the maintainers have approved on my working plan.

Motivation

DocNavbarItem's currently aren't allowed being matched using activeBasePath or activeBaseRegex like other NavbarItems. This PR adds the ability to match these too.

For reference, on the tRPC website, we have multiple DocItems in the navbar, and currently they are all being matched as active. By allowing them to be regex matched we would have more flexibility and could fix this issue.

Test Plan

I don't think there is any need for tests. I have reused the same logic from NavbarNavLink. If you disagree, let me know and we can work it out.

Test links

  • NaN

Deploy preview: https://deploy-preview-_____--docusaurus-2.netlify.app/

Related issues/PRs

Closes #8018

@netlify
Copy link

netlify bot commented Sep 10, 2022

[V2]

Built without sensitive environment variables

Name Link
🔨 Latest commit 8e5a75f
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/631cf550026c860009217da8
😎 Deploy Preview https://deploy-preview-8079--docusaurus-2.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 site settings.

Comment on lines +433 to +445
{
type: 'doc',
position: 'left',
docId: 'playground',
label: 'Playground',
activeBaseRegex: `/docs/playground`,
},
{
type: 'doc',
position: 'left',
docId: 'playground',
label: 'Playground',
},
Copy link
Author

Choose a reason for hiding this comment

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

As you can see, the 2nd Playground link is active matched no matter what doc page we're at, whereas the first one is only matched when we are at docs/playground.

CleanShot 2022-09-10 at 22 41 32@2x

CleanShot 2022-09-10 at 22 41 42@2x

@github-actions
Copy link

⚡️ Lighthouse report for the deploy preview of this PR

URL Performance Accessibility Best Practices SEO PWA Report
/ 🟠 83 🟢 98 🟢 100 🟢 100 🟠 80 Report
/docs/installation 🟠 81 🟢 100 🟢 100 🟢 100 🟢 90 Report

@netlify
Copy link

netlify bot commented Sep 10, 2022

[V2]

Built without sensitive environment variables

Name Link
🔨 Latest commit c29870f
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/631cf645cddb94000c325883
😎 Deploy Preview https://deploy-preview-8079--docusaurus-2.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 site settings.

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

Successfully merging this pull request may close these issues.

active matching to multiple sub paths
2 participants