summaryrefslogtreecommitdiffstats
path: root/layouts/partials/scripts-front.html
blob: 9fa99b6192516eb5d5b14c90f8ae67c691d7dce1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<script data-cfasync="false">
    // detect theme data in localStorage
    // change the data-theme attribute of body
    var fujiThemeData = localStorage.getItem('fuji_theme');
    if (fujiThemeData) {
        if ($('body').attr('data-theme') !== fujiThemeData) {
            $('body').attr('data-theme', (index, attr) => {
                if (fujiThemeData === 'dark') {
                    return 'dark';
                } else {
                    return 'light';
                }
            });
        }
    } else {
        localStorage.setItem('fuji_theme', $('body').attr('data-theme'));
    }
</script>