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

fix #835 :Link target of repo's GitHub Corner add new independent config cornerExternalLinkTarget. #842

Merged
merged 2 commits into from
Dec 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -397,14 +397,27 @@ window.$docsify = {
- type: `String`
- default: `_blank`

Target to open external links. Default `'_blank'` (new window/tab)
Target to open external links inside the markdown. Default `'_blank'` (new window/tab)

```js
window.$docsify = {
externalLinkTarget: '_self' // default: '_blank'
};
```

## cornerExternalLinkTarget

- type:`String`
- default:`_blank`

Target to open external link at the top right corner. Default `'_blank'` (new window/tab)

```js
window.$docsify = {
cornerExternalLinkTarget: '_self' // default: '_blank'
};
```

## routerMode

- type: `String`
Expand Down
3 changes: 3 additions & 0 deletions src/core/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ export default function () {
ext: '.md',
mergeNavbar: false,
formatUpdated: '',
// this config for the links inside markdown
externalLinkTarget: '_blank',
// this config for the corner
cornerExternalLinkTarget: '_blank',
routerMode: 'hash',
noCompileLinks: [],
relativePath: false
Expand Down
2 changes: 1 addition & 1 deletion src/core/render/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ export function initRender(vm) {

if (el) {
if (config.repo) {
html += tpl.corner(config.repo)
html += tpl.corner(config.repo, config.cornerExternalLinkTarge)
}
if (config.coverpage) {
html += tpl.cover()
Expand Down
6 changes: 4 additions & 2 deletions src/core/render/tpl.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@ import {isMobile} from '../util/env'
* @param {Object} data
* @return {String}
*/
export function corner(data) {
export function corner(data, cornerExternalLinkTarge) {
if (!data) {
return ''
}
if (!/\/\//.test(data)) {
data = 'https://github.com/' + data
}
data = data.replace(/^git\+/, '')
// double check
cornerExternalLinkTarge = cornerExternalLinkTarge || '_blank'

return (
`<a href="${data}" class="github-corner" aria-label="View source on Github">` +
`<a href="${data}" target="${cornerExternalLinkTarge}" class="github-corner" aria-label="View source on Github">` +
'<svg viewBox="0 0 250 250" aria-hidden="true">' +
'<path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path>' +
'<path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path>' +
Expand Down