feat: add gitment module (#36)

This commit is contained in:
sslyxhz 2018-03-11 14:47:13 +08:00 committed by olOwOlo
parent 52777345e4
commit 1da110d6b1
4 changed files with 41 additions and 2 deletions

View file

@ -92,6 +92,14 @@ copyright = "" # default: author.name ↓ # 默认为下面配
slideout = '<script src="https://cdn.jsdelivr.net/npm/slideout@1.0.1/dist/slideout.min.js" integrity="sha256-t+zJ/g8/KXIJMjSVQdnibt4dlaDxc9zXr/9oNPeWqdg=" crossorigin="anonymous"></script>'
fancyboxJs = '<script src="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.1.20/dist/jquery.fancybox.min.js" integrity="sha256-XVLffZaxoWfGUEbdzuLi7pwaUJv1cecsQJQqGLe7axY=" crossorigin="anonymous"></script>'
fancyboxCss = '<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.1.20/dist/jquery.fancybox.min.css" integrity="sha256-7TyXnr2YU040zfSP+rEcz29ggW4j56/ujTPwjMzyqFY=" crossorigin="anonymous">'
gitmentJS = '<script src="https://cdn.jsdelivr.net/npm/gitment@0.0.3/dist/gitment.browser.min.js" crossorigin="anonymous"></script>'
gitmentCSS = '<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/gitment@0.0.3/style/default.min.css" crossorigin="anonymous">'
[params.gitment] # Gitment is a comment system based on GitHub issues. see https://github.com/imsun/gitment
owner = "" # Your GitHub ID
repo = "" # The repo to store comments
clientId = "" # Your client ID
clientSecret = "" # Your client secret
[params.busuanzi] # count web traffic by busuanzi # 是否使用不蒜子统计站点访问量
enable = false

View file

@ -15,7 +15,7 @@
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
{{- end }}
{{- end -}}
<!-- changyan -->
{{- if and .Site.Params.changyanAppid .Site.Params.changyanAppkey -}}
@ -30,7 +30,7 @@
if (width < 960) {window.document.write('<script id="changyan_mobile_js" charset="utf-8" type="text/javascript" src="https://changyan.sohu.com/upload/mobile/wap-js/changyan_mobile.js?client_id=' + appid + '&conf=' + conf + '"><\/script>'); } else { var loadJs=function(d,a){var c=document.getElementsByTagName("head")[0]||document.head||document.documentElement;var b=document.createElement("script");b.setAttribute("type","text/javascript");b.setAttribute("charset","UTF-8");b.setAttribute("src",d);if(typeof a==="function"){if(window.attachEvent){b.onreadystatechange=function(){var e=b.readyState;if(e==="loaded"||e==="complete"){b.onreadystatechange=null;a()}}}else{b.onload=a}}c.appendChild(b)};loadJs("https://changyan.sohu.com/upload/changyan.js",function(){window.changyan.api.config({appid:appid,conf:conf})}); }
})();
</script>
{{- end }}
{{- end -}}
<!-- LiveRe -->
{{- if .Site.Params.livereUID -}}
@ -50,5 +50,34 @@
</script>
<noscript>Please enable JavaScript to view the comments powered by <a href="https://livere.com/">LiveRe.</a></noscript>
</div>
{{- end -}}
<!-- gitment -->
{{- if .Site.Params.gitment.owner -}}
<div id="comments-gitment"></div>
{{ if .Site.Params.publicCDN.enable -}}
{{ .Site.Params.publicCDN.gitmentCSS | safeHTML }}
{{ .Site.Params.publicCDN.gitmentJS | safeHTML }}
{{- else -}}
<link rel="stylesheet" href="{{ "lib/gitment/gitment-0.0.3.min.css" | relURL }}">
<script src="{{ "lib/gitment/gitment-0.0.3.min.js" | relURL }}"></script>
{{- end }}
<script type="text/javascript">
const gitment = new Gitment({
id: '{{ .Date }}',
title: '{{ .Title }}',
link: decodeURI(location.href),
desc: '{{ .Summary }}',
owner: '{{ .Site.Params.gitment.owner }}',
repo: '{{ .Site.Params.gitment.repo }}',
oauth: {
client_id: '{{ .Site.Params.gitment.clientId }}',
client_secret: '{{ .Site.Params.gitment.clientSecret }}'
}
})
gitment.render('comments-gitment')
</script>
<noscript>Please enable JavaScript to view the <a href="https://github.com/imsun/gitment">comments powered by gitment.</a></noscript>
{{- end }}
{{- end }}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long