From bb074124829bc1b7a1eee0404f7ba34f1e5cbb33 Mon Sep 17 00:00:00 2001 From: Bangara Raju Kottedi Date: Sun, 23 Jul 2023 04:38:03 +0530 Subject: [PATCH] remark42 theme change automatically when chripy theme changes --- _includes/comments/remark42.html | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/_includes/comments/remark42.html b/_includes/comments/remark42.html index 8ab159e..f17e91d 100644 --- a/_includes/comments/remark42.html +++ b/_includes/comments/remark42.html @@ -6,7 +6,7 @@ max_shown_comments: 10, // theme: 'light', - theme: document.documentElement.hasAttribute("data-mode")? "dark": "light", + theme: document.documentElement.hasAttribute("data-mode") ? "dark" : "light", locale: 'en', show_email_subscription: false @@ -22,7 +22,19 @@ } })(remark_config.components || ['embed']); + var targetDiv = document.getElementById("sidebar").getElementsByClassName("mode-toggle")[0]; + + if (targetDiv != null) { + targetDiv.addEventListener("click", () => { + if (document.documentElement.hasAttribute("data-mode")) { + window.REMARK42.changeTheme('dark'); + } else { + window.REMARK42.changeTheme('light'); + } + }) + } +
-
+ \ No newline at end of file