theme blink bug fixed

This commit is contained in:
zzossig 2019-11-25 09:51:48 +09:00
parent e050e0f374
commit b82244ab9b
2 changed files with 6 additions and 1 deletions

View File

@ -2,7 +2,6 @@ $(document).ready(function() {
// theme change // theme change
var localTheme = localStorage.getItem('theme'); var localTheme = localStorage.getItem('theme');
if (localTheme) { if (localTheme) {
$('#root').attr('class', `theme__${localTheme}`);
$('.select-theme__item').each(function () { $('.select-theme__item').each(function () {
$(this).removeClass('is-active'); $(this).removeClass('is-active');
}); });

View File

@ -13,6 +13,12 @@
</head> </head>
<body id="root" class="theme__{{ index .Site.Params.themeOptions 0 }}"> <body id="root" class="theme__{{ index .Site.Params.themeOptions 0 }}">
<script>
var localTheme = localStorage.getItem('theme');
if (localTheme) {
document.getElementById('root').className = `theme__${localTheme}`;
}
</script>
<div id="body"> <div id="body">
<div class="container wrapper"> <div class="container wrapper">
{{ partial "navbar/site-nav" . }} {{ partial "navbar/site-nav" . }}