From e61410a7571aed1604b3a73c2d31be8d05924311 Mon Sep 17 00:00:00 2001
From: Mt <369491420@qq.com>
Date: Fri, 10 May 2019 15:47:07 +0800
Subject: [PATCH] add new config `cornerExternalLinkTarget` for the corner link
target
rm CNAME
add CNAME
add repo test
back to the origin index.html
fix: the Git corner displayed bigger when the externalLinkTarget = ''
[update] a new independent config for corner link target attribute.
[update doc] add the `cornerExternalLinkTarget` config in the doc.
---
docs/configuration.md | 15 ++++++++++++++-
src/core/config.js | 3 +++
src/core/render/index.js | 2 +-
src/core/render/tpl.js | 6 ++++--
4 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/docs/configuration.md b/docs/configuration.md
index ba48475..786bd97 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 a1386b2..0d21393 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 1c0373c..b4d1600 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, config.externalLinkTarget)
+ 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 7831e86..e280c4b 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, externalLinkTarget) {
+export function corner(data, cornerExternalLinkTarge) {
if (!data) {
return ''
}
@@ -12,9 +12,11 @@ export function corner(data, externalLinkTarget) {
data = 'https://github.com/' + data
}
data = data.replace(/^git\+/, '')
+ // double check
+ cornerExternalLinkTarge = cornerExternalLinkTarge || '_blank'
return (
- `` +
+ `` +
'