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

fix: open docs links in the same tab closes #6927 #6936

Merged
merged 2 commits into from
Jul 27, 2024

Conversation

wesleytodd
Copy link
Member

@wesleytodd wesleytodd commented Jul 19, 2024

Description

Open Docs link in the same tab

Validation

Open the docs link in the header, should not have the icon and should open in the same tab.

Fixes #6927

Related Issues

Check List

  • I have read the Contributing Guidelines and made commit messages that follow the guideline.
  • I have run npm run format to ensure the code follows the style guide.
  • I have run npm run test to check if all tests are passing.
  • I have run npx turbo build to check if the website builds without errors.
  • I've covered new added functionality with unit tests if necessary.

@wesleytodd wesleytodd requested a review from a team as a code owner July 19, 2024 19:58
Copy link

vercel bot commented Jul 19, 2024

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

Name Status Preview Updated (UTC)
nodejs-org ✅ Ready (Inspect) Visit Preview Jul 22, 2024 9:41pm

@bmuenzenmeyer
Copy link
Collaborator

bmuenzenmeyer commented Jul 19, 2024

I'm getting a 404 on this current approach.

https://nodejs-org-git-fork-wesleytodd-docs-in-tab-openjs.vercel.app/en/docs/latest/api/

It may need to be the absolute url to account for the way the site is built and/or requests are routed by CF

Jay-Karia

This comment was marked as resolved.

@Jay-Karia
Copy link
Contributor

I'm getting a 404 on this current approach.

https://nodejs-org-git-fork-wesleytodd-docs-in-tab-openjs.vercel.app/en/docs/latest/api/

It may need to be the absolute url to account for the way the site is built and/or requests are routed by CF

@wesleytodd Does it work locally ?

@Jay-Karia
Copy link
Contributor

This works,

"docs": {
  "link": "https://nodejs.org/docs/latest/api/",
  "label": "components.containers.navBar.links.docs"
},

But, the icon in navbar renders.

@ovflowd
Copy link
Member

ovflowd commented Jul 20, 2024

I'm getting a 404 on this current approach.

nodejs-org-git-fork-wesleytodd-docs-in-tab-openjs.vercel.app/en/docs/latest/api

It may need to be the absolute url to account for the way the site is built and/or requests are routed by CF

With absolute paths, it will always use i18n routing. That's why we use the full path. We can use the full DN (https://nodejs.org/api...), but the external icon will render it, although it will not open on a blank tab, which is what this PR intends to fix.

@wesleytodd
Copy link
Member Author

Well IMO the icon should also not render if it is not opening in a new tab. @ovflowd, am I understanding this last comment that the current setup would need a change to exclude this route from the i18n treatment which adds in the /en? What if instead we remove the check for type === 'nav' && href.startsWith('http')? Is this component used for more than just the nav bar?

@wesleytodd
Copy link
Member Author

Figured it was just easier to push a change to this and see what y'all wanted to do.

Copy link
Collaborator

@bmuenzenmeyer bmuenzenmeyer left a comment

Choose a reason for hiding this comment

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

I'm fine with this. From a user perspective I wouldn't imagine anyone sees these as two different sites, and someone can always middle click or "open in new tab/window" contextually.

Copy link
Contributor

@AugustinMauroy AugustinMauroy left a comment

Choose a reason for hiding this comment

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

LGMT !
I prefer this behavior

Copy link

Unit Test Coverage Report

Lines Statements Branches Functions
Coverage: 92%
90.67% (593/654) 76.08% (175/230) 94.57% (122/129)

Unit Test Report

Tests Skipped Failures Errors Time
131 0 💤 0 ❌ 0 🔥 5.179s ⏱️

Copy link
Member

@juanarbol juanarbol left a comment

Choose a reason for hiding this comment

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

Thanks!

Copy link
Member

@mikeesto mikeesto left a comment

Choose a reason for hiding this comment

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

LGTM, let's land this

@mikeesto mikeesto added this pull request to the merge queue Jul 27, 2024
Merged via the queue into nodejs:main with commit d2f278a Jul 27, 2024
13 of 14 checks passed
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.

Open docs link in same window
8 participants