blob: e2cb2a3c20e2a84ad0834bbaa1d8d9d664756c59 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
<header class="flex flex-row justify-between mb-6 px-3 pt-2">
<h1 class="mb-1">{{ .Site.Params.profile.name }}</h1>
<i
class="toggle-theme text-3xl cursor-pointer fas {{ if eq .Site.Params.theme `light` }}fa-moon{{ else }}fa-sun{{ end }} text-gray-600 hover:text-gray-800 dark:text-gray-500 dark:hover:text-gray-200"
onclick="toggleTheme(this)"
></i>
</header>
<script>
const toggleTheme = (el) => {
const html = document.querySelector("html");
if (el.classList.contains("fa-moon")) {
el.classList.remove("fa-moon");
el.classList.add("fa-sun");
html.classList.add("dark");
} else {
el.classList.remove("fa-sun");
el.classList.add("fa-moon");
html.classList.remove("dark");
}
};
</script>
|