remark42 theme change automatically when chripy theme changes

This commit is contained in:
Bangara Raju Kottedi 2023-07-23 04:38:03 +05:30
parent feda9f8675
commit bb07412482

View File

@ -6,7 +6,7 @@
max_shown_comments: 10, max_shown_comments: 10,
// theme: 'light', // theme: 'light',
theme: document.documentElement.hasAttribute("data-mode")? "dark": "light", theme: document.documentElement.hasAttribute("data-mode") ? "dark" : "light",
locale: 'en', locale: 'en',
show_email_subscription: false show_email_subscription: false
@ -22,7 +22,19 @@
} }
})(remark_config.components || ['embed']); })(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');
}
})
}
</script> </script>
<div id="remark42"> <div id="remark42">
</div> </div>