imsun/gitment

Error: Validation Failed

DanielJyc opened this issue · 7 comments

初始化页面评论页报错Error: Validation Failed.
原因:如下图评论的标签,及第二个字段id/2018/02/04/shell%E8%84%9A%E6%9C%AC%E4%BD%BF%E7%94%A8%E5%92%8C%E6%80%BB%E7%BB%93/太长导致。请问下,这个怎么解决。在这里可以重现Link

image

我的也是,Console:
api.github.com/repos/vimcaw/blog/issues
Failed to load resource: the server responded with a status of 422 (Unprocessable Entity)

出现 Error:validation failed

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

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

使用 @iHTCboy 的方法,更好一些。👍

我用的next-reloaded主题。修改文件next-reloaded/layout/_third-party/comments/gitment.swig下:

    {% if page.comments %}
      <script type="text/javascript">
      function renderGitment(){
        var gitment = new {{CommentsClass}}({
            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,

中修改id: '{{ page.date }}',就可以了。

@iHTCboy good job

我觉得用题目更好点 id: '{{ page.title }}' 比如https://github.com/huiwang/gitment.hui-wang.info/issues

记录,我也遇到,但是我的问题不是label字符超过50个,而是标题中包含了英文半角的, 可以改成中文逗号,希望有帮到后来人。

Sogrey/Sogrey.github.io#28 (comment)