12

整个博客增加 Valine 评论,欢迎留言

 3 years ago
source link: https://z.arlmy.me/posts/hexo/Hexo_Valine/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

整个博客增加 Valine 评论,欢迎留言

本篇应该是本博客最水的一篇。

此处省略前因后果一千字。

逛别人博客发现了这个 Valine 系统,很贴近自己的风格,稍折腾一下就成功了。不过还没弄邮件通知,所以有了留言我也不知道。

本以为不会有什么评论的,结果两天后就发现了两条。还有一位是老读者。果然留言簿的 Gitalk 太不友好了吧?果断取缔,都换成了 Valine。

说到底,我还是很希望有互动和留言的!毕竟,交流才是写作的最大欲求。

themes\maupassant\_config.yml 文件中增加代码(注意缩进)

valine: ## https://valine.js.org
enable: true ## If you want to use Valine comment system, please set the value to true.
appid: ## Your LeanCloud application App ID, e.g. pRBBL2JR4N7kLEGojrF0MsSs-gzGzoHsz
appkey: ## Your LeanCloud application App Key, e.g. tjczHpDfhjYDSYddzymYK1JJ
notify: false ## Mail notifier, see https://github.com/xCss/Valine/wiki/Valine-评论系统中的邮件提醒设置
verify: false ## Validation code.
placeholder: 请不吝赐教 ## Comment box placeholders.
avatar: "mm" ## Gravatar type, see https://github.com/xCss/Valine/wiki/avatar-setting-for-valine
pageSize: 7 ## Number of comments per page.
guest_info: nick,mail,link ## Attributes of reviewers.

themes\maupassant\layout\_partial\comments.jade 文件中增加代码(注意缩进)

if theme.valine.enable == true
#vcomment
script(src='//cdn1.lncld.net/static/js/3.0.4/av-min.js')
script(src='//unpkg.com/valine@latest/dist/Valine.min.js')
script.
var notify = '#{ theme.valine.notify }' ? true : false;
var verify = '#{ theme.valine.verify }' ? true : false;
var GUEST_INFO = ['nick','mail','link'];
var guest_info = '#{ theme.valine.guest_info }'.split(',').filter(function(item){
return GUEST_INFO.indexOf(item) > -1
});
guest_info = guest_info.length == 0 ? GUEST_INFO :guest_info;
window.valine = new Valine({
el:'#vcomment',
notify:notify,
verify:verify,
appId:'#{theme.valine.appid}',
appKey:'#{theme.valine.appkey}',
placeholder:'#{theme.valine.placeholder}',
avatar:'#{theme.valine.avatar}',
guest_info:guest_info,
pageSize:'#{theme.valine.pageSize}'
})

部署:hexo g -d

2021 迁移至 Leancloud 海外服务器

LeanCloud 国际版,例行重新注册、开通服务即可,完全 copy 原有配置即可。记得要在 themes\maupassant\_config.yml 内更新新生成的 appid 和 appkey 。

数据迁移:国内版 Leancloud,“数据存储”-“导入导出”-“数据导出”,选择限定 Class,导出 _UserComment 两项即可,如果数据不多,很快就能收到 Email,下载解压压缩包即可。

此处,需要进行文本处理后再上传,参照 Leancloud 官方文档,需要调整 JSON 文件格式,转换要求为:

            {"results": [
{A} -> {A},
{B} {B}
]}

如果数据条目较多,可使用 Sublime Text 的编辑功能:"ctrl+A"-"ctrl+shift+L",再通过光标移动到每一条数据末尾,增加英文逗号。全选,增加缩进。注意要将最后一个逗号删除,再在前后增加两行信息 {"results": []}

调整后上传至国际版 Leancloud 后台即可。

最后,部署:hexo g -d

LeanCloud 流控问题解决方案

参照:Gtihub Action|一行命令解决 LeanCloud 流控问题,亲测管用


CHANGELOG


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK