hexo博客配置笔记

回主页

这几个教程可以做参考:https://codezjx.github.io/2017/07/31/hexo-guide/ https://github.com/limedroid/HexoLearning

针对评论系统参考了这篇文章,https://blog.csdn.net/yanzi1225627/article/details/77890414 但是感觉这篇文章不是太靠谱,就把按照这篇文章做的修改又还原了。

今天又把评论系统给配置上了,现在把踩的坑记录下来: 1,themes\next_config.yml文件中的gitment配置,每一项冒号后面要有空格,value后边如果加#注释的话,value和#之间也要有空格

gitment:
  enable: true
  mint: true 		# RECOMMEND, A mint on Gitment, to support count, language and proxy_gateway
  count: true 		# Show comments count in post meta area
  lazy: false 		# Comments lazy loading with a button
  cleanly: false 	# Hide 'Powered by ...' on footer, and more
  language: 		# Force language, or auto switch by theme
  github_user: sunhang 	# 此处 - Your Github ID
  github_repo: gitment-comments # 此处注意 - The repo you use to store Gitment comments
  client_id: xxxxxxxxxxxxxxxxxx # 此处 - Github client id for the Gitment
  client_secret: xxxxxxxxxxxxx # 此处 - Github access secret token for the Gitment
  proxy_gateway: # Address of api proxy, See: https://github.com/aimingoo/intersect
  redirect_protocol: # Protocol of redirect_uri with force_redirect_protocol when mint enabled

2,打开博客初始化评论时,会提示“Error: Validation Failed”。原因是文章的title有过长的中文,需要修改一下\next\layout_third-party\comments中的gitments.swig文件

 function renderGitment(){
        var gitment = new {{CommentsClass}}({
-           id: window.location.pathname,
+           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,
            {% endif %}

或者是修改成id: decodeURI(window.location.pathname)

然后hexo g -d就ok了

回主页