diff --git a/assets/js/theme.js b/assets/js/theme.js index 6f2f730d..4d94e316 100644 --- a/assets/js/theme.js +++ b/assets/js/theme.js @@ -902,6 +902,8 @@ var Theme = /*#__PURE__*/function () { this.switchThemeEventSet.add(this._giscusOnSwitchTheme); } + + if (this.config.comment.waline) Waline.init(this.config.comment.waline); } } }, { diff --git a/exampleSite/config.toml b/exampleSite/config.toml index 504cb9e9..19297361 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -585,6 +585,15 @@ ignoreErrors = ["error-remote-getjson", "error-missing-instagram-accesstoken"] lazyLoading = false lightTheme = "light" darkTheme = "dark" + # Waline comment config (https://waline.js.org/) + # Waline 评论系统设置 (https://waline.js.org/) + [params.page.comment.waline] + enable = false + serverURL = "https://love-it-waline.vercel.app" + # automatically adapt the current theme i18n configuration when empty + # 为空时自动适配当前主题 i18n 配置 + lang = "" + emoji = ["https://unpkg.com/@waline/emojis@1.0.1/tw-emoji"] # Third-party library config # 第三方库配置 [params.page.library] diff --git a/i18n/ar.toml b/i18n/ar.toml index 661f3c4e..7df15ff3 100644 --- a/i18n/ar.toml +++ b/i18n/ar.toml @@ -62,6 +62,9 @@ other = "ar_AR" [giscusLang] other = "en" + +[walineLang] +other = "en" # === partials/comment.html === # === partials/assets.html === diff --git a/i18n/ca.toml b/i18n/ca.toml index 3a695cca..3e9f69d0 100644 --- a/i18n/ca.toml +++ b/i18n/ca.toml @@ -62,6 +62,9 @@ other = "ca_ES" [giscusLang] other = "en" + +[walineLang] +other = "en" # === partials/comment.html === # === partials/assets.html === diff --git a/i18n/de.toml b/i18n/de.toml index 6bfaa504..1b05aef2 100644 --- a/i18n/de.toml +++ b/i18n/de.toml @@ -62,6 +62,9 @@ other = "de_DE" [giscusLang] other = "de" + +[walineLang] +other = "en" # === partials/comment.html === # === partials/assets.html === diff --git a/i18n/en.toml b/i18n/en.toml index 47d8e73d..1b2fc70f 100644 --- a/i18n/en.toml +++ b/i18n/en.toml @@ -61,6 +61,9 @@ other = "en_US" [giscusLang] other = "en" + +[walineLang] +other = "en" # === partials/comment.html === # === partials/assets.html === diff --git a/i18n/es.toml b/i18n/es.toml index 7c6d0186..6643e77b 100644 --- a/i18n/es.toml +++ b/i18n/es.toml @@ -62,6 +62,9 @@ other = "es_MX" [giscusLang] other = "es" + +[walineLang] +other = "en" # === partials/comment.html === # === partials/assets.html === diff --git a/i18n/fr.toml b/i18n/fr.toml index fd9d2823..c721d977 100644 --- a/i18n/fr.toml +++ b/i18n/fr.toml @@ -62,6 +62,9 @@ other = "fr" [giscusLang] other = "fr" + +[walineLang] +other = "en" # === partials/comment.html === # === partials/assets.html === diff --git a/i18n/hi.toml b/i18n/hi.toml index 7a05fb58..94a75492 100644 --- a/i18n/hi.toml +++ b/i18n/hi.toml @@ -62,6 +62,9 @@ other = "hi_IN" [giscusLang] other = "en" + +[walineLang] +other = "en" # === partials/comment.html === # === partials/assets.html === diff --git a/i18n/id.toml b/i18n/id.toml index 2bebaac8..9456a214 100644 --- a/i18n/id.toml +++ b/i18n/id.toml @@ -62,6 +62,9 @@ other = "id_ID" [giscusLang] other = "id" + +[walineLang] +other = "en" # === partials/comment.html === # === partials/assets.html === diff --git a/i18n/it.toml b/i18n/it.toml index b3381d00..0b897381 100644 --- a/i18n/it.toml +++ b/i18n/it.toml @@ -62,6 +62,9 @@ other = "it" [giscusLang] other = "it" + +[walineLang] +other = "en" # === partials/comment.html === # === partials/assets.html === diff --git a/i18n/ko.toml b/i18n/ko.toml index 65eb15de..5fe1c1a0 100644 --- a/i18n/ko.toml +++ b/i18n/ko.toml @@ -62,6 +62,9 @@ other = "ko-KR" [giscusLang] other = "ko" + +[walineLang] +other = "en" # === partials/comment.html === # === partials/assets.html === diff --git a/i18n/pl.toml b/i18n/pl.toml index fd200763..edf1d13f 100644 --- a/i18n/pl.toml +++ b/i18n/pl.toml @@ -62,6 +62,9 @@ other = "pl" [giscusLang] other = "pl" + +[walineLang] +other = "en" # === partials/comment.html === # === partials/assets.html === diff --git a/i18n/pt-BR.toml b/i18n/pt-BR.toml index 9267dc51..3b24645f 100644 --- a/i18n/pt-BR.toml +++ b/i18n/pt-BR.toml @@ -62,6 +62,9 @@ other = "pt_BR" [giscusLang] other = "en" + +[walineLang] +other = "pt-BR" # === partials/comment.html === # === partials/assets.html === diff --git a/i18n/ro.toml b/i18n/ro.toml index 5ec072b2..91a295c2 100644 --- a/i18n/ro.toml +++ b/i18n/ro.toml @@ -62,6 +62,9 @@ other = "ro_RO" [giscusLang] other = "ro" + +[walineLang] +other = "en" # === partials/comment.html === # === partials/assets.html === diff --git a/i18n/ru.toml b/i18n/ru.toml index d97029d4..713db214 100644 --- a/i18n/ru.toml +++ b/i18n/ru.toml @@ -62,6 +62,9 @@ other = "ru_RU" [giscusLang] other = "ru" + +[walineLang] +other = "ru-RU" # === partials/comment.html === # === partials/assets.html === diff --git a/i18n/sr.toml b/i18n/sr.toml index 5810f9d6..6d422833 100644 --- a/i18n/sr.toml +++ b/i18n/sr.toml @@ -62,6 +62,9 @@ other = "sr_RS" [giscusLang] other = "en" + +[walineLang] +other = "en" # === partials/comment.html === # === partials/assets.html === diff --git a/i18n/te.toml b/i18n/te.toml index 432303cb..64b1d897 100644 --- a/i18n/te.toml +++ b/i18n/te.toml @@ -63,6 +63,9 @@ other = "te_IN" [giscusLang] other = "en" + +[walineLang] +other = "en" # === partials/comment.html === # === partials/assets.html === diff --git a/i18n/th.toml b/i18n/th.toml index 58fab433..901d0b02 100644 --- a/i18n/th.toml +++ b/i18n/th.toml @@ -62,6 +62,9 @@ other = "th_TH" [giscusLang] other = "en" + +[walineLang] +other = "en" # === partials/comment.html === # === partials/assets.html === diff --git a/i18n/tr.toml b/i18n/tr.toml index 9142ca18..78dc99d0 100644 --- a/i18n/tr.toml +++ b/i18n/tr.toml @@ -62,6 +62,9 @@ other = "tr_TR" [giscusLang] other = "tr" + +[walineLang] +other = "en" # === partials/comment.html === # === partials/assets.html === diff --git a/i18n/vi.toml b/i18n/vi.toml index 69c91ea5..ce6d9c9d 100644 --- a/i18n/vi.toml +++ b/i18n/vi.toml @@ -62,6 +62,9 @@ other = "vi" [giscusLang] other = "vi" + +[walineLang] +other = "en" # === partials/comment.html === # === partials/assets.html === diff --git a/i18n/zh-CN.toml b/i18n/zh-CN.toml index d45c89ea..a330e28b 100644 --- a/i18n/zh-CN.toml +++ b/i18n/zh-CN.toml @@ -62,6 +62,9 @@ other = "zh_CN" [giscusLang] other = "zh-CN" + +[walineLang] +other = "zh-CN" # === partials/comment.html === # === partials/assets.html === diff --git a/i18n/zh-TW.toml b/i18n/zh-TW.toml index 126cfeee..630f0761 100644 --- a/i18n/zh-TW.toml +++ b/i18n/zh-TW.toml @@ -59,6 +59,9 @@ other = "你的評論 ..." [facebookLanguageCode] other = "zh_TW" + +[walineLang] +other = "zh-TW" # === partials/comment.html === # === partials/assets.html === diff --git a/layouts/partials/comment.html b/layouts/partials/comment.html index 2a52864e..548ff212 100644 --- a/layouts/partials/comment.html +++ b/layouts/partials/comment.html @@ -146,6 +146,23 @@ Please enable JavaScript to view the comments powered by Giscus. {{- end -}} + + {{- /* Waline Comment System */ -}} + {{- $waline := $comment.waline | default dict -}} + {{- if $waline.enable -}} +
+ {{- $source := $cdn.walineCSS | default "lib/waline/waline.css" -}} + {{- dict "Source" $source "Fingerprint" $fingerprint | dict "Scratch" .Scratch "Data" | partial "scratch/style.html" -}} + {{- $source := $cdn.walineJS | default "lib/waline/waline.js" -}} + {{- dict "Source" $source "Fingerprint" $fingerprint | dict "Scratch" .Scratch "Data" | partial "scratch/script.html" -}} + {{- $commentConfig = dict "el" "#waline" "serverURL" $waline.serverURL "lang" ($waline.lang | default (T "walineLang")) | dict "waline" | merge $commentConfig -}} + {{- with $waline.emoji -}} + {{- $commentConfig = dict "emoji" . | dict "waline" | merge $commentConfig -}} + {{- end -}} + + {{- end -}} {{- end -}} diff --git a/src/js/theme.js b/src/js/theme.js index 3598f9a2..579dc502 100644 --- a/src/js/theme.js +++ b/src/js/theme.js @@ -678,6 +678,7 @@ class Theme { }); this.switchThemeEventSet.add(this._giscusOnSwitchTheme); } + if (this.config.comment.waline) Waline.init(this.config.comment.waline); } }