File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3434 {{ #each site.feeds }}
3535 <link rel =" alternate" href =" /{{ ../site.locale }} /{{ link }} " title =" {{ text }} " type =" application/rss+xml" >
3636 {{ /each }}
37+
38+ <script src =" /static/js/themeSwitcher.js" ></script >
3739</head >
Original file line number Diff line number Diff line change 4848; ( function ( ) {
4949 const themeAttr = 'data-theme'
5050 var darkThemeSwitcherElement = document . querySelector ( '.dark-theme-switcher' )
51- var isInDarkMode = window . matchMedia && window . matchMedia ( '(prefers-color-scheme: dark)' ) . matches
52-
53- if ( getTheme ( ) == null ) {
54- setTheme ( isInDarkMode ? 'dark' : 'light' )
55- } else {
56- setTheme ( getTheme ( ) )
57- }
5851
5952 darkThemeSwitcherElement . addEventListener ( 'click' , function ( ) {
6053 var currentTheme = getTheme ( )
Original file line number Diff line number Diff line change 1+ ; ( function ( ) {
2+ const themeAttr = 'data-theme'
3+ const isInDarkMode = window . matchMedia && window . matchMedia ( '(prefers-color-scheme: dark)' ) . matches
4+
5+ if ( getTheme ( ) == null ) {
6+ setTheme ( isInDarkMode ? 'dark' : 'light' )
7+ } else {
8+ setTheme ( getTheme ( ) )
9+ }
10+
11+ function setTheme ( theme ) {
12+ document . querySelector ( 'html' ) . setAttribute ( themeAttr , theme )
13+ window . localStorage . setItem ( 'theme' , theme )
14+ }
15+
16+ function getTheme ( ) {
17+ return window . localStorage . getItem ( 'theme' )
18+ }
19+ } ) ( )
You can’t perform that action at this time.
0 commit comments