MoePlayer / hexo-tag-dplayer

Embed dplayer in Hexo posts/pages
MIT License
207 stars 30 forks source link

fix: no return after if #18

Closed xiazeyu closed 6 years ago

xiazeyu commented 6 years ago

Related issues:

https://github.com/EYHN/hexo-helper-live2d/issues/91

https://github.com/MoePlayer/hexo-tag-dplayer/blob/master/index.js#L65 hexo.extend.filter.register(str.includes('</html>') && str.includes('class="dplayer hexo-tag-dplayer-mark"')) === false 的情况下会丢失返回值。

根据https://hexo.io/zh-cn/api/filter.html中的说明:

data 会作为第一个参数传入每个过滤器,而您可以在过滤器中通过返回值改变下一个过滤器中的 data,如果什么都没有返回的话则会保持原本的 data。 https://github.com/hexojs/hexo/blob/master/lib/extend/filter.js#L63

丢失返回值将会导致接下来的所有过滤器所做的改动无法应用到生成的文件中。

dixyes commented 6 years ago

我就觉得这个脏方法迟早得出问题 但没想到还能这么出问题(捂脸.jpg

说起来现在还是没有合适的加script标签的方法么

xiazeyu commented 6 years ago

@dixyes emmmm @EYHN 好像也在找方法... 我已经丢了一个issue去问了 https://github.com/hexojs/hexo/issues/3086

grzhan commented 6 years ago

有人实现过一个方案叫 hexo-inject ,原理上基本和 hexo-tag-dplayer 一致

xiazeyu commented 6 years ago

@grzhan 我看了一下,它看起来多了一个inject_ready的状态。 觉得用它会稳很多

xiazeyu commented 6 years ago

@dixyes 能否在npm上发布最新的hexo-tag-dplayer@0.3.2?

dixyes commented 6 years ago

这要等沉迷吃鸡的某小伙伴想起来怎么操作npm。。。

Myer921 commented 6 years ago

不好意思,这几天沉迷游戏和失踪 出现了一些关于国际网络的意外,已推送