From 105a835bab9543baadd9879527bf1f5959ddb05a Mon Sep 17 00:00:00 2001 From: Damillora Date: Wed, 14 Apr 2021 21:01:51 +0700 Subject: [PATCH] chore: add comments --- assets/js/index.js | 3 ++- assets/js/lib/comments.js | 39 +++++++++++++++++++++++++++++++++++++++ post.hbs | 2 +- 3 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 assets/js/lib/comments.js diff --git a/assets/js/index.js b/assets/js/index.js index 9dfc8e3..bfca76b 100644 --- a/assets/js/index.js +++ b/assets/js/index.js @@ -2,4 +2,5 @@ import './lib/dark-mode'; import './lib/fitvids'; import './lib/infinite-scroll'; import './lib/nav-collapse'; -import './lib/search'; \ No newline at end of file +import './lib/search'; +import './lib/comments'; diff --git a/assets/js/lib/comments.js b/assets/js/lib/comments.js new file mode 100644 index 0000000..10f269d --- /dev/null +++ b/assets/js/lib/comments.js @@ -0,0 +1,39 @@ + +window.remark_config = { + host: "https://comments.nanao.moe", // hostname of remark server, same as REMARK_URL in backend config, e.g. "https://demo.remark42.com" + site_id: 'yuika', + theme: 'light', + components: ['embed'], // optional param; which components to load. default to ["embed"] + // to load all components define components as ['embed', 'last-comments', 'counter'] + // available component are: + // - 'embed': basic comments widget + // - 'last-comments': last comments widget, see `Last Comments` section below + // - 'counter': counter widget, see `Counter` section below + max_shown_comments: 10, // optional param; if it isn't defined default value (15) will be used + show_email_subscription: false // optional param; by default it is `true` and you can see email subscription feature + // in interface when enable it from backend side + // if you set this param in `false` you will get notifications email notifications as admin + // but your users won't have interface for subscription +}; + + + remark_config.theme = window.document.body.getAttribute("data-theme"); + (function (c) { + for (var i = 0; i < c.length; i++) { + var d = document, s = d.createElement('script'); + s.src = remark_config.host + '/web/' + c[i] + '.js'; + s.defer = true; + (d.head || d.body).appendChild(s); + } + })(remark_config.components || ['embed']); + document.getElementById("darkMode").addEventListener('click',function () { + if (window.document.body.getAttribute("data-theme") != "dark") { + if (window.REMARK42) { + window.REMARK42.changeTheme('dark'); + } + } else { + if (window.REMARK42) { + window.REMARK42.changeTheme('light'); + } + } + }); diff --git a/post.hbs b/post.hbs index 1df8ebb..3af6d54 100644 --- a/post.hbs +++ b/post.hbs @@ -89,7 +89,7 @@

Comments are disabled for post previews

{{else}} {{!-- Comments --}} - +
{{/is}}