diff options
author | WingLim <643089849@qq.com> | 2021-10-01 17:38:37 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-01 17:38:37 +0300 |
commit | d8c9468c685f38476b241f82130a6ae59e28ad05 (patch) | |
tree | 83e0ca94640b9de7727c8d4722e2b94c3e78b2f0 | |
parent | 57bfea833850e0565cf81d9a26c52359427151a2 (diff) |
feat(comments): add Cusdis support (#372)
* feat: add cusdis support
* docs: add cusdis example config
-rw-r--r-- | exampleSite/config.yaml | 4 | ||||
-rw-r--r-- | layouts/partials/comments/provider/cusdis.html | 24 |
2 files changed, 28 insertions, 0 deletions
diff --git a/exampleSite/config.yaml b/exampleSite/config.yaml index 7b89960..dcf6c63 100644 --- a/exampleSite/config.yaml +++ b/exampleSite/config.yaml @@ -121,6 +121,10 @@ params: repo: clientID: clientSecret: + + cusdis: + host: + id: widgets: enabled: diff --git a/layouts/partials/comments/provider/cusdis.html b/layouts/partials/comments/provider/cusdis.html new file mode 100644 index 0000000..71863f3 --- /dev/null +++ b/layouts/partials/comments/provider/cusdis.html @@ -0,0 +1,24 @@ +<div id="cusdis_thread" + {{ if .Site.Params.comments.cusdis.host }} + data-host="{{ .Site.Params.comments.cusdis.host }}" + {{ else }} + data-host="https://cusdis.com" + {{ end }} + data-app-id="{{ .Site.Params.comments.cusdis.id }}" + data-page-id="{{ .File.UniqueID }}" + data-page-url="{{ .Permalink }}" + data-page-title="{{ .Title }}"></div> +<script async defer src="https://cusdis.com/js/cusdis.es.js"></script> + +<script> + function setCusdisTheme(theme) { + let cusdis = document.querySelector('#cusdis_thread iframe'); + if (cusdis) { + window.CUSDIS.setTheme(theme) + } + } + + window.addEventListener('onColorSchemeChange', (e) => { + setCusdisTheme(e.detail) + }) +</script>
\ No newline at end of file |