{{- $cdn := .Scratch.Get "cdn" | default dict -}} {{- $fingerprint := .Scratch.Get "fingerprint" -}} {{- $comment := .Scratch.Get "comment" | default dict -}} {{- $commentConfig := dict -}} {{- if $comment.enable -}}
{{- /* Disqus Comment System */ -}} {{- if $comment.disqus.enable -}}
{{- $source := printf "https://%s.disqus.com/embed.js" $comment.disqus.shortname -}} {{- dict "source" $source "defer" true | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- end -}} {{- /* Gitalk Comment System */ -}} {{- if $comment.gitalk.enable -}}
{{- with $cdn.gitalkCSS -}} {{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/stylesheet.html" -}} {{- else -}} {{- dict "source" "lib/gitalk/gitalk.css" "minify" true "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/stylesheet.html" -}} {{- end -}} {{- with $cdn.gitalkJS -}} {{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- else -}} {{- dict "source" "lib/gitalk/gitalk.min.js" "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- end -}} {{- $commentConfig = dict "id" .Date "title" .Title "clientID" $comment.gitalk.clientId "clientSecret" $comment.gitalk.clientSecret "repo" $comment.gitalk.repo "owner" $comment.gitalk.owner "admin" (slice $comment.gitalk.owner) | dict "gitalk" | merge $commentConfig -}} {{- end -}} {{- /* Valine Comment System */ -}} {{- if $comment.valine.enable -}}
{{- $options := dict "targetPath" "lib/valine/valine.min.css" -}} {{- dict "source" "lib/valine/valine.scss" "toCSS" $options | dict "scratch" $.Scratch "data" | partial "scratch/stylesheet.html" -}} {{- with $cdn.valineJS -}} {{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- else -}} {{- dict "source" "lib/valine/Valine.min.js" "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- end -}} {{- $commentConfig = dict "el" "#valine" "appId" $comment.valine.appId "appKey" $comment.valine.appKey "lang" ($comment.valine.lang | default (T "valineLang")) "notify" $comment.valine.notify "verify" $comment.valine.verify "visitor" $comment.valine.visitor "recordIP" $comment.valine.recordIP "placeholder" ($comment.valine.placeholder | default (T "valinePlaceholder")) | dict "valine" | merge $commentConfig -}} {{- with $comment.valine.avatar -}} {{- $commentConfig = dict "avatar" . | dict "valine" | merge $commentConfig -}} {{- end -}} {{- with $comment.valine.meta -}} {{- $commentConfig = dict "meta" . | dict "valine" | merge $commentConfig -}} {{- end -}} {{- with $comment.valine.pageSize -}} {{- $commentConfig = dict "pageSize" . | dict "valine" | merge $commentConfig -}} {{- end -}} {{- end -}} {{- /* Facebook Comment System */ -}} {{- if $comment.facebook.enable -}}
{{- $source := printf "https://connect.facebook.net/%s/sdk.js#xfbml=1&version=v5.0&appId=%s&autoLogAppEvents=1" ($comment.facebook.languageCode | default (T "facebookLanguageCode")) $comment.facebook.appId -}} {{- dict "source" $source "defer" true | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- end -}} {{- /* Telegram Comments System */ -}} {{- if $comment.telegram.enable -}}
{{- $attr := printf `data-comments-app-website="%s"` $comment.telegram.siteID -}} {{- $attr = printf `%s data-limit="%s"` $attr ($comment.telegram.limit | default 5) -}} {{- with $comment.telegram.height -}} {{- $attr = printf `%s data-height="%s"` $attr . -}} {{- end -}} {{- with $comment.telegram.color -}} {{- $attr = printf `%s data-color="%s"` $attr . -}} {{- end -}} {{- if $comment.telegram.colorful -}} {{- $attr = printf `%s data-colorful="1"` $attr -}} {{- end -}} {{- if $comment.telegram.dislikes -}} {{- $attr = printf `%s data-dislikes="1"` $attr -}} {{- end -}} {{- if $comment.telegram.outlined -}} {{- $attr = printf `%s data-outlined="1"` $attr -}} {{- end -}} {{- dict "source" "https://comments.app/js/widget.js?2" "defer" true "attr" $attr | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- end -}}
{{- end -}} {{- dict "comment" $commentConfig | dict "config" | merge (.Scratch.Get "this") | .Scratch.Set "this" -}}