Skip to content

Commit

Permalink
feat: support Valine (#79)
Browse files Browse the repository at this point in the history
* feat: support valine

* ui: impove valine UI

* feat: support valine options

* fix: remove valine serverURLs option

* refactor: load params in a more flexible way

* feat: custom editThisPage repo branch

* cRevert "feat: custom editThisPage repo branch"

This reverts commit 36923ac.

Co-authored-by: Wang Chucheng <[email protected]>
  • Loading branch information
HerbertHe and wangchucheng authored Apr 18, 2021
1 parent 177e4b1 commit 1762613
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
9 changes: 8 additions & 1 deletion data/assets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,11 @@ mermaid:
version: 8.9.2
js:
url: https://cdn.jsdelivr.net/npm/mermaid@%s/dist/mermaid.min.js
sri: sha256-Zmpaaj+GXFsPF5WdPArSrnW3b30dovldeKsW00xBVwE=
sri: sha256-Zmpaaj+GXFsPF5WdPArSrnW3b30dovldeKsW00xBVwE=

# Valine
valine:
version: 1.4.14
js:
url: https://cdn.jsdelivr.net/npm/valine@%s/dist/Valine.min.js
sri: sha256-fPqMAsW3FDt/rNyneSJ7HOpZNRs/O2rM016SU08JtCk=
12 changes: 10 additions & 2 deletions exampleSite/config/_default/params.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ publisherLogo:

highlight:
handler: highlightjs

highlightjs:
# highlight.js doesn't bundle every language. So please specify additional languages you want here.
# See https://github.com/highlightjs/cdn-release/tree/master/build/languages for available languages.
Expand All @@ -40,7 +40,7 @@ math:
# leqno:

comment:
# Options: disqus, commento and utterances.
# Options: disqus, commento, valine and utterances.
handler:

# disqus:
Expand All @@ -57,6 +57,14 @@ comment:
# # If self-hosting, please enter the url (e.g. https://commento.example.com) here. Otherwise leave empty.
# url:

valine:
# Browse https://valine.js.org/configuration.html to see the options available.
# You can list the key and value you want as below.
# Because Hugo's config params are case-insensitive, you need to add `-` or `_` before the uppercase letters.
# For example, `appId` should be written as `app-Id` or other acceptable formats.
app-Id:
app-Key:

diagram:
handler: mermaid

Expand Down
14 changes: 14 additions & 0 deletions layouts/partials/comment/valine.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<div id="valine-comments" class="mt-4"></div>
{{- $assets := .Site.Data.assets }}
<script defer src="{{ printf $assets.valine.js.url $assets.valine.version }}" {{ with $assets.valine.js.sri }}
integrity="{{ . }}" {{ end }} crossorigin></script>
{{- with .Site.Params.comment.valine }}
<script>
document.addEventListener("DOMContentLoaded", function () {
new Valine({
el: "#valine-comments",
{{- partial "utils/get-js-configs" . | safeJS }}
})
});
</script>
{{- end }}

0 comments on commit 1762613

Please sign in to comment.