From b343cd3cb731b9776bd6e4e9186f76121d7f6056 Mon Sep 17 00:00:00 2001 From: Alex Bea Date: Thu, 23 Jul 2020 13:56:12 -0500 Subject: [PATCH] fix: allows no rel attribute on external links in the nav (#2338) * 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 Co-authored-by: Billyyyyy3320 --- packages/@vuepress/theme-default/components/NavLink.vue | 5 ++++- packages/docs/docs/theme/default-theme-config.md | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/@vuepress/theme-default/components/NavLink.vue b/packages/@vuepress/theme-default/components/NavLink.vue index 4ccd13d88b..f7e65a4451 100644 --- a/packages/@vuepress/theme-default/components/NavLink.vue +++ b/packages/@vuepress/theme-default/components/NavLink.vue @@ -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 } }, diff --git a/packages/docs/docs/theme/default-theme-config.md b/packages/docs/docs/theme/default-theme-config.md index 84cb68fefc..fe75254f05 100644 --- a/packages/docs/docs/theme/default-theme-config.md +++ b/packages/docs/docs/theme/default-theme-config.md @@ -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' } ] } @@ -355,7 +355,7 @@ You can improve the search result by [setting `tags` in frontmatter](../guide/fr ```yaml --- -tags: +tags: - configuration - theme - indexing