fix remark42 theme

This commit is contained in:
Dmitry Belyaev 2024-10-10 23:17:20 +03:00
parent c4088cb74a
commit 86a584e465
Signed by: b4tman
GPG Key ID: 41A00BF15EA7E5F3

View File

@ -10,6 +10,10 @@
theme: 'light' theme: 'light'
}; };
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
remark_config.theme = "dark";
}
(function(c) { (function(c) {
for(var i = 0; i < c.length; i++){ for(var i = 0; i < c.length; i++){
var d = document, s = d.createElement('script'); var d = document, s = d.createElement('script');
@ -18,6 +22,11 @@
(d.head || d.body).appendChild(s); (d.head || d.body).appendChild(s);
} }
})(remark_config.components || ['embed']); })(remark_config.components || ['embed']);
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => {
const newColorScheme = event.matches ? "dark" : "light";
window.REMARK42.changeTheme(newColorScheme);
});
</script> </script>
{{ end }} {{ end }}
{{ end }} {{ end }}