{{- $cdn := .Site.Store.Get "cdn" | default dict -}} {{- $fingerprint := .Site.Store.Get "fingerprint" -}} {{- $comment := .Store.Get "comment" | default dict -}} {{- $commentConfig := dict "enable" false -}} {{- if $comment.enable -}} {{- $commentConfig = dict "enable" true "expired" (.Store.Get "commentExpired" | default false) -}}
{{- /* Artalk Comment System */ -}} {{- $artalk := $comment.artalk | default dict -}} {{- if $artalk.enable -}}
{{- $source := $cdn.artalkCSS | default (add $artalk.server "/dist/Artalk.css") -}} {{- dict "Source" $source "Minify" true "Fingerprint" $fingerprint | dict "Page" . "Data" | partial "store/style.html" -}} {{- $source := $cdn.artalkJS | default (add $artalk.server "/dist/Artalk.js") -}} {{- dict "Source" $source "Fingerprint" $fingerprint | dict "Page" . "Data" | partial "store/script.html" -}} {{- dict "Source" "js/lib/artalk.ts" "Build" true "Fingerprint" $fingerprint "Defer" true | dict "Page" . "Data" | partial "store/script.html" -}} {{- $commentConfig = dict "el" "#artalk" "pageKey" .Permalink "pageTitle" .Title "pvEl" "artalk-visitor-count" "countEl" "artalk-comment-count" | dict "artalk" | merge $commentConfig -}} {{- if (eq $artalk.locale "") | and (eq $.Site.Language.Locale "en") -}} {{- $artalk = dict "locale" "en-US" | merge $artalk -}} {{- end -}} {{- $commentConfig = dict "locale" ($artalk.locale | default $.Site.Language.Locale | default "auto") | dict "artalk" | merge $commentConfig -}} {{- with .Site.Params.gravatar -}} {{/* See https://artalk.js.org/guide/frontend/config.html#gravatar-params */}} {{- $gravatarMirror := printf "https://%v/avatar/" .Host -}} {{- $commentConfig = dict "mirror" $gravatarMirror "params" (printf "d=%v&s=240" .Style) | dict "gravatar" | dict "artalk" | merge $commentConfig -}} {{- end -}} {{- with $artalk.server -}} {{- $commentConfig = dict "server" . | dict "artalk" | merge $commentConfig -}} {{- end -}} {{- with $artalk.site -}} {{- $commentConfig = dict "site" . | dict "artalk" | merge $commentConfig -}} {{- end -}} {{- with $artalk.placeholder -}} {{- $commentConfig = dict "placeholder" . | dict "artalk" | merge $commentConfig -}} {{- end -}} {{- with $artalk.nocomment -}} {{- $commentConfig = dict "noComment" . | dict "artalk" | merge $commentConfig -}} {{- end -}} {{- with $artalk.sendbtn -}} {{- $commentConfig = dict "sendBtn" . | dict "artalk" | merge $commentConfig -}} {{- end -}} {{- with $artalk.editortravel -}} {{- $commentConfig = dict "editorTravel" . | dict "artalk" | merge $commentConfig -}} {{- end -}} {{- if ne $artalk.flatmode nil -}} {{- $commentConfig = dict "flatMode" $artalk.flatmode | dict "artalk" | merge $commentConfig -}} {{- end -}} {{- with $artalk.nestmax -}} {{- $commentConfig = dict "nestMax" . | dict "artalk" | merge $commentConfig -}} {{- end -}} {{- with $artalk.nestsort -}} {{- $commentConfig = dict "nestSort" . | dict "artalk" | merge $commentConfig -}} {{- end -}} {{- with $artalk.lightgallery -}} {{- $commentConfig = dict "lightgallery" . | dict "artalk" | merge $commentConfig -}} {{- end -}} {{- if eq $artalk.vote false -}} {{- $commentConfig = dict "vote" false | dict "artalk" | merge $commentConfig -}} {{- end -}} {{- with $artalk.votedown -}} {{- $commentConfig = dict "voteDown" . | dict "artalk" | merge $commentConfig -}} {{- end -}} {{- if eq $artalk.uabadge false -}} {{- $commentConfig = dict "uaBadge" false | dict "artalk" | merge $commentConfig -}} {{- end -}} {{- if eq $artalk.listsort false -}} {{- $commentConfig = dict "listSort" false | dict "artalk" | merge $commentConfig -}} {{- end -}} {{- if eq $artalk.imgupload false -}} {{- $commentConfig = dict "imgUpload" false | dict "artalk" | merge $commentConfig -}} {{- end -}} {{- if eq $artalk.preview false -}} {{- $commentConfig = dict "preview" false | dict "artalk" | merge $commentConfig -}} {{- end -}} {{- if eq $artalk.versioncheck false -}} {{- $commentConfig = dict "versionCheck" false | dict "artalk" | merge $commentConfig -}} {{- end -}} {{- if eq $artalk.preferremoteconf true -}} {{- $commentConfig = dict "preferRemoteConf" true | dict "artalk" | merge $commentConfig -}} {{- end -}} {{- with $artalk.imglazyload -}} {{- $commentConfig = dict "imgLazyLoad" . | dict "artalk" | merge $commentConfig -}} {{- end -}} {{- with $artalk.reqtimeout -}} {{- $commentConfig = dict "reqTimeout" . | dict "artalk" | merge $commentConfig -}} {{- end -}} {{- if eq $artalk.listunreadhighlight true -}} {{- $commentConfig = dict "listUnreadHighlight" true | dict "artalk" | merge $commentConfig -}} {{- end -}} {{- if eq $artalk.pvadd false -}} {{- $commentConfig = dict "pvAdd" false | dict "artalk" | merge $commentConfig -}} {{- end -}} {{- with $artalk.pagination -}} {{- $pagination := dict -}} {{- with .pagesize -}} {{- $pagination = dict "pageSize" . | merge $pagination -}} {{- end -}} {{- if eq .readmore false -}} {{- $pagination = dict "readMore" false | merge $pagination -}} {{- end -}} {{- if eq .autoload false -}} {{- $pagination = dict "autoLoad" false | merge $pagination -}} {{- end -}} {{- $commentConfig = dict "pagination" $pagination | dict "artalk" | merge $commentConfig -}} {{- end -}} {{- with $artalk.heightlimit -}} {{- $heightLimit := dict -}} {{- with .content -}} {{- $heightLimit = dict "content" . | merge $heightLimit -}} {{- end -}} {{- with .children -}} {{- $heightLimit = dict "children" . | merge $heightLimit -}} {{- end -}} {{- if eq .scrollable true -}} {{- $heightLimit = dict "scrollable" true | merge $heightLimit -}} {{- end -}} {{- $commentConfig = dict "heightLimit" $heightLimit | dict "artalk" | merge $commentConfig -}} {{- end -}} {{- end -}} {{- /* 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 "Page" . "Data" | partial "store/script.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 "Page" . "Data" | partial "store/style.html" -}} {{- $source := $cdn.gitalkJS | default "lib/gitalk/gitalk.min.js" -}} {{- dict "Source" $source "Fingerprint" $fingerprint | dict "Page" . "Data" | partial "store/script.html" -}} {{- dict "Source" "js/lib/gitalk.ts" "Build" true "Fingerprint" $fingerprint "Defer" true | dict "Page" . "Data" | partial "store/script.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 -}} {{- end -}} {{- /* Valine Comment System */ -}} {{- $valine := $comment.valine | default dict -}} {{- if $valine.enable -}}
{{- dict "Source" "lib/valine/valine.scss" "ToCSS" true | dict "Page" . "Data" | partial "store/style.html" -}} {{- $source := $cdn.valineJS | default "lib/valine/Valine.min.js" -}} {{- dict "Source" $source "Fingerprint" $fingerprint | dict "Page" . "Data" | partial "store/script.html" -}} {{- dict "Source" "js/lib/valine.ts" "Build" true "Fingerprint" $fingerprint "Defer" true | dict "Page" . "Data" | partial "store/script.html" -}} {{- /* Valine lang: https://github.com/xCss/Valine */ -}} {{- $valineLang := $valine.lang | default .Language.Name -}} {{- $valineLangs := dict "zh-cn" "zh-cn" "zh-tw" "zh-tw" "en" "en" "en-us" "en" "en-gb" "en" "ja" "ja" "ko" "ko" "ru" "ru" "fr" "fr" "pt-br" "pt" -}} {{- $valineLang = or (index $valineLangs $valineLang) (index $valineLangs (index (split $valineLang "-") 0)) "en" -}} {{- $commentConfig = dict "el" "#valine" "appId" $valine.appId "appKey" $valine.appKey "lang" $valineLang "visitor" $valine.visitor "recordIP" $valine.recordIP "placeholder" ($valine.placeholder | default (T "comment.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.requiredFields -}} {{- $commentConfig = dict "requiredFields" . | 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 "lib/valine/emoji/%v" | resources.Get | transform.Unmarshal | dict "valine" | merge $commentConfig -}} {{- end -}} {{- /* Waline Comment System */ -}} {{- /* see https://waline.js.org/reference/client/props.html */ -}} {{- $waline := $comment.waline | default dict -}} {{- if $waline.enable -}}
{{- $source := $cdn.walineCSS | default "lib/waline/waline.css" -}} {{- dict "Source" $source "Fingerprint" $fingerprint | dict "Page" . "Data" | partial "store/style.html" -}} {{- $source := $cdn.walineJS | default "lib/waline/waline.umd.js" -}} {{- dict "Source" $source "Fingerprint" $fingerprint "Defer" true | dict "Page" . "Data" | partial "store/script.html" -}} {{- dict "Source" "js/lib/waline.ts" "Build" true "Fingerprint" $fingerprint "Defer" true | dict "Page" . "Data" | partial "store/script.html" -}} {{- $commentConfig = dict "el" "#waline" "serverURL" $waline.serverURL "lang" .Language.Name | dict "waline" | merge $commentConfig -}} {{- $commentConfig = dict "copyright" true "imageUploader" false "highlighter" false "texRenderer" false "search" false | dict "waline" | merge $commentConfig -}} {{- with $waline.pageview -}} {{- $commentConfig = dict "pageview" . | 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 -}} {{- with $waline.imageUploader -}} {{- $commentConfig = dict "imageUploader" . | dict "waline" | merge $commentConfig -}} {{- end -}} {{- with $waline.highlighter -}} {{- $commentConfig = dict "highlighter" . | dict "waline" | merge $commentConfig -}} {{- end -}} {{- with $waline.comment -}} {{- $commentConfig = dict "comment" . | dict "waline" | merge $commentConfig -}} {{- end -}} {{- with $waline.texRenderer -}} {{- $commentConfig = dict "texRenderer" . | dict "waline" | merge $commentConfig -}} {{- end -}} {{- with $waline.search -}} {{- $commentConfig = dict "search" . | dict "waline" | merge $commentConfig -}} {{- end -}} {{- with $waline.recaptchaV3Key -}} {{- $commentConfig = dict "recaptchaV3Key" . | dict "waline" | merge $commentConfig -}} {{- end -}} {{- with $waline.turnstileKey -}} {{- $commentConfig = dict "turnstileKey" . | dict "waline" | merge $commentConfig -}} {{- end -}} {{- with $waline.reaction -}} {{- $commentConfig = dict "reaction" . | dict "waline" | merge $commentConfig -}} {{- end -}} {{- end -}} {{- /* Facebook Comment System */ -}} {{- $facebook := $comment.facebook | default dict -}} {{- if $facebook.enable -}}
{{- /* Facebook locale: https://developers.facebook.com/docs/internationalization */ -}} {{- $fbLang := $facebook.languageCode | default .Language.Name -}} {{- $fbLangs := dict "zh" "zh_CN" "zh-cn" "zh_CN" "zh-tw" "zh_TW" "en" "en_US" "ja" "ja_JP" "ko" "ko_KR" "fr" "fr_FR" "de" "de_DE" "es" "es_ES" "pt" "pt_BR" "pt-br" "pt_BR" "ru" "ru_RU" "it" "it_IT" "hi" "hi_IN" "pl" "pl_PL" "ro" "ro_RO" "sr" "sr_RS" "vi" "vi_VN" -}} {{- $fbLang = or (index $fbLangs $fbLang) (index $fbLangs (index (split $fbLang "-") 0)) "en_US" -}} {{- $source := printf "https://connect.facebook.net/%v/sdk.js#xfbml=1&version=v5.0&appId=%v&autoLogAppEvents=1" $fbLang $facebook.appId -}} {{- dict "Source" $source "Defer" true | dict "Page" . "Data" | partial "store/script.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 -}} {{- dict "Source" "https://comments.app/js/widget.js?2" "Defer" true "Attr" $attr | dict "Page" . "Data" | partial "store/script.html" -}} {{- end -}} {{- /* Commento Comment System */ -}} {{- $commento := $comment.commento | default dict -}} {{- if $commento.enable -}}
{{- dict "Source" "https://cdn.commento.io/js/commento.js" "Defer" true | dict "Page" . "Data" | partial "store/script.html" -}} {{- end -}} {{- /* Utterances Comment System */ -}} {{- $utterances := $comment.utterances | default dict -}} {{- if $utterances.enable -}}
{{- dict "Source" "js/lib/utterances.ts" "Build" true "Fingerprint" $fingerprint "Defer" true | dict "Page" . "Data" | partial "store/script.html" -}} {{- $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 -}} {{- end -}} {{- /* Twikoo Comment System */ -}} {{- $twikoo := $comment.twikoo | default dict -}} {{- if $twikoo.enable -}}
{{- $source := $cdn.twikooJS | default "lib/twikoo/twikoo.all.min.js" -}} {{- dict "Source" $source "Fingerprint" $fingerprint "Defer" true | dict "Page" . "Data" | partial "store/script.html" -}} {{- dict "Source" "js/lib/twikoo.ts" "Build" true "Fingerprint" $fingerprint "Defer" true | dict "Page" . "Data" | partial "store/script.html" -}} {{- /* Twikoo lang: https://github.com/twikoojs/twikoo/blob/main/src/client/utils/i18n/index.js */ -}} {{- $lang := $twikoo.lang | default .Language.Name -}} {{- $langs := slice "zh" "zh-cn" "zh-hk" "zh-tw" "en" "en-us" "en-gb" "uz" "ja" "ja-jp" "ko" "ko-kr" "vi" "vi-vn" "pt" "hr" -}} {{- $base := index (split $lang "-") 0 -}} {{- $lang = or (and (in $langs $lang) $lang) (and (in $langs $base) $base) "en" -}} {{- $commentConfig = dict "el" "#twikoo" "envId" $twikoo.envId "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 -}} {{- with $twikoo.lightgallery -}} {{- $commentConfig = dict "lightgallery" . | dict "twikoo" | merge $commentConfig -}} {{- end -}} {{- end -}} {{- /* Giscus Comment System */ -}} {{- $giscus := $comment.giscus | default dict -}} {{- if $giscus.enable -}} {{- dict "Source" "js/lib/giscus.ts" "Build" true "Fingerprint" $fingerprint "Defer" true | dict "Page" . "Data" | partial "store/script.html" -}} {{- with $giscus -}} {{- $commentConfig = .origin | default "https://giscus.app" | dict "origin" | dict "giscus" | merge $commentConfig -}} {{- $commentConfig = .lightTheme | default "light" | dict "lightTheme" | dict "giscus" | merge $commentConfig -}} {{- $commentConfig = .darkTheme | default "dark" | dict "darkTheme" | dict "giscus" | merge $commentConfig -}}
{{- end -}} {{- end -}} {{- /* Custom Comment System */ -}} {{- block "custom-comment" . }}{{ end -}}
{{- /* lightgallery for Artalk and Twikoo */ -}} {{- if not (.Param "lightgallery") | and (($artalk.enable | and $artalk.lightgallery) | or ($twikoo.enable | and $twikoo.lightgallery)) -}} {{- $source := $cdn.lightgalleryCSS | default "lib/lightgallery/css/lightgallery-bundle.min.css" -}} {{- dict "Source" $source "Fingerprint" $fingerprint | dict "Page" . "Data" | partial "store/style.html" -}} {{- $source := $cdn.lightgalleryJS | default "lib/lightgallery/lightgallery.min.js" -}} {{- dict "Source" $source "Fingerprint" $fingerprint "Defer" true | dict "Page" . "Data" | partial "store/script.html" -}} {{- $source := $cdn.lightgalleryThumbnailJS | default "lib/lightgallery/plugins/thumbnail/lg-thumbnail.min.js" -}} {{- dict "Source" $source "Fingerprint" $fingerprint "Defer" true | dict "Page" . "Data" | partial "store/script.html" -}} {{- $source := $cdn.lightgalleryZoomJS | default "lib/lightgallery/plugins/zoom/lg-zoom.min.js" -}} {{- dict "Source" $source "Fingerprint" $fingerprint "Defer" true | dict "Page" . "Data" | partial "store/script.html" -}} {{- end -}} {{- /* KaTeX for Twikoo */ -}} {{- if $twikoo.enable | and $twikoo.katex -}} {{- $katexVersion := "0.16.47" -}} {{- $source := printf "https://cdn.jsdelivr.net/npm/katex@%s/dist/katex.min.css" $katexVersion -}} {{- dict "Source" $source "Fingerprint" $fingerprint | dict "Page" . "Data" | partial "store/style.html" -}} {{- $source := printf "https://cdn.jsdelivr.net/npm/katex@%s/dist/katex.min.js" $katexVersion -}} {{- dict "Source" $source "Fingerprint" $fingerprint "Defer" true | dict "Page" . "Data" | partial "store/script.html" -}} {{- $source := printf "https://cdn.jsdelivr.net/npm/katex@%s/dist/contrib/auto-render.min.js" $katexVersion -}} {{- dict "Source" $source "Fingerprint" $fingerprint "Defer" true | dict "Page" . "Data" | partial "store/script.html" -}} {{- end -}} {{- end -}} {{- dict "comment" $commentConfig | dict "config" | merge (.Store.Get "this") | .Store.Set "this" -}}