File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2828 <![endif]-->
2929
3030 < link rel ="stylesheet " href ="{{ "/assets/css/cookiealert.css" | prepend: site.baseurl }}">
31+
32+ < script src ="{{ "/assets/js/bootstrap-auto-dark-mode.js" | prepend: site.baseurl }}"> </ script >
33+
3134</ head >
Original file line number Diff line number Diff line change 33---
44
55<!DOCTYPE html>
6- < html lang ="en ">
6+ < html lang ="en " data-bs-theme =" auto " >
77
88 {% include head.html %}
99
Original file line number Diff line number Diff line change 1+ document . addEventListener ( 'DOMContentLoaded' , function ( ) {
2+ function toggleTheme ( ) {
3+ const html = document . documentElement ;
4+ const prefersDark = window . matchMedia ( '(prefers-color-scheme: dark)' ) . matches ;
5+ if ( prefersDark ) {
6+ html . setAttribute ( 'data-bs-theme' , 'dark' ) ;
7+ } else {
8+ html . setAttribute ( 'data-bs-theme' , 'light' ) ;
9+ }
10+ }
11+
12+ // Initial call to set the correct theme
13+ toggleTheme ( ) ;
14+
15+ // Listen for system theme changes
16+ window . matchMedia ( '(prefers-color-scheme: dark)' ) . addEventListener ( 'change' , toggleTheme ) ;
17+
18+ // Optionally, add a toggle button to allow manual switching
19+ // You would need to add a button to your HTML and handle the click event
20+ // to toggle the theme.
21+ } ) ;
You can’t perform that action at this time.
0 commit comments