{{- $cdn := .Scratch.Get "cdn" | default dict -}} {{- $fingerprint := .Scratch.Get "fingerprint" -}} {{- $comment := .Scratch.Get "comment" | default dict -}} {{- $commentConfig := dict -}} {{- if $comment.enable -}}
{{- /* Disqus Comment System */ -}} {{- $disqus := $comment.disqus | default dict -}} {{- if $disqus.enable -}}
{{- $source := printf "https://%v.disqus.com/embed.js" $disqus.shortname -}} {{- dict "Source" $source "Defer" true | dict "Scratch" .Scratch "Data" | partial "scratch/commentScript.html" -}} {{- end -}} {{- /* Gitalk Comment System */ -}} {{- $gitalk := $comment.gitalk | default dict -}} {{- if $gitalk.enable -}}
{{- $source := $cdn.gitalkCSS | default "lib/gitalk/gitalk.css" -}} {{- dict "Source" $source "Minify" true "Fingerprint" $fingerprint | dict "Scratch" .Scratch "Data" | partial "scratch/style.html" -}} {{- $source := $cdn.gitalkJS | default "lib/gitalk/gitalk.min.js" -}} {{- dict "Source" $source "Fingerprint" $fingerprint | dict "Scratch" .Scratch "Data" | partial "scratch/commentScript.html" -}} {{- $commentConfig = dict "id" .Date "title" .Title "clientID" $gitalk.clientId "clientSecret" $gitalk.clientSecret "repo" $gitalk.repo "owner" $gitalk.owner "admin" (slice $gitalk.owner) | dict "gitalk" | merge $commentConfig -}} {{- with $gitalk.proxy -}} {{- $commentConfig = dict "proxy" . | dict "gitalk" | merge $commentConfig -}} {{- end -}} {{- $options := dict "targetPath" "js/gitalk.min.js" "minify" true -}} {{- $js := resources.Get "js/lib/gitalk.js" | js.Build $options -}} {{- $_ := $js.RelPermalink -}} {{- dict "Link" $js.RelPermalink "Fingerprint" $fingerprint "Defer" true | dict "Scratch" .Scratch "Data" | partial "scratch/commentScript.html" -}} {{- end -}} {{- /* Valine Comment System */ -}} {{- $valine := $comment.valine | default dict -}} {{- if $valine.enable -}}
{{- $options := dict "targetPath" "lib/valine/valine.min.css" -}} {{- dict "Source" "lib/valine/Valine.scss" "ToCSS" $options | dict "Scratch" .Scratch "Data" | partial "scratch/style.html" -}} {{- $commentConfig = dict "el" "#valine" "appId" $valine.appId "appKey" $valine.appKey "lang" ($valine.lang | default (T "valineLang")) "visitor" $valine.visitor "recordIP" $valine.recordIP "placeholder" ($valine.placeholder | default (T "valinePlaceholder")) "highlight" (ne $valine.highlight false) "enableQQ" $valine.enableQQ | dict "valine" | merge $commentConfig -}} {{- with $valine.avatar -}} {{- $commentConfig = dict "avatar" . | dict "valine" | merge $commentConfig -}} {{- end -}} {{- with $valine.meta -}} {{- $commentConfig = dict "meta" . | dict "valine" | merge $commentConfig -}} {{- end -}} {{- with $valine.pageSize -}} {{- $commentConfig = dict "pageSize" . | dict "valine" | merge $commentConfig -}} {{- end -}} {{- with $valine.serverURLs -}} {{- $commentConfig = dict "serverURLs" . | dict "valine" | merge $commentConfig -}} {{- end -}} {{- $commentConfig = $valine.emoji | default "google.yml" | printf "data/emoji/%v" | resources.Get | transform.Unmarshal | dict "valine" | merge $commentConfig -}} {{- $shims := dict "valine" "js/shims/valine.js" -}} {{- $options := dict -}} {{- $source := $cdn.valineJS | default "lib/valine/Valine.min.js" -}} {{- dict "Source" $source "Fingerprint" $fingerprint "Defer" true | dict "Scratch" .Scratch "Data" | partial "scratch/commentScript.html" -}} {{- $options = dict "shims" $shims | merge $options -}} {{- $options = dict "targetPath" "js/valine.min.js" | merge $options -}} {{- $options = dict "minify" true | merge $options -}} {{- $js := resources.Get "js/lib/valine.js" | js.Build $options -}} {{- $_ := $js.RelPermalink -}} {{- dict "Link" $js.RelPermalink "Fingerprint" $fingerprint "Defer" true | dict "Scratch" .Scratch "Data" | partial "scratch/commentScript.html" -}} {{- end -}} {{- /* Waline Comment System */ -}} {{- $waline := $comment.waline | default dict -}} {{- if $waline.enable -}}
{{- $source := $cdn.walineCSS | default "lib/waline/waline.css" -}} {{- dict "Source" $source "Minify" true "Fingerprint" $fingerprint | dict "Scratch" .Scratch "Data" | partial "scratch/style.html" -}} {{- $commentConfig = dict "el" "#waline" "serverURL" $waline.serverURL "lang" .Lang "dark" "body[theme='dark'], body[theme='black']" "copyright" true | dict "waline" | merge $commentConfig -}} {{- with $waline.pageview -}} {{- $commentConfig = dict "pageview" . | dict "waline" | merge $commentConfig -}} {{- end -}} {{- with $waline.comment -}} {{- $commentConfig = dict "comment" . | dict "waline" | merge $commentConfig -}} {{- end -}} {{- with $waline.emoji -}} {{- $commentConfig = dict "emoji" . | dict "waline" | merge $commentConfig -}} {{- end -}} {{- with $waline.meta -}} {{- $commentConfig = dict "meta" . | dict "waline" | merge $commentConfig -}} {{- end -}} {{- with $waline.requiredMeta -}} {{- $commentConfig = dict "requiredMeta" . | dict "waline" | merge $commentConfig -}} {{- end -}} {{- with $waline.login -}} {{- $commentConfig = dict "login" . | dict "waline" | merge $commentConfig -}} {{- end -}} {{- with $waline.wordLimit -}} {{- $commentConfig = dict "wordLimit" . | dict "waline" | merge $commentConfig -}} {{- end -}} {{- with $waline.pageSize -}} {{- $commentConfig = dict "pageSize" . | dict "waline" | merge $commentConfig -}} {{- end -}} {{- if eq $waline.imageUploader false -}} {{- $commentConfig = dict "imageUploader" false | dict "waline" | merge $commentConfig -}} {{- end -}} {{- if eq $waline.highlighter false -}} {{- $commentConfig = dict "highlighter" false | dict "waline" | merge $commentConfig -}} {{- end -}} {{- if eq $waline.texRenderer false -}} {{- $commentConfig = dict "texRenderer" false | dict "waline" | merge $commentConfig -}} {{- end -}} {{- $shims := dict "@waline/client" "js/shims/waline.js" -}} {{- $options := dict -}} {{- $source := $cdn.walineJS | default "lib/waline/waline.js" -}} {{- dict "Source" $source "Fingerprint" $fingerprint "Defer" true | dict "Scratch" .Scratch "Data" | partial "scratch/commentScript.html" -}} {{- $options = dict "shims" $shims | merge $options -}} {{- $options = dict "targetPath" "js/waline.min.js" | merge $options -}} {{- $options = dict "minify" true | merge $options -}} {{- $js := resources.Get "js/lib/waline.js" | js.Build $options -}} {{- $_ := $js.RelPermalink -}} {{- dict "Link" $js.RelPermalink "Fingerprint" $fingerprint "Defer" true | dict "Scratch" .Scratch "Data" | partial "scratch/commentScript.html" -}} {{- end -}} {{- /* Facebook Comment System */ -}} {{- $facebook := $comment.facebook | default dict -}} {{- if $facebook.enable -}}
{{- $source := printf "https://connect.facebook.net/%v/sdk.js#xfbml=1&version=v5.0&appId=%v&autoLogAppEvents=1" ($facebook.languageCode | default (T "facebookLanguageCode")) $facebook.appId -}} {{- dict "Source" $source "Defer" true | dict "Scratch" .Scratch "Data" | partial "scratch/commentScript.html" -}} {{- end -}} {{- /* Telegram Comments System */ -}} {{- $telegram := $comment.telegram | default dict -}} {{- if $telegram.enable -}}
{{- $attr := printf `data-comments-app-website="%v"` $telegram.siteID -}} {{- $attr = printf `%v data-limit="%v"` $attr ($telegram.limit | default 5) -}} {{- with $telegram.height -}} {{- $attr = printf `%v data-height="%v"` $attr . -}} {{- end -}} {{- with $telegram.color -}} {{- $attr = printf `%v data-color="%v"` $attr . -}} {{- end -}} {{- if $telegram.colorful -}} {{- $attr = printf `%v data-colorful="1"` $attr -}} {{- end -}} {{- if $telegram.dislikes -}} {{- $attr = printf `%v data-dislikes="1"` $attr -}} {{- end -}} {{- if $telegram.outlined -}} {{- $attr = printf `%v data-outlined="1"` $attr -}} {{- end -}} {{- if $telegram.dark -}} {{- $attr = printf `%v data-dark="1"` $attr -}} {{- end -}}
{{- end -}} {{- /* Commento Comment System */ -}} {{- $commento := $comment.commento | default dict -}} {{- if $commento.enable -}}
{{- dict "Source" "https://cdn.commento.io/js/commento.js" "Defer" true | dict "Scratch" .Scratch "Data" | partial "scratch/commentScript.html" -}} {{- end -}} {{- /* Utterances Comment System */ -}} {{- $utterances := $comment.utterances | default dict -}} {{- if $utterances.enable -}}
{{- $commentConfig = dict "repo" $utterances.repo | dict "utterances" | merge $commentConfig -}} {{- $commentConfig = $utterances.issueTerm | default "pathname" | dict "issueTerm" | dict "utterances" | merge $commentConfig -}} {{- $commentConfig = dict "label" $utterances.label | dict "utterances" | merge $commentConfig -}} {{- $commentConfig = $utterances.lightTheme | default "github-light" | dict "lightTheme" | dict "utterances" | merge $commentConfig -}} {{- $commentConfig = $utterances.darkTheme | default "github-dark" | dict "darkTheme" | dict "utterances" | merge $commentConfig -}} {{- $options := dict "targetPath" "js/utterances.min.js" "minify" true -}} {{- $js := resources.Get "js/lib/utterances.js" | js.Build $options -}} {{- $_ := $js.RelPermalink -}} {{- dict "Link" $js.RelPermalink "Fingerprint" $fingerprint "Defer" true | dict "Scratch" .Scratch "Data" | partial "scratch/commentScript.html" -}} {{- end -}} {{- /* Twikoo Comment System */ -}} {{- $twikoo := $comment.twikoo | default dict -}} {{- if $twikoo.enable -}}
{{- $shims := dict "twikoo" "js/shims/twikoo.js" -}} {{- $options := dict -}} {{- $options = dict "targetPath" "js/twikoo.min.js" | merge $options -}} {{- $options = dict "minify" true | merge $options -}} {{- if eq $twikoo.cloudbase false -}} {{- $source := $cdn.twikooJS | default "lib/twikoo/twikoo.min.js" -}} {{- dict "Source" $source "Fingerprint" $fingerprint "Defer" true | dict "Scratch" .Scratch "Data" | partial "scratch/commentScript.html" -}} {{- else -}} {{- $source := $cdn.twikooAllJS | default "lib/twikoo/twikoo.all.min.js" -}} {{- dict "Source" $source "Fingerprint" $fingerprint "Defer" true | dict "Scratch" .Scratch "Data" | partial "scratch/commentScript.html" -}} {{- end -}} {{- $options = dict "shims" $shims | merge $options -}} {{- $js := resources.Get "js/lib/twikoo.js" | js.Build $options -}} {{- dict "Link" $js.RelPermalink "Fingerprint" $fingerprint "Defer" true | dict "Scratch" .Scratch "Data" | partial "scratch/commentScript.html" -}} {{- $commentConfig = dict "el" "#twikoo" "envId" $twikoo.envId | dict "twikoo" | merge $commentConfig -}} {{- $commentConfig = dict "lang" .Lang | dict "twikoo" | merge $commentConfig -}} {{- with $twikoo.region -}} {{- $commentConfig = dict "region" . | dict "twikoo" | merge $commentConfig -}} {{- end -}} {{- with $twikoo.path -}} {{- $commentConfig = dict "path" . | dict "twikoo" | merge $commentConfig -}} {{- end -}} {{- with $twikoo.commentCount -}} {{- $commentConfig = dict "commentCount" . | dict "twikoo" | merge $commentConfig -}} {{- end -}} {{- end -}} {{- /* Vssue Comment System */ -}} {{- $vssue := $comment.vssue | default dict -}} {{- if $vssue.enable -}}
{{- $source := $cdn.vssueCSS | default "lib/vssue/vssue.min.css" -}} {{- dict "Source" $source "Minify" true "Fingerprint" $fingerprint | dict "Scratch" .Scratch "Data" | partial "scratch/style.html" -}} {{- $source := $cdn.vueRuntimeJS | default "lib/vue/vue.runtime.min.js" -}} {{- dict "Source" $source "Fingerprint" $fingerprint | dict "Scratch" .Scratch "Data" | partial "scratch/commentScript.html" -}} {{- if eq $vssue.platform "bitbucket" -}} {{- $source := $cdn.vssueBitbucketJS | default "lib/vssue/vssue.bitbucket.min.js" -}} {{- dict "Source" $source "Fingerprint" $fingerprint | dict "Scratch" .Scratch "Data" | partial "scratch/commentScript.html" -}} {{- else if eq $vssue.platform "gitea" -}} {{- $source := $cdn.vssueGiteaJS | default "lib/vssue/vssue.gitea.min.js" -}} {{- dict "Source" $source "Fingerprint" $fingerprint | dict "Scratch" .Scratch "Data" | partial "scratch/commentScript.html" -}} {{- else if eq $vssue.platform "gitee" -}} {{- $source := $cdn.vssueGiteeJS | default "lib/vssue/vssue.gitee.min.js" -}} {{- dict "Source" $source "Fingerprint" $fingerprint | dict "Scratch" .Scratch "Data" | partial "scratch/commentScript.html" -}} {{- else if eq $vssue.platform "github" -}} {{- $source := $cdn.vssueGithubJS | default "lib/vssue/vssue.github.min.js" -}} {{- dict "Source" $source "Fingerprint" $fingerprint | dict "Scratch" .Scratch "Data" | partial "scratch/commentScript.html" -}} {{- else if eq $vssue.platform "gitlab" -}} {{- $source := $cdn.vssueGitlabJS | default "lib/vssue/vssue.gitlab.min.js" -}} {{- dict "Source" $source "Fingerprint" $fingerprint | dict "Scratch" .Scratch "Data" | partial "scratch/commentScript.html" -}} {{- end -}} {{- $commentConfig = dict "el" "#vssue" "title" .Title | dict "vssue" | merge $commentConfig -}} {{- with $vssue.owner -}} {{- $commentConfig = dict "owner" . | dict "vssue" | merge $commentConfig -}} {{- end -}} {{- with $vssue.repo -}} {{- $commentConfig = dict "repo" . | dict "vssue" | merge $commentConfig -}} {{- end -}} {{- with $vssue.clientId -}} {{- $commentConfig = dict "clientId" . | dict "vssue" | merge $commentConfig -}} {{- end -}} {{- with $vssue.clientSecret -}} {{- $commentConfig = dict "clientSecret" . | dict "vssue" | merge $commentConfig -}} {{- end -}} {{- $options := dict "targetPath" "js/vssue.min.js" "minify" true -}} {{- $js := resources.Get "js/lib/vssue.js" | js.Build $options -}} {{- $_ := $js.RelPermalink -}} {{- dict "Link" $js.RelPermalink "Fingerprint" $fingerprint "Defer" true | dict "Scratch" .Scratch "Data" | partial "scratch/commentScript.html" -}} {{- end -}} {{- /* Remark42 Comment System */ -}} {{- $remark42 := $comment.remark42 | default dict -}} {{- if $remark42.enable -}}
{{- $commentConfig = dict "host" $remark42.host "site_id" $remark42.site_id "locale" .Lang | dict "remark42" | merge $commentConfig -}} {{- with $remark42.max_shown_comments -}} {{- $commentConfig = dict "max_shown_comments" . | dict "remark42" | merge $commentConfig -}} {{- end -}} {{- with $remark42.show_email_subscription -}} {{- $commentConfig = dict "show_email_subscription" . | dict "remark42" | merge $commentConfig -}} {{- end -}} {{- with $remark42.simple_view -}} {{- $commentConfig = dict "simple_view" . | dict "remark42" | merge $commentConfig -}} {{- end -}} {{- $options := dict "targetPath" "js/remark42.min.js" "minify" true -}} {{- $js := resources.Get "js/lib/remark42.js" | js.Build $options -}} {{- $_ := $js.RelPermalink -}} {{- dict "Link" $js.RelPermalink "Fingerprint" $fingerprint "Defer" true | dict "Scratch" .Scratch "Data" | partial "scratch/commentScript.html" -}} {{- end -}} {{- /* giscus Comment System */ -}} {{- $giscus := $comment.giscus | default dict -}} {{- if $giscus.enable -}}
{{- $commentConfig = dict "dataRepo" $giscus.dataRepo | dict "giscus" | merge $commentConfig -}} {{- $commentConfig = dict "dataRepoId" $giscus.dataRepoId | dict "giscus" | merge $commentConfig -}} {{- $commentConfig = dict "dataCategory" $giscus.dataCategory | dict "giscus" | merge $commentConfig -}} {{- $commentConfig = dict "dataCategoryId" $giscus.dataCategoryId | dict "giscus" | merge $commentConfig -}} {{- $commentConfig = $giscus.dataMapping | default "pathname" | dict "dataMapping" | dict "giscus" | merge $commentConfig -}} {{- $commentConfig = $giscus.dataStrict | default "0" | dict "dataStrict" | dict "giscus" | merge $commentConfig -}} {{- $commentConfig = $giscus.dataReactionsEnabled | default "1" | dict "dataReactionsEnabled" | dict "giscus" | merge $commentConfig -}} {{- $commentConfig = $giscus.dataEmitMetadata | default "0" | dict "dataEmitMetadata" | dict "giscus" | merge $commentConfig -}} {{- $commentConfig = $giscus.dataInputPosition | default "bottom" | dict "dataInputPosition" | dict "giscus" | merge $commentConfig -}} {{- $commentConfig = $giscus.lightTheme | default "light" | dict "lightTheme" | dict "giscus" | merge $commentConfig -}} {{- $commentConfig = $giscus.darkTheme | default "dark" | dict "darkTheme" | dict "giscus" | merge $commentConfig -}} {{- $commentConfig = $giscus.dataLang | default "en" | dict "dataLang" | dict "giscus" | merge $commentConfig -}} {{- $options := dict "targetPath" "js/giscus.min.js" "minify" true -}} {{- $js := resources.Get "js/lib/giscus.js" | js.Build $options -}} {{- $_ := $js.RelPermalink -}} {{- dict "Link" $js.RelPermalink "Fingerprint" $fingerprint "Defer" true | dict "Scratch" .Scratch "Data" | partial "scratch/commentScript.html" -}} {{- end -}} {{/* Artalk Comment System */}} {{- $artalk := $comment.artalk | default dict -}} {{- if $artalk.enable -}}
{{ if $artalk.lite }} {{- $source := $cdn.artalkLiteJS | default "lib/artalk/ArtalkLite.js" -}} {{- dict "Source" $source "Fingerprint" $fingerprint "Defer" true | dict "Scratch" .Scratch "Data" | partial "scratch/commentScript.html" -}} {{- $source := $cdn.artalkLiteCSS | default "lib/artalk/ArtalkLite.css" -}} {{- dict "Source" $source "Minify" true "Fingerprint" $fingerprint | dict "Scratch" .Scratch "Data" | partial "scratch/style.html" -}} {{ else }} {{- $source := $cdn.artalkJS | default "lib/artalk/Artalk.js" -}} {{- dict "Source" $source "Fingerprint" $fingerprint "Defer" true | dict "Scratch" .Scratch "Data" | partial "scratch/commentScript.html" -}} {{- $source := $cdn.artalkCSS | default "lib/artalk/Artalk.css" -}} {{- dict "Source" $source "Minify" true "Fingerprint" $fingerprint | dict "Scratch" .Scratch "Data" | partial "scratch/style.html" -}} {{ end }} {{ if $artalk.katex }} {{- $source := $cdn.artalkPluginKaTeXJS | default "lib/artalk/artalk-plugin-katex.js" -}} {{- dict "Source" $source "Fingerprint" $fingerprint "Defer" true | dict "Scratch" .Scratch "Data" | partial "scratch/commentScript.html" -}} {{ end }} {{- if $artalk.lightbox -}} {{- $source := $cdn.artalkPluginLightboxJS | default "lib/artalk/artalk-plugin-lightbox.js" -}} {{- dict "Source" $source "Fingerprint" $fingerprint "Defer" true | dict "Scratch" .Scratch "Data" | partial "scratch/commentScript.html" -}} {{- end -}} {{- $commentConfig = dict "el" "#artalk" "server" $artalk.server "site" $artalk.site | dict "artalk" | merge $commentConfig -}} {{- $shims := dict "artalk" "js/shims/artalk.js" -}} {{- $options := dict -}} {{- $options = dict "targetPath" "js/artalk.min.js" | merge $options -}} {{- $options = dict "minify" true | merge $options -}} {{- $options = dict "shims" $shims | merge $options -}} {{- $js := resources.Get "js/lib/artalk.js" | js.Build $options -}} {{- dict "Link" $js.RelPermalink "Fingerprint" $fingerprint "Defer" true | dict "Scratch" .Scratch "Data" | partial "scratch/commentScript.html" -}} {{- end -}}
{{- end -}} {{- dict "comment" $commentConfig | dict "config" | merge (.Scratch.Get "this") | .Scratch.Set "this" -}}