diff options
author | reuixiy <reuixiy@gmail.com> | 2019-11-21 10:17:15 +0300 |
---|---|---|
committer | reuixiy <reuixiy@gmail.com> | 2019-11-21 10:17:15 +0300 |
commit | 15a86acb78a6af75885e8b57c17556368aa17e28 (patch) | |
tree | 739c89d9b6a94c8c02d76e6dcb6ed114017abe4f | |
parent | 9cbb874cfce4916aacdbde37e47e9331de49fc8d (diff) |
feat: support Valine comment #22
-rw-r--r-- | config-examples/en-us/config.toml | 19 | ||||
-rw-r--r-- | config-examples/zh-cn/config.toml | 19 | ||||
-rw-r--r-- | layouts/partials/comments.html | 14 | ||||
-rw-r--r-- | layouts/partials/script.html | 6 | ||||
-rw-r--r-- | layouts/partials/third-party/valine.html | 23 |
5 files changed, 78 insertions, 3 deletions
diff --git a/config-examples/en-us/config.toml b/config-examples/en-us/config.toml index 9db7413..bd52fda 100644 --- a/config-examples/en-us/config.toml +++ b/config-examples/en-us/config.toml @@ -567,6 +567,25 @@ uglyURLs = false enableDisqus = false disqusShortname = "" + ## Valine + enableValine = false + valineAppId = "" + valineAppKey = "" + valinePlaceholder = "Just go go" + valineNotify = false + valineVerify = false + valinePath = "window.location.pathname" + valineAvatar = "mm" + valineMeta = ["nick", "mail", "link"] + valinePageSize = 10 + valineLang = "en" + valineVisitor = false + valineHighlight = true + avatarForce = false + valineRecordIP = false + valineServerURLs = "http[s]://[tab/us].avoscloud.com" + # Note: https://valine.js.org/ + ###################################### # Google Analytics diff --git a/config-examples/zh-cn/config.toml b/config-examples/zh-cn/config.toml index 23b4c74..b0d2fde 100644 --- a/config-examples/zh-cn/config.toml +++ b/config-examples/zh-cn/config.toml @@ -519,6 +519,25 @@ uglyURLs = false enableDisqus = false disqusShortname = "" + ## Valine + enableValine = false + valineAppId = "" + valineAppKey = "" + valinePlaceholder = "Just go go" + valineNotify = false + valineVerify = false + valinePath = "window.location.pathname" + valineAvatar = "mm" + valineMeta = ["nick", "mail", "link"] + valinePageSize = 10 + valineLang = "zh-cn" + valineVisitor = false + valineHighlight = true + avatarForce = false + valineRecordIP = false + valineServerURLs = "http[s]://[tab/us].avoscloud.com" + # 说明:https://valine.js.org/ + ###################################### # Google Analytics diff --git a/layouts/partials/comments.html b/layouts/partials/comments.html index 3442c85..96a4471 100644 --- a/layouts/partials/comments.html +++ b/layouts/partials/comments.html @@ -1,10 +1,18 @@ {{ if and (.Params.comments | default .Site.Params.enableComments) (eq hugo.Environment "production") }} {{ if or (in .Site.Params.mainSections .Section) .Params.comments }} + + <div class="load-comments"> + <div id="load-comments" onclick="loadComments()">{{ i18n "loadComments" }}</div> + </div> + {{ if .Site.Params.enableDisqus }} - <div class="load-comments"> - <div id="load-comments" onclick="loadComments()">{{ i18n "loadComments" }}</div> - </div> <div id="disqus_thread"></div> {{ end }} + + {{ if .Site.Params.enableValine }} + <script src="https://unpkg.com/valine/dist/Valine.min.js"></script> + <div id="vcomments"></div> + {{ end }} + {{ end }} {{ end }}
\ No newline at end of file diff --git a/layouts/partials/script.html b/layouts/partials/script.html index ad73a9e..8552590 100644 --- a/layouts/partials/script.html +++ b/layouts/partials/script.html @@ -41,9 +41,15 @@ {{ if and (.Params.comments | default .Site.Params.enableComments) (eq hugo.Environment "production") }} {{ if or (in .Site.Params.mainSections .Section) .Params.comments }} + {{ if .Site.Params.enableDisqus }} {{ partial "third-party/disqus.html" . }} {{ end }} + + {{ if .Site.Params.enableValine }} + {{ partial "third-party/valine.html" . }} + {{ end }} + {{ end }} {{ end }} diff --git a/layouts/partials/third-party/valine.html b/layouts/partials/third-party/valine.html new file mode 100644 index 0000000..9457a53 --- /dev/null +++ b/layouts/partials/third-party/valine.html @@ -0,0 +1,23 @@ +<script> + function loadComments() { + document.querySelector('#load-comments').style = "display:none"; + new Valine({ + el: '#vcomments', + appId: '{{ .Site.Params.valineAppId }}', + appKey: '{{ .Site.Params.valineAppKey }}', + placeholder: '{{ .Site.Params.valinePlaceholder }}', + notify: {{ .Site.Params.valineNotify }}, + verify: {{ .Site.Params.valineVerify }}, + path: '{{ .Site.Params.valinePath }}', + avatar: '{{ .Site.Params.valineAvatar }}', + meta: {{ .Site.Params.valineMeta }}, + pageSize: {{ .Site.Params.valinePageSize }}, + lang: '{{ .Site.Params.valineLang }}', + visitor: {{ .Site.Params.valineVisitor }}, + highlight: {{ .Site.Params.valineHighlight }}, + avatarForce: {{ .Site.Params.avatarForce }}, + recordIP: {{ .Site.Params.valineRecordIP }}, + serverURLs: '{{ .Site.Params.valineServerURLs }}' + }); + } +</script>
\ No newline at end of file |