gitment
gitment copied to clipboard
每次更新文章后都会重新创建一个issue
如标题所示,每次更改文章或者某些情况下会重建issue,并且需要重新初始化评论,导致github项目内issue非常多且不统一
以后提issue的话尽量把配置文件放上来咯 😄
我找到你的配置,大致问题就是你的id设为了id: document.location.href
,所以只要地址不同,就会新建一个。而我的配置是id:window.location.pathname
,这样就保证以path为id,不管你的hash,不管你的域名,不管你的请求参数。这种配置我暂时还没遇到什么问题,只要路径名不变(在hexo中好像是日期+标题或文件名)就行
@GeekaholicLin 非常感谢,我去试一下。没有提交这个文件主要是不太清楚这个问题出在哪里,下次我会注意的!谢谢!
@GeekaholicLin 我的配置文件是这样的:
{% if not (theme.duoshuo and theme.duoshuo.shortname) and not theme.duoshuo_shortname and not (theme.disqus.enable and theme.disqus.shortname) and not theme.hypercomments_id and not theme.gentie_productKey and not theme.changyan.enable %}
{% if page.comments and theme.gitment.enable and theme.gitment.username and theme.gitment.client_id and theme.gitment.client_secret %}
{% set username = theme.gitment.username %}
{% set client_id = theme.gitment.client_id %}
{% set client_secret = theme.gitment.client_secret %}
<link rel="stylesheet" href="https://imsun.github.io/gitment/style/default.css">
<script src="https://imsun.github.io/gitment/dist/gitment.browser.js"></script>
<script>
var gitment = new Gitment({
id: window.location.pathname,
owner: '{{username}}',
repo: '{{username}}.github.io',
oauth: {
client_id: '{{client_id}}',
client_secret: '{{client_secret}}'
}
});
gitment.render('gitment_container');
</script>
{% endif %}
{% endif %}
运行正常,但是仍然会有issues重复的情况。
问题重现:
当我进入一篇博客点击初始化组件按钮后,点击当前博客页的下一篇博客按钮,下一篇博客也初始化后,再点击浏览器的返回按钮返回到上一篇博客,发现初始化组件按钮又出现了,再次点击的话就会出现重复的issues。issues页链接:https://github.com/DavidSheh/davidsheh.github.io/issues
是我的id: window.location.pathname
这句代码写错了么?不会js,求教
@DavidSheh 还有这种操作?那你不点击返回按钮也会出现这种情况吗?
感觉这是个bug,已经找到规律了: 进入到某个未初始化的博文页(比如说A页),点击初始化,然后在当前页(A页)进入上一页或者下一页未初始化的页面(假如叫B页),然后点击初始化,接着点击浏览器返回按钮,返回到第一次进的那个页面(A页面),这时候发现初始化按钮重新显示出来了(A页面已经初始化完了,不应该显示的),如果这时候点击了初始化按钮就会出现重复的issues。不是这种操作暂时没发现重复的情况,其他的也都是正常的,暂时没发现其他问题。 @GeekaholicLin 你可以按照我说的步骤测试一下。一开始也遇到重复issues的情况,后来按照你的方法解决问题了,后来又偶然发现这个bug。 我刚刚提了一个issues #63
个人认为, 该评论系统可以利用hexo博客的permalink
参数来作为唯一标识标示同一篇博客, 而忽略其他参数, 这样做的好处有:
- 在
localhost
调试的时候可以共享在线的评论 - 可以在
localhost
调试的时候即可进行评论的初始化
这个问题比较复杂,因为使用location.href是Gitment的默认和推荐方式,因此在Gitment中其实不方便直接修改这个约定。
我的建议是处理anchor,放过query。参考:https://github.com/aimingoo/gitmint/blob/master/src/gitment.js#L67
在Gitmint中的处理方式是通过重写'id'的getter/setter的方式,来处理掉了“不同锚点(anchor)” #62 的问题。这是合理的,因为#
的锚点都是在页内,这意味着有没有锚点都是“同一个页”。然而不应该将这个规则应用到“查询(Query)”,因为没有办法确定不同的查询是否是同一个页面。例如.../index.do?postId=123
,其实就不能直接将query除去了事。
https://advance-esthetic.us/rf-facial-machines