Skip to content

Commit

Permalink
docs: support nav config for attr of external links
Browse files Browse the repository at this point in the history
  • Loading branch information
billyyyyy3320 committed Aug 1, 2019
1 parent e88caf2 commit 389c576
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
17 changes: 15 additions & 2 deletions packages/docs/docs/theme/default-theme-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,19 @@ module.exports = {
}
```

Outbound links automatically get `target="_blank" rel="noopener noreferrer"`. You can offer `target` and `rel` to customize the attributes:

``` js
// .vuepress/config.js
module.exports = {
themeConfig: {
nav: [
{ text: 'External', link: 'https://google.com', target:'_self', rel:'' },
]
}
}
```

These links can also be dropdown menus if you provide an array of `items` instead of a `link`:

```js
Expand Down Expand Up @@ -346,7 +359,7 @@ module.exports = {
```

::: warning Note
Unlike the [built-in search](#built-in-search) engine which works out of the box, [Algolia DocSearch](https://community.algolia.com/docsearch/) requires you to submit your site to them for indexing before it starts working.
Unlike the [built-in search](#built-in-search) engine which works out of the box, [Algolia DocSearch](https://community.algolia.com/docsearch/) requires you to submit your site to them for indexing before it starts working.
:::

For more options, refer to [Algolia DocSearch's documentation](https://github.com/algolia/docsearch#docsearch-options).
Expand Down Expand Up @@ -460,7 +473,7 @@ This will render `.vuepress/components/SpecialLayout.vue` for the given page.

## Ejecting

You can copy the default theme source code into `.vuepress/theme` to fully customize the theme using the `vuepress eject [targetDir]` command.
You can copy the default theme source code into `.vuepress/theme` to fully customize the theme using the `vuepress eject [targetDir]` command.

::: warning
Once you eject, you are on your own and **won't** be receiving future updates or bug fixes to the default theme even if you upgrade VuePress.
Expand Down
14 changes: 14 additions & 0 deletions packages/docs/docs/zh/theme/default-theme-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,20 @@ module.exports = {
]
}
}


```
外部链接 `<a>` 标签的特性将默认包含`target="_blank" rel="noopener noreferrer"`,你可以提供 `target` 与 `rel`,它们将被作为特性被增加到 `<a>` 标签上:

``` js
// .vuepress/config.js
module.exports = {
themeConfig: {
nav: [
{ text: 'External', link: 'https://google.com', target:'_self', rel:'' },
]
}
}
```

当你提供了一个 `items` 数组而不是一个单一的 `link` 时,它将显示为一个 `下拉列表` :
Expand Down

0 comments on commit 389c576

Please sign in to comment.