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

hexo 4.0.0 會給 a 標簽 添加 target="_blank" #3796

Closed
4 tasks
jerryc127 opened this issue Oct 24, 2019 · 6 comments · Fixed by #3812
Closed
4 tasks

hexo 4.0.0 會給 a 標簽 添加 target="_blank" #3796

jerryc127 opened this issue Oct 24, 2019 · 6 comments · Fixed by #3812

Comments

@jerryc127
Copy link

Check List

Please check followings before submitting a new issue.

  • I have already read Docs page & Troubleshooting page
  • I have already searched existing issues and they are not help to me
  • I examined error or warning messages and it's difficult to solve
  • Node.js is higher than 6.9

Expected behavior

Actual behavior

How to reproduce?

  • Step1
  • Step2
  • etc...

Environment & Settings

Node.js & npm version

Your site _config.yml (Optional)

Your theme _config.yml (Optional)

Hexo and Plugin version(npm ls --depth 0)

Your package.json package.json

Others

hexo 4.0.0 會給 一些a 標簽 添加 target="_blank"
而原本a 標簽是默認本頁打開的,導致打開a標簽會跳出一個頁面 about:blank#blocked

具體這個 hexo - douban的插件 生成的頁面
別添加 target="_blank" 后,導致點擊上一頁/下一頁/進入這個頁面 都會跳出一個about:blank#blocked 空頁面

我退回 3.9.0 后 沒發現問題。。可以斷定是hexo 4.0.0的問題

@curbengh
Copy link
Contributor

In your _config.yml:

external_link:
  enable: false

@SukkaW
Copy link
Member

SukkaW commented Oct 27, 2019

This is a BREAKING CHANGES of Hexo 4.0.0.

Before Hexo 4.0, external_link only applies to the post by default, and Hexo 4.0 applies to the whole website.

@curbengh
Copy link
Contributor

@jerryc127
If you only want to apply external_link to post,

external_link:
  enable: true
  field: post

The above config restore pre-4.0 behavior.

Alternatively, you could also exclude certain domains:

external_link:
  enable: true
  exclude:
    - a.douban.com
    - b.douban.com

@jerryc127
Copy link
Author

@SukkaW @curbengh
感謝回答

有個建議 ,如果 a標簽是 href="javascript:void(0)"和"javascript:;"
這種的就不要加上 target="_blank"
這種用途就是通過js控制a標簽的動作,你加了 target="_blank",會跳出bout:blank#blocked 一個頁面。。

SukkaW added a commit to SukkaW/hexo that referenced this issue Oct 27, 2019
SukkaW added a commit that referenced this issue Oct 28, 2019
* fix: external link ignore mailto: & javascript:
Close #3796

* refactor: use startsWith instead of regex

* refactor(external_link): use whatwg url

* fix(external_link): handle whatwg url api
Apply code suggestions from code review by @curbengh
@ElfriedeMagdaleneHolger

@ jerryc127
如果您只想申请external_link发布,

external_link:
   启用:true 
  字段:发布

上面的配置还原4.0之前的行为。

另外,您也可以排除某些域:

external_link:
   enable:true 
  排除:
    - a.douban.com 
    - b.douban.com

不知道现在能不能回复……使用您提供的设置config里的external_link的方法没能解决问题,而且不能更新了……

@curbengh
Copy link
Contributor

The fixes #3847 hexojs/hexo-util#119 haven't release yet, please wait for hexo 4.1.0 + hexo-util 1.6.0.

thom4parisot pushed a commit to thom4parisot/hexo that referenced this issue Jan 17, 2020
* fix: external link ignore mailto: & javascript:
Close hexojs#3796

* refactor: use startsWith instead of regex

* refactor(external_link): use whatwg url

* fix(external_link): handle whatwg url api
Apply code suggestions from code review by @curbengh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants