Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3d662a5

Browse files
committed
fix: fixed target and rel issue (fixes#1183)
1 parent9ff4d06 commit3d662a5

File tree

10 files changed

+117
-95
lines changed

10 files changed

+117
-95
lines changed

‎packages/docsify-server-renderer/index.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import{readFileSync}from'fs';
22
import{resolve,basename}from'path';
33
importresolvePathnamefrom'resolve-pathname';
4+
importfetchfrom'node-fetch';
5+
importdebugfrom'debug';
46
import{AbstractHistory}from'../../src/core/router/history/abstract';
57
import{Compiler}from'../../src/core/render/compiler';
68
import{isAbsolutePath}from'../../src/core/router/util';
79
import*astplfrom'../../src/core/render/tpl';
810
import{prerenderEmbed}from'../../src/core/render/embed';
9-
importfetchfrom'node-fetch';
10-
importdebugfrom'debug';
1111

1212
functioncwd(...args){
1313
returnresolve(process.cwd(), ...args);

‎src/core/event/scroll.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
importTweezerfrom'tweezer.js';
12
import{isMobile}from'../util/env';
23
import*asdomfrom'../util/dom';
34
import{removeParams}from'../router/util';
45
importconfigfrom'../config';
5-
importTweezerfrom'tweezer.js';
66

77
constnav={};
88
lethoverOver=false;

‎src/core/global-api.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1+
importprismfrom'prismjs';
2+
importmarkedfrom'marked';
13
import*asutilfrom'./util';
24
import*asdomfrom'./util/dom';
35
import{Compiler}from'./render/compiler';
46
import{slugify}from'./render/slugify';
57
import{get}from'./fetch/ajax';
6-
importprismfrom'prismjs';
7-
importmarkedfrom'marked';
88

99
exportdefaultfunction(){
1010
window.Docsify={

‎src/core/render/compiler.js‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
importmarkedfrom'marked';
12
import{isAbsolutePath,getPath,getParentPath}from'../router/util';
23
import{isFn,merge,cached,isPrimitive}from'../util/core';
34
import{treeastreeTpl}from'./tpl';
@@ -11,7 +12,6 @@ import { paragraphCompiler } from './compiler/paragraph';
1112
import{taskListCompiler}from'./compiler/taskList';
1213
import{taskListItemCompiler}from'./compiler/taskListItem';
1314
import{linkCompiler}from'./compiler/link';
14-
importmarkedfrom'marked';
1515

1616
constcachedLinks={};
1717

@@ -193,7 +193,7 @@ export class Compiler {
193193

194194
_initRenderer(){
195195
constrenderer=newmarked.Renderer();
196-
const{ linkTarget, router, contentBase}=this;
196+
const{ linkTarget,linkRel,router, contentBase}=this;
197197
const_self=this;
198198
constorigin={};
199199

@@ -233,6 +233,7 @@ export class Compiler {
233233
renderer,
234234
router,
235235
linkTarget,
236+
linkRel,
236237
compilerClass:_self,
237238
});
238239
origin.paragraph=paragraphCompiler({ renderer});

‎src/core/render/compiler/link.js‎

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
import{getAndRemoveConfig}from'../utils';
22
import{isAbsolutePath}from'../../router/util';
33

4-
exportconstlinkCompiler=({ renderer, router, linkTarget, compilerClass})=>
4+
exportconstlinkCompiler=({
5+
renderer,
6+
router,
7+
linkTarget,
8+
linkRel,
9+
compilerClass,
10+
})=>
511
(renderer.link=(href,title='',text)=>{
612
letattrs=[];
713
const{ str, config}=getAndRemoveConfig(title);
8-
14+
linkTarget=config.target||linkTarget;
15+
linkRel=
16+
linkTarget==='_blank'
17+
?compilerClass.config.externalLinkRel||'noopener'
18+
:'';
919
title=str;
1020

1121
if(
@@ -24,10 +34,13 @@ export const linkCompiler = ({ renderer, router, linkTarget, compilerClass }) =>
2434
document.URL.replace(/\/(?!.*\/).*/,'/').replace('#/./','')+href;
2535
}
2636
attrs.push(href.indexOf('mailto:')===0 ?'' :`target="${linkTarget}"`);
27-
}
28-
29-
if(config.target){
30-
attrs.push(`target="${config.target}"`);
37+
attrs.push(
38+
href.indexOf('mailto:')===0
39+
?''
40+
:linkRel!==''
41+
?` rel="${linkRel}"`
42+
:''
43+
);
3144
}
3245

3346
// special case to check crossorigin urls

‎src/core/render/embed.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
importstripIndentfrom'strip-indent';
12
import{get}from'../fetch/ajax';
23
import{merge}from'../util/core';
3-
importstripIndentfrom'strip-indent';
44

55
constcached={};
66

‎src/core/render/index.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* eslint-disable no-unused-vars */
2+
importtinydatefrom'tinydate';
23
import*asdomfrom'../util/dom';
34
importcssVarsfrom'../util/polyfill/css-vars';
45
import{callHook}from'../init/lifecycle';
@@ -10,7 +11,6 @@ import { scrollActiveSidebar } from '../event/scroll';
1011
import{Compiler}from'./compiler';
1112
import*astplfrom'./tpl';
1213
import{prerenderEmbed}from'./embed';
13-
importtinydatefrom'tinydate';
1414

1515
functionexecuteScript(){
1616
constscript=dom

‎test/unit/base.test.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
require=require('esm')(
33
module/* , options */
44
);/* eslint-disable-line no-global-assign */
5-
const{ History}=require('../../src/core/router/history/base');
65
const{ expect}=require('chai');
6+
const{ History}=require('../../src/core/router/history/base');
77

88
classMockHistoryextendsHistory{
99
parse(path){

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp