Merge pull request #450 from rlemaitre/main

Integrate utteranc.es comment system
This commit is contained in:
Djordje Atlialp 2023-11-22 23:18:47 +01:00 committed by GitHub
commit 2adc4af46e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 76 additions and 0 deletions

View file

@ -156,6 +156,42 @@ disableHugoGeneratorInject = false
# [params.commento] # [params.commento]
# url = "" # url = ""
# Utteranc.es is a lightweight comments widget built on GitHub issues.
# See https://utteranc.es/ for documentation
# Uncomment this to enable Utteranc.es.
#
# [params.utterances]
# Your GitHub repository
#
# repository = ""
# label used for GitHub issues
#
# label = ""
# Blog Post <-> Issue mapping. This parameter is optional. Possible values are:
# - pathname
# - url
# - title
# - og:title
# - issue number
# - specific term
#
# issueTerm = ""
# Theme used: possible values are:
# - github-light
# - github-dark
# - preferred-color-scheme
# - github-dark-orange
# - icy-dark
# - dark-blue
# - photon-dark
# - boxy-light
# - gruvbox-dark
#
# theme = ""
# Uncomment this if you want a portrait on your start page # Uncomment this if you want a portrait on your start page
# #
# [params.portrait] # [params.portrait]

View file

@ -0,0 +1,4 @@
<pre class="mermaid">
{{- .Inner | safeHTML }}
</pre>
{{ .Page.Store.Set "hasMermaid" true }}

View file

@ -9,3 +9,28 @@
<script src="{{ $val }}"></script> <script src="{{ $val }}"></script>
{{ end }} {{ end }}
{{ end }} {{ end }}
{{ if .Page.Store.Get "hasMermaid" }}
<script type="module">
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.esm.min.mjs';
const settings = localStorage.getItem('theme') === 'dark' ?
{
startOnLoad: true,
theme: 'dark',
darkMode: true,
themeVariables: {
tertiaryColor: '#dee3ed'
}
}
:
{
startOnLoad: true,
theme: 'base',
darkMode: false,
themeVariables: {
tertiaryColor: '#dee3ed'
}
}
;
mermaid.initialize(settings);
</script>
{{ end }}

View file

@ -135,5 +135,16 @@
<div id="commento"></div> <div id="commento"></div>
{{ end }} {{ end }}
{{ if .Site.Params.Utterances.Repository }}
<script src="https://utteranc.es/client.js"
repo="{{ .Site.Params.Utterances.Repository }}"
{{ if .Site.Params.Utterances.Label }}label="{{ .Site.Params.Utterances.Label }}"{{ end }}
issue-term="{{ .Site.Params.Utterances.IssueTerm }}"
theme="{{ .Site.Params.Utterances.Theme }}"
crossorigin="anonymous"
async>
</script>
{{ end }}
</main> </main>
{{ end }} {{ end }}