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

Initialize Comments 时提示 Error: Validation Failed #66

Open
aiokr opened this issue Aug 19, 2017 · 12 comments
Open

Initialize Comments 时提示 Error: Validation Failed #66

aiokr opened this issue Aug 19, 2017 · 12 comments

Comments

@aiokr
Copy link

aiokr commented Aug 19, 2017

No description provided.

@Yiaichen
Copy link

看我的文章有解决方案

@Ethan-yt
Copy link

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

@Jarvis73
Copy link

Jarvis73 commented Jan 31, 2018

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:

  • gitment
  • <your post url>

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
Copy link

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

@jackRoadOnTop
Copy link

image

@iHTCboy
Copy link

iHTCboy commented Feb 25, 2018

出现 Error:validation failed

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

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

@YummyLau
Copy link

YummyLau commented Mar 2, 2018

在 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
Copy link

litt1e-p commented Mar 7, 2018

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
Copy link

gbxu commented Mar 16, 2018

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

@muyuefei
Copy link

muyuefei commented Apr 4, 2018

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

@imLogM
Copy link

imLogM commented May 16, 2018

主题为: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
Copy link

kdyzm commented Oct 16, 2018

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

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

No branches or pull requests