imsun / gitment

A comment system based on GitHub Issues.
https://imsun.github.io/gitment/
MIT License
4.06k stars 347 forks source link

Initialize Comments 时提示 Error: Validation Failed #66

Open aiokr opened 7 years ago

Yiaichen commented 7 years ago

看我的文章有解决方案

Ethan-yt commented 7 years ago

检查url是否存在问题,删除所有标题中的标点符号

Jarvis73 commented 6 years ago

When you click the button Initialize Comments, the script will open a new issue in your repository and automatically add two labels to the issue:

But each label has a restriction of 50 chars, so the validation Failed message comes from the length of the url.

So I solved the ploblem by copying the core js file to my project and modifying the variable labels.

jackRoadOnTop commented 6 years ago

我也遇到同样问题,发现英文文章题目初始化文本页没有问题,如果文章是中文标题,初始化就会报错。不知道具体原因?

jackRoadOnTop commented 6 years ago

image

iHTCboy commented 6 years ago

出现 Error:validation failed

我想到一个更好的方法,用文章的时间,这样长度是保证在50个字符内,完美解决! id: '<%= page.date %>'

具体原因可以查看我博客:http://ihtc.cc/2018/02/25/2018-02-25%20_Gitment评论功能接入踩坑教程/

YummyLau commented 6 years ago

在 themes\next\layout_third-party\comments 目录下修改gitments.swig,找到以下代码修改

      function renderGitment(){
        var gitment = new {{CommentsClass}}({
-           id: window.location.pathname,
+           id: '{{ page.date }}',
            owner: '{{ theme.gitment.github_user }}',
            repo: '{{ theme.gitment.github_repo }}',
            {% if theme.gitment.mint %}
            lang: "{{ theme.gitment.language }}" || navigator.language || navigator.systemLanguage || navigator.userLanguage,
            {% endif %}

之后重新hexo g -d就ok了,请保证没有浏览器缓存。

litt1e-p commented 6 years ago

for hexo-theme-jane:

var gitment = new Gitment({
      id: '<%= post.date %>',
      owner: 'github id',
      repo: 'github  issue repo',
      oauth: {
        client_id: 'XXX',
        client_secret: 'XXXX',
      },
    })
gbxu commented 6 years ago

@mll120110 中文目录的问题 Hexo+Next+gitment的Error:validation failed 我的方法: https://www.jianshu.com/p/d873394f12ce

muyuefei commented 6 years ago

在外层的_config.yml 里把permalink: :year/:month/:day/:title/ 改成:year/:month/:day/:id/ 可以解决这个问题,原因是把标题编码后Label超过50.

imLogM commented 6 years ago

主题为:hexo-theme-next 使用 @gbxu 提到的方法:https://www.jianshu.com/p/d873394f12ce

修改 themes/next/layout/_comments/gitment.swig 中 id: window.location.pathname 改为: id: decodeURI(window.location.pathname)

原理是不加decodeURI时,生成的中文id会被转码为UTF-8格式,中文以%E1%A2这样的形式呈现,很容易超过github issue的长度限制,修改后,生成的id中文字符不转码。

kdyzm commented 5 years ago

文件名不能有标点符号,我加了一个.就不行了,和中英文标题没关系