<p>解决:gitalk 报错 Error: Validation Failed.--MD5 加密 id 避免 github issue lables 50 字符限制
创建一个<code>github gist</code> 文件保存</p>
<pre><code>https://github.com/blueimp/JavaScript-MD5/blob/master/js/md5.min.js</code></pre>
<p>js 源码:</p>
<pre><code>https://gist.githubusercontent.com/qhh0205/78e9e0b1f3114db6737f3ed8cdd51d3a/raw/3894c5be5aa2378336b1f5ee0f296fa0b22d06e9/md5.min.js</code></pre>
<p>将 gist 链接嵌入到 <code>layout/_third-party/comments/gitalk.swig </code>文件,嵌入时的 js 链接地址需要注意下:</p>
<p>不能直接写第一步的创建的 gitst 链接地址,需要将 <code>gist.githubusercontent.com</code> 替换为 <code>rawgit.com</code>。即嵌入地址为:</p>
<pre><code>https://rawgit.com/qhh0205/78e9e0b1f3114db6737f3ed8cdd51d3a/raw/3894c5be5aa2378336b1f5ee0f296fa0b22d06e9/md5.min.js</code></pre>
<p>最终 <code>layout/_third-party/comments/gitalk.swig</code> 配置如下:</p>
<pre><code class="language-JS">{% if page.comments && theme.gitalk.enable %}
<link rel="stylesheet" href="https://unpkg.com/gitalk/dist/gitalk.css">
<script src="https://unpkg.com/gitalk/dist/gitalk.min.js"></script>
<script src="https://rawgit.com/qhh0205/78e9e0b1f3114db6737f3ed8cdd51d3a/raw/3894c5be5aa2378336b1f5ee0f296fa0b22d06e9/md5.min.js"></script>
<script type="text/javascript">
var gitalk = new Gitalk({
clientID: '3840ba8c8d80c18be7e3',
clientSecret: '1b00f2efe5285973c24da9ed9ac895775eacc8ea',
repo: '{{ theme.gitalk.repo }}',
owner: '{{ theme.gitalk.githubID }}',
admin: ['{{ theme.gitalk.adminUser }}'],
id: md5(location.pathname),
distractionFreeMode: '{{ theme.gitalk.distractionFreeMode }}'
})
gitalk.render('gitalk-container')
</script>
{% endif %}</code></pre>
0 条评论