Skip to content

Commit

Permalink
Fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
khang-nd committed Sep 26, 2024
1 parent 83a9a8f commit 4753150
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/.vuepress/components/AThemeToggle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ import DarkMode from "../utils/darkmode";
export default {
data() {
return {
isDark: DarkMode.isDarkMode(),
isDark: false,
label: "Toggle theme",
};
},
mounted() {
this.isDark = DarkMode.isDarkMode();
},
methods: {
toggle() {
this.isDark = !this.isDark;
Expand Down
2 changes: 2 additions & 0 deletions src/.vuepress/utils/darkmode.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const DarkMode = {
},

isDarkMode() {
if (typeof window === "undefined" || typeof localStorage === "undefined")
return false;
return localStorage.getItem(KEY) === "true";
},
};
Expand Down

0 comments on commit 4753150

Please sign in to comment.