hexojs / hexo

A fast, simple & powerful blog framework, powered by Node.js.
https://hexo.io
MIT License
39.28k stars 4.83k forks source link

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

Closed jerryc127 closed 4 years ago

jerryc127 commented 4 years ago

Check List

Please check followings before submitting a new issue.

Expected behavior

Actual behavior

How to reproduce?

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 commented 4 years ago

In your _config.yml:

external_link:
  enable: false
SukkaW commented 4 years ago

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 commented 4 years ago

@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 commented 4 years ago

@SukkaW @curbengh 感謝回答

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

ElfriedeMagdaleneHolger commented 4 years ago

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

external_link:
   启用:true 
  字段:发布

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

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

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

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

curbengh commented 4 years ago

The fixes https://github.com/hexojs/hexo/pull/3847 https://github.com/hexojs/hexo-util/pull/119 haven't release yet, please wait for hexo 4.1.0 + hexo-util 1.6.0.