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

Nav ahref with target="_self" breaks the url when the link points to the same website, but to a directory other than VitePress's #2487

Closed
4 tasks done
cedivad opened this issue Jun 7, 2023 · 2 comments · Fixed by #2563
Labels
bug Something isn't working has-workaround Has workaround, low priority

Comments

@cedivad
Copy link

cedivad commented Jun 7, 2023

Describe the bug

I have VitePress installed at /docs/ and I would like to have a clickable item pointing to /other-dir/ from the navigation menu (config.js -> themeConfig -> nav []). However, when setting target: '_self', the a href stop working. I believe that the function catching those clicks is triggering but confused that:

  • The url is on the same website
  • It is outside of the urls VitePress knows about, so it thinks those don't exist

When changing the target url from website.com/other-dir/ to another-website.com, target: '_self' works just fine.

Reproduction

Install VitePress in a subdirectory and try to reach outside of the install directory, but on the same domain, without using _blank.

Expected behavior

_self shouldn't crash a href.

System Info

Latest

Additional context

No response

Validations

@cedivad cedivad added the bug: pending triage Maybe a bug, waiting for confirmation label Jun 7, 2023
@brc-dd brc-dd added bug Something isn't working and removed bug: pending triage Maybe a bug, waiting for confirmation labels Jun 7, 2023
@brc-dd brc-dd assigned brc-dd and unassigned brc-dd Jun 7, 2023
@brc-dd
Copy link
Member

brc-dd commented Jun 7, 2023

As a workaround, consider adding class="vp-raw" to that link. That will bypass that click handler.

@brc-dd brc-dd added the has-workaround Has workaround, low priority label Jun 7, 2023
@Red-Asuka
Copy link

@brc-dd I tried using class="vp-raw", which can indeed bypass click handler. However, in the production environment, this will load some non-existent JavaScript files. Is there any solution to this?

image

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working has-workaround Has workaround, low priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants