eventually-inconsistent/layouts/partials/comments.html
Felipe Cotti 158d050d00
Some checks failed
Deploy Eventually (In)Consistent / build-and-deploy (push) Has been cancelled
Improve a little bit how light/dark theme is inferred, perhaps.
2025-02-25 20:25:39 -03:00

24 lines
804 B
HTML

<script defer src="https://comentario.cotti.com.br/comentario.js"></script>
<comentario-comments></comentario-comments>
<noscript>Please enable JavaScript to view comments.</noscript>
<script>
function detectTheme() {
const storedTheme = localStorage.getItem("theme");
if (storedTheme === "dark" || storedTheme === "light") {
return storedTheme;
}
if (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches) {
return "dark";
}
return "light";
}
const comentarioComments = document.getElementsByTagName("comentario-comments");
const theme = detectTheme();
for (const commentElement of comentarioComments) {
commentElement.setAttribute("theme", theme);
}
</script>