summaryrefslogtreecommitdiffstats
path: root/layouts/partials
diff options
context:
space:
mode:
authorSerghei Iakovlev <egrep@protonmail.ch>2024-04-14 17:57:42 +0200
committerSerghei Iakovlev <egrep@protonmail.ch>2024-04-14 21:56:09 +0200
commit669c97a7360e8268104466a52eade82a628ad719 (patch)
tree2362f4bb4612e9ca974a67d44ffa225d98a94c86 /layouts/partials
parent23d77288040ca113dbc797aa2eaff6ba2a32f324 (diff)
downloadgohugo-theme-ed-669c97a7360e8268104466a52eade82a628ad719.tar.gz
Provide an ability to use comments form
Diffstat (limited to 'layouts/partials')
-rw-r--r--layouts/partials/comments.html39
1 files changed, 39 insertions, 0 deletions
diff --git a/layouts/partials/comments.html b/layouts/partials/comments.html
new file mode 100644
index 0000000..7150fd0
--- /dev/null
+++ b/layouts/partials/comments.html
@@ -0,0 +1,39 @@
+{{- $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" -}}
+ {{- $isProduction := (or (eq (getenv "HUGO_ENV") "production") (eq site.Params.env "production")) -}}
+
+ {{- $repo := site.Params.comments.giscus.repo -}}
+ {{- $repoId := site.Params.comments.giscus.repoId -}}
+ {{- $category := site.Params.comments.giscus.category -}}
+ {{- $categoryId := site.Params.comments.giscus.categoryId -}}
+ {{- $theme := site.Params.comments.giscus.theme | default "light" -}}
+ {{- $emitMetadata := site.Params.comments.giscus.emitMetadata | default 0 -}}
+ {{- $inputPosition := site.Params.comments.giscus.inputPosition | default "bottom" -}}
+ {{- $lang := site.Params.comments.giscus.lang | default "en" -}}
+ {{- $mapping := site.Params.comments.giscus.mapping | default "pathname" -}}
+ {{- $reactionsEnabled := site.Params.comments.giscus.reactionsEnabled | default 1 -}}
+ {{- $strict := site.Params.comments.giscus.strict | default 0 -}}
+ {{- $commentsParams := dict "repo" $repo "repoId" $repoId "category" $category "categoryId" $categoryId "theme" $theme "emitMetadata" $emitMetadata "inputPosition" $inputPosition "lang" $lang "mapping" $mapping "reactionsEnabled" $reactionsEnabled "strict" $strict -}}
+
+ {{- $siteComments := slice -}}
+ {{- $siteComments = $siteComments | append (resources.Get "js/giscus.js") -}}
+ {{- $siteComments = $siteComments | resources.Concat "js/giscus-bundle.js" -}}
+
+ {{- $siteComments = $siteComments | js.Build (dict "format" "iife" "minify" $isProduction "target" "es2015" "params" $commentsParams) -}}
+
+ {{- if or (site.Params.assets.disable_fingerprinting) (not $isProduction) }}
+ <script src="{{ $siteComments.RelPermalink }}"></script>
+ {{- else -}}
+ {{- $siteComments = $siteComments | fingerprint }}
+ <script src="{{ $siteComments.RelPermalink }}" integrity="{{ $siteComments.Data.Integrity }}"></script>
+ {{- end -}}
+
+ <div id="giscus"></div>
+ {{- end -}}
+{{- end -}}