添加utteranc评论
首先github授权utteranc。
针对github-style
主题,在themes/github-style/layouts/partials/
下,创建utteranc.html
文件。
{{ if .Site.Params.Utteranc.enable }}
<script src="https://utteranc.es/client.js"
repo="{{ .Site.Params.Utteranc.owner }}/{{ .Site.Params.Utteranc.repo }}",
issue-term="title"
label="💬"
theme="{{ .Site.Params.Utteranc.theme }}",
crossorigin="anonymous"
async>
</script>
<noscript>Please enable JavaScript to view the <a href="https://github.com/utterance">comments powered by utterances.</a></noscript>
{{ end }}
然后,修改themes/github-style/layouts/_default/single.html
文件
{{ define "content" }}
{{ partial "toc.html" .}}
{{ partial "post.html" .}}
{{ partial "gitalk.html" . }}
{{ partial "utteranc.html" . }} // 添加
{{end }}
最后,在config.toml
中增加配置
[params]
[params.utteranc]
enable = true
owner = "your_github_name"
repo = "blog"
issueTerm = "pathname"
theme = "icy-dark"