想起夕阳下的奔跑,那是我逝去的青春

0%

hexo+next+valine评论报错410处理方法

搭建博客的时候,遇到过一个问题,就是使用 主题next+valine 评论系统报错:

1
Code : undefined [410 GET https://avoscloud.com/1.1/classes/Comment]

这个错误是真的难受,各种修改配置然后找原因,最后,找到了我这里的解决办法,可能只对部分人有用吧。

下载Valine.min.js文件

传送门,下载完了之后解压,然后取出其中的Valine.min.js文件,放在next主题的这个路径下
xxxxxx.github.io/themes/next/source/js/src(注意:如果没有src文件夹,自己创建即可)。
放好该文件夹之后,我们去修改主题下的另外一个文件,路径如下xxxxxx.github.io/themes/next/layout/_third-party/comments/valine.swig,打开该文件,博主该文件原始代码如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
{%- set valine_uri = theme.vendors.valine or '//unpkg.com/valine/dist/Valine.min.js' %}

<script>
NexT.utils.getScript('{{ valine_uri }}', () => {
var GUEST = ['nick', 'mail', 'link'];
var guest = '{{ theme.valine.guest_info }}';
guest = guest.split(',').filter(item => {
return GUEST.includes(item);
});
new Valine({
el: '#comments',
verify: {{ theme.valine.verify }},
notify: {{ theme.valine.notify }},
appId: '{{ theme.valine.appid }}',
appKey: '{{ theme.valine.appkey }}',
placeholder: {{ theme.valine.placeholder | json }},
avatar: '{{ theme.valine.avatar }}',
meta: guest,
pageSize: '{{ theme.valine.pageSize }}' || 10,
visitor: {{ theme.valine.visitor }},
lang: '{{ theme.valine.language }}' || 'zh-cn',
path: location.pathname,
recordIP: {{ theme.valine.recordIP }},
serverURLs: '{{ theme.valine.serverURLs }}'
});
}, window.Valine);
</script>

注意看valine_url指向的地址,改成我们刚才下载下来的文件地址,于是修改成

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
{%- set valine_uri = '/js/src/Valine.min.js' %}

<script>
NexT.utils.getScript('{{ valine_uri }}', () => {
var GUEST = ['nick', 'mail', 'link'];
var guest = '{{ theme.valine.guest_info }}';
guest = guest.split(',').filter(item => {
return GUEST.includes(item);
});
new Valine({
el: '#comments',
verify: {{ theme.valine.verify }},
notify: {{ theme.valine.notify }},
appId: '{{ theme.valine.appid }}',
appKey: '{{ theme.valine.appkey }}',
placeholder: {{ theme.valine.placeholder | json }},
avatar: '{{ theme.valine.avatar }}',
meta: guest,
pageSize: '{{ theme.valine.pageSize }}' || 10,
visitor: {{ theme.valine.visitor }},
lang: '{{ theme.valine.language }}' || 'zh-cn',
path: location.pathname,
recordIP: {{ theme.valine.recordIP }},
serverURLs: '{{ theme.valine.serverURLs }}'
});
}, window.Valine);
</script>

然后就OK了,可能只针对部分人有用吧同时也给自己做一个记号