Skip to content

Commit

Permalink
fix: allows no rel attribute on external links in the nav (#2338)
Browse files Browse the repository at this point in the history
* fix: allows no rel attribute on external links in the nav

* fix: documents the falsy rel option

* fix: clarifies documentation

* fix: explicitly uses  for rel attr

* fix: removes unnecessary condition

Co-authored-by: Billyyyyy3320 <newsbielt703@gmail.com>

Co-authored-by: Billyyyyy3320 <newsbielt703@gmail.com>
  • Loading branch information
abea and billyyyyy3320 committed Jul 23, 2020
1 parent 18b2198 commit b343cd3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion packages/@vuepress/theme-default/components/NavLink.vue
Expand Up @@ -71,10 +71,13 @@ export default {
if (this.isNonHttpURI) {
return null
}
if (this.item.rel === false) {
return null
}
if (this.item.rel) {
return this.item.rel
}
return this.isBlankTarget ? 'noopener noreferrer' : ''
return this.isBlankTarget ? 'noopener noreferrer' : null
}
},
Expand Down
6 changes: 3 additions & 3 deletions packages/docs/docs/theme/default-theme-config.md
Expand Up @@ -69,14 +69,14 @@ module.exports = {
}
```

Outbound links automatically get `target="_blank" rel="noopener noreferrer"`. You can offer `target` and `rel` to customize the attributes:
Outbound links automatically get `target="_blank" rel="noopener noreferrer"`. You can offer `target` and `rel` to customize the attributes. Setting `rel: false` as will disable the `rel` attribute for a link:

``` js
// .vuepress/config.js
module.exports = {
themeConfig: {
nav: [
{ text: 'External', link: 'https://google.com', target:'_self', rel:'' },
{ text: 'External', link: 'https://google.com', target:'_self', rel:false },
{ text: 'Guide', link: '/guide/', target:'_blank' }
]
}
Expand Down Expand Up @@ -355,7 +355,7 @@ You can improve the search result by [setting `tags` in frontmatter](../guide/fr

```yaml
---
tags:
tags:
- configuration
- theme
- indexing
Expand Down

0 comments on commit b343cd3

Please sign in to comment.