/Blog更新汇总

Created Thu, 07 Jul 2022 07:48:44 +0800 Modified Thu, 07 Jul 2022 08:01:12 +0800
274 Words

添加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"