迁移Disqus
查看博客的时候发现多说将要关闭的消息,在几番选择下,就谋划将评论系统迁移到Disqus.
然而喜出望外的是从jekyll迁移到Hexo之后还没有收到评论(无奈),所以此番迁移也不会费多少工夫.
step 1
修改next主题的配置文件_config.yml
中关于disqus_shortname
的设置,同时将duoshuo_shortname
字段注释掉.
# Disqus
disqus_shortname: your_disqus_shortname
step 2
打开next/layout/_partials/comments.swig
文件
找到这个判断条件
{% elseif theme.disqus_shortname %}
,在这个行下面将之前的占位的代码替换成我们所需要的,根据 Disqus 的指南,替换后的代码应该是这个样子的
{% elseif theme.disqus_shortname %}
<div id="disqus_thread"></div>
<script>
// RECOMMENDED CONFIGURATION VARIABLES: EDIT AND UNCOMMENT THE SECTION BELOW TO INSERT DYNAMIC VALUES FROM YOUR PLATFORM OR CMS.
// LEARN WHY DEFINING THESE VARIABLES IS IMPORTANT: https://disqus.com/admin/universalcode/#configuration-variables*/
var disqus_config = function () {
this.page.url = "{{ page.permalink }}"; // Replace PAGE_URL with your page's canonical URL variable
this.page.identifier = "{{ page.path }}"; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
};
(function() { // DON'T EDIT BELOW THIS LINE
var d = document, s = d.createElement('script');
s.src = 'https://yourshortname.disqus.com/embed.js';
s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
step 3
保存更改的代码 在终端分别执行 hexo c
, hexo g
, hexo s
. 进入一篇博客就可以看到熟悉的Disqus评论栏了.
Next主题的一些配置优化
在侧栏中显示其他社交平台的链接.
以github为例:
```
social:
Github: https://github.com/yourgithub
social_icons:
enable: true
GitHub: github
```
侧栏头像设置:
```
avatar: your_acatar_picture_url
```
首页文章不显示全文
```
auto_excerpt:
enable: true
length: 150
```
代码高亮:
```
highlight_theme: night //选一个自己喜欢的.
```
注意,代码高亮这样设置完了只是设置了代码高亮的主题, 想要在网页上显示高亮的效果,还需要自己在使用 ``` 生成代码区域时添加代码所属语言的标记,
以OC为例: