Skip to content

Commit

Permalink
fix: first load of comments isn't with right theme
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryrden committed Jul 10, 2024
1 parent cf0f5a9 commit f4f1188
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions _includes/comments.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,13 @@
data-loading="lazy"
crossorigin="anonymous"
async>
</script>
<script>
// Check if the user has a preferred theme set in local storage
let theme = localStorage.getItem('theme') || (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light');
theme = theme === 'dark' ? "{{ site.giscus.dark_theme }}" : "{{ site.giscus.light_theme }}";
const existingGiscus = document.querySelector('script[src="https://giscus.app/client.js"]');
if (existingGiscus) {
existingGiscus.setAttribute('data-theme', theme);
}
</script>

0 comments on commit f4f1188

Please sign in to comment.