docs: add giscus comments system (#96)

* chore: rename comment to comments

* docs: add giscus comments

* docs: update
This commit is contained in:
Xin
2023-09-26 23:33:27 +01:00
committed by GitHub
parent adf5a113fc
commit 46dea718e6
11 changed files with 68 additions and 23 deletions

View File

@ -10,7 +10,7 @@
</div>
<div class="mt-16"></div>
{{ partial "components/last-updated.html" . }}
{{ partial "components/comment.html" . }}
{{ partial "components/comments.html" . }}
</main>
</article>
</div>

View File

@ -10,7 +10,8 @@
<div class="content">
{{ .Content }}
</div>
{{ partial "components/comment.html" . }}
<div class="mt-16"></div>
{{ partial "components/comments.html" . }}
</main>
</article>
</div>

View File

@ -28,7 +28,7 @@
{{ partial "components/last-updated.html" . }}
{{ .Scratch.Set "reversePagination" true }}
{{ partial "components/pager.html" . }}
{{ partial "components/comment.html" . }}
{{ partial "components/comments.html" . }}
</main>
</article>
</div>

View File

@ -9,10 +9,9 @@
<h1>{{ .Title }}</h1>
{{ .Content }}
</div>
<div class="mt-16"></div>
{{ partial "components/last-updated.html" . }}
{{ partial "components/pager.html" . }}
{{ partial "components/comment.html" . }}
{{ partial "components/comments.html" . }}
</main>
</article>
</div>

View File

@ -11,7 +11,7 @@
</div>
{{ partial "components/last-updated.html" . }}
{{ partial "components/pager.html" . }}
{{ partial "components/comment.html" . }}
{{ partial "components/comments.html" . }}
</main>
</article>
</div>

View File

@ -1,8 +0,0 @@
{{- $commentEnable := site.Params.comment.enable | default false -}}
{{- $commentPageEnable := .Params.comment | default true -}}
{{- if and $commentEnable $commentPageEnable -}}
{{- if eq site.Params.comment.type "giscus" -}}
{{ partial "components/giscus.html" . }}
{{- end -}}
{{- end -}}

View File

@ -0,0 +1,11 @@
{{- $enableComments := site.Params.comments.enable | default false -}}
{{ if not (eq .Params.comments nil) }}
{{ $enableComments = .Params.comments }}
{{ end }}
{{- if $enableComments -}}
{{- if eq site.Params.comments.type "giscus" -}}
{{ partial "components/giscus.html" . }}
{{- end -}}
{{- end -}}

View File

@ -1,6 +1,6 @@
{{- $lang := site.Language.LanguageCode | default `en` -}}
{{- with site.Params.comment.giscus -}}
{{- with site.Params.comments.giscus -}}
<script>
/*
* "preferred color scheme" theme in giscus works using "prefers-color-scheme" in media query.
@ -57,4 +57,6 @@
</script>
<div id="giscus"></div>
{{- else -}}
{{ warnf "giscus is not configured" }}
{{- end -}}