From 12546ba9bff2ca2648b63e43c93aa0d9c58b6eea Mon Sep 17 00:00:00 2001 From: Dillon Date: Tue, 28 Apr 2020 03:24:48 +0800 Subject: [PATCH] feat(valine): add more params for new valine (#272) --- exampleSite/config.toml | 3 ++ .../posts/theme-documentation-basics.en.md | 3 ++ .../posts/theme-documentation-basics.fr.md | 3 ++ .../posts/theme-documentation-basics.zh-cn.md | 3 ++ layouts/partials/comment.html | 39 +++++++++++-------- 5 files changed, 35 insertions(+), 16 deletions(-) diff --git a/exampleSite/config.toml b/exampleSite/config.toml index be701b38..499d1933 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -831,6 +831,9 @@ enableEmoji = true lang = "" visitor = true recordIP = true + highlight = true + enableQQ = false + serverURLs = "" # Facebook comment config (https://developers.facebook.com/docs/plugins/comments) # Facebook 评论系统设置 (https://developers.facebook.com/docs/plugins/comments) [params.page.comment.facebook] diff --git a/exampleSite/content/posts/theme-documentation-basics.en.md b/exampleSite/content/posts/theme-documentation-basics.en.md index a73cd376..06c9abc4 100644 --- a/exampleSite/content/posts/theme-documentation-basics.en.md +++ b/exampleSite/content/posts/theme-documentation-basics.en.md @@ -485,6 +485,9 @@ Please open the code block below to view the complete sample configuration :(far lang = "" visitor = true recordIP = true + highlight = true + enableQQ = false + serverURLs = "" # {{< link "https://developers.facebook.com/docs/plugins/comments" "Facebook comment" >}} config [params.page.comment.facebook] enable = false diff --git a/exampleSite/content/posts/theme-documentation-basics.fr.md b/exampleSite/content/posts/theme-documentation-basics.fr.md index 23137790..90a38f20 100644 --- a/exampleSite/content/posts/theme-documentation-basics.fr.md +++ b/exampleSite/content/posts/theme-documentation-basics.fr.md @@ -490,6 +490,9 @@ Please open the code block below to view the complete sample configuration :(far lang = "" visitor = true recordIP = true + highlight = true + enableQQ = false + serverURLs = "" # {{< link "https://developers.facebook.com/docs/plugins/comments" "Facebook comment" >}} config [params.page.comment.facebook] enable = false diff --git a/exampleSite/content/posts/theme-documentation-basics.zh-cn.md b/exampleSite/content/posts/theme-documentation-basics.zh-cn.md index 6432a600..e744bae8 100644 --- a/exampleSite/content/posts/theme-documentation-basics.zh-cn.md +++ b/exampleSite/content/posts/theme-documentation-basics.zh-cn.md @@ -488,6 +488,9 @@ hugo lang = "en" visitor = true recordIP = true + highlight = true + enableQQ = false + serverURLs = "" # {{< link "https://developers.facebook.com/docs/plugins/comments" "Facebook 评论系统" >}}设置 [params.page.comment.facebook] enable = false diff --git a/layouts/partials/comment.html b/layouts/partials/comment.html index 81e7590a..29b5a4ae 100644 --- a/layouts/partials/comment.html +++ b/layouts/partials/comment.html @@ -1,6 +1,6 @@ {{- $cdn := .Scratch.Get "cdn" | default dict -}} {{- $fingerprint := .Scratch.Get "fingerprint" -}} -{{- $comment := .Scratch.Get "comment" | default dict -}} +{{- $comment := .Scratch.Get "comment" | default (dict "disqus" dict "gitalk" dict "valine" dict "facebook" dict "telegram" dict "commento" dict) -}} {{- $commentConfig := dict -}} {{- if $comment.enable -}} @@ -17,12 +17,13 @@ {{- /* Gitalk Comment System */ -}} {{- if $comment.gitalk.enable -}} + {{- $gitalk := $comment.gitalk -}}
{{- $source := $cdn.gitalkCSS | default "lib/gitalk/gitalk.css" -}} {{- dict "source" $source "minify" true "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/stylesheet.html" -}} {{- $source := $cdn.gitalkJS | default "lib/gitalk/gitalk.min.js" -}} {{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} - {{- $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 -}} + {{- $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 -}} @@ -30,21 +31,25 @@ {{- /* Valine Comment System */ -}} {{- if $comment.valine.enable -}} + {{- $valine := $comment.valine -}}
{{- $options := dict "targetPath" "lib/valine/valine.min.css" -}} {{- dict "source" "lib/valine/valine.scss" "toCSS" $options | dict "scratch" $.Scratch "data" | partial "scratch/stylesheet.html" -}} {{- $source := $cdn.valineJS | default "lib/valine/Valine.min.js" -}} {{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} - {{- $commentConfig = dict "el" "#valine" "appId" $comment.valine.appId "appKey" $comment.valine.appKey "lang" ($comment.valine.lang | default (T "valineLang")) "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 "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 $comment.valine.meta -}} + {{- with $valine.meta -}} {{- $commentConfig = dict "meta" . | dict "valine" | merge $commentConfig -}} {{- end -}} - {{- with $comment.valine.pageSize -}} + {{- with $valine.pageSize -}} {{- $commentConfig = dict "pageSize" . | dict "valine" | merge $commentConfig -}} {{- end -}} + {{- with $valine.serverURLs -}} + {{- $commentConfig = dict "serverURLs" . | dict "valine" | merge $commentConfig -}} + {{- end -}} @@ -52,14 +57,15 @@ {{- /* Facebook Comment System */ -}} {{- if $comment.facebook.enable -}} + {{- $facebook := $comment.facebook -}}
- {{- $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 -}} + {{- $source := printf "https://connect.facebook.net/%s/sdk.js#xfbml=1&version=v5.0&appId=%s&autoLogAppEvents=1" ($facebook.languageCode | default (T "facebookLanguageCode")) $facebook.appId -}} {{- dict "source" $source "defer" true | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}}