diff --git a/docs/configuration.md b/docs/configuration.md index ba4847598..786bd971c 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -397,7 +397,7 @@ 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 = { @@ -405,6 +405,19 @@ window.$docsify = { }; ``` +## 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` diff --git a/src/core/config.js b/src/core/config.js index a1386b274..0d2139395 100644 --- a/src/core/config.js +++ b/src/core/config.js @@ -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 diff --git a/src/core/render/index.js b/src/core/render/index.js index fae1bc526..b4d16006d 100644 --- a/src/core/render/index.js +++ b/src/core/render/index.js @@ -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() diff --git a/src/core/render/tpl.js b/src/core/render/tpl.js index 79cbaaec6..64ba92562 100644 --- a/src/core/render/tpl.js +++ b/src/core/render/tpl.js @@ -4,7 +4,7 @@ import {isMobile} from '../util/env' * @param {Object} data * @return {String} */ -export function corner(data) { +export function corner(data, cornerExternalLinkTarge) { if (!data) { return '' } @@ -12,9 +12,11 @@ export function corner(data) { data = 'https://github.com/' + data } data = data.replace(/^git\+/, '') + // double check + cornerExternalLinkTarge = cornerExternalLinkTarge || '_blank' return ( - `` + + `` + '