-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Allow NavLinks to open in the same window (applies to default theme) #1353
Allow NavLinks to open in the same window (applies to default theme) #1353
Comments
Try: module.exports = {
markdown: {
externalLinks: {
target: '_self',
rel: ''
}
}
} |
@ulivz thanks, but I'm talking about the NavLink component in the default theme's header: vuepress/packages/@vuepress/theme-default/components/NavLink.vue Lines 8 to 14 in e231744
The suggestion you provided only affects page content written in markdown. The change should probably be along the lines of: <a
v-else
:href="link"
class="nav-link external"
:target="resolveTarget(link)"
:rel="isMailto(link) || isTel(link) ? null : 'noopener noreferrer'"
> ... resolveTarget(link) {
if (link.target) return link.target;
if (isMailto(link) || isTel(link)) return null;
return '_blank';
} Can you re-open the issue and I can create a PR against it? |
I would also use it |
I ran in this issue as well. I can drop $5 for this in Eth |
Feature request
Similar to #186, the nav links in the the default theme should also allow devs to define if a link should open in a new tab or the same tab.
What problem does this feature solve?
If there are .html files in the
public
directory, or external sites we want to link to (one of our links says "Back to "), but not open in a new window, we should at least have the option to override thetarget=_blank
.What does the proposed API look like?
Same as before
How should this be implemented in your opinion?
So essentially, the theme config would look like this if we wanted an external link to open in the same tab:
with the same logic as #186 applied to the
NavLink
componentAre you willing to work on this yourself?**
Sure
The text was updated successfully, but these errors were encountered: