Skip to content

Commit a6facf1

Browse files
committed
Updated
1 parent 9a5e411 commit a6facf1

File tree

2 files changed

+58
-55
lines changed

2 files changed

+58
-55
lines changed

site/_layouts/default.html

Lines changed: 55 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,61 @@
11
<!DOCTYPE html>
22
<html lang="en">
3-
<head>
4-
<meta charset="UTF-8" />
5-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6-
<title>{{ page.title }}</title>
7-
<link rel="stylesheet" href="{{ "/assets/style.css" | relative_url }}">
8-
<script>
9-
function toggleSidebar() {
10-
const sidebar = document.getElementById("sidebar");
11-
sidebar.classList.toggle("hidden");
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>{{ page.title }}</title>
7+
<link rel="stylesheet" href="{{ "/assets/style.css" | relative_url }}">
8+
9+
<!-- Dark Mode Toggle Button -->
10+
<style>
11+
.dark-toggle {
12+
position: fixed;
13+
top: 1rem;
14+
right: 1rem;
15+
z-index: 1000;
16+
background: var(--sidebar-bg);
17+
color: var(--text-color);
18+
border: none;
19+
padding: 0.5rem 0.75rem;
20+
border-radius: 8px;
21+
cursor: pointer;
22+
font-size: 1.2rem;
23+
box-shadow: 0 0 10px rgba(0,0,0,0.1);
24+
transition: background 0.3s ease;
25+
}
26+
</style>
27+
28+
<script>
29+
const toggleDarkMode = () => {
30+
document.body.classList.toggle('dark-mode');
31+
localStorage.setItem('dark-mode', document.body.classList.contains('dark-mode'));
32+
};
33+
34+
window.onload = () => {
35+
if (localStorage.getItem('dark-mode') === 'true') {
36+
document.body.classList.add('dark-mode');
1237
}
13-
</script>
14-
<script>
15-
const toggleDarkMode = () => {
16-
document.body.classList.toggle('dark-mode');
17-
localStorage.setItem('dark-mode', document.body.classList.contains('dark-mode'));
18-
};
38+
};
39+
40+
function toggleSidebar() {
41+
const sidebar = document.getElementById("sidebar");
42+
sidebar.classList.toggle("hidden");
43+
}
44+
</script>
45+
</head>
46+
47+
<body>
48+
<button class="dark-toggle" onclick="toggleDarkMode()">🌓</button>
1949

20-
window.onload = () => {
21-
if (localStorage.getItem('dark-mode') === 'true') {
22-
document.body.classList.add('dark-mode');
23-
}
24-
};
25-
</script>
26-
<button onclick="toggleDarkMode()" style="position: fixed; top: 1rem; right: 1rem;">🌓</button>
50+
<div class="wrapper">
51+
<div id="sidebar" class="sidebar">
52+
{% include nav.html %}
53+
</div>
2754

28-
</head>
29-
<body>
30-
<div class="wrapper">
31-
<div id="sidebar" class="sidebar">
32-
{% include nav.html %}
33-
</div>
34-
<div class="content">
35-
<button class="toggle-btn" onclick="toggleSidebar()"></button>
36-
{{ content }}
37-
</div>
38-
</div>
39-
</body>
55+
<div class="content fade-in">
56+
<button class="toggle-btn" onclick="toggleSidebar()"></button>
57+
{{ content }}
58+
</div>
59+
</div>
60+
</body>
4061
</html>

site/assets/style.css

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ body {
6060
6161
6262
*/
63-
6463
:root {
6564
--bg-color: #ffffff;
6665
--text-color: #000000;
@@ -80,21 +79,14 @@ body {
8079
color: var(--text-color);
8180
}
8281

83-
.sidebar {
84-
background-color: var(--sidebar-bg);
85-
}
86-
87-
a {
88-
color: var(--link-color);
89-
}
90-
9182
.sidebar {
9283
width: 260px;
9384
padding: 1rem;
9485
position: fixed;
9586
height: 100vh;
9687
overflow-y: auto;
9788
border-right: 1px solid #ccc;
89+
background-color: var(--sidebar-bg);
9890
transition: all 0.3s ease;
9991
}
10092

@@ -104,23 +96,13 @@ a {
10496
margin-bottom: 0.5rem;
10597
border-radius: 0.5rem;
10698
text-decoration: none;
99+
color: var(--link-color);
107100
}
108101

109102
.sidebar a:hover {
110103
background-color: rgba(0, 0, 0, 0.05);
111104
}
112105

113-
<style>
114106
.fade-in {
115107
animation: fadeIn 0.4s ease-in;
116-
}
117-
118-
@keyframes fadeIn {
119-
from { opacity: 0; transform: translateY(10px); }
120-
to { opacity: 1; transform: translateY(0); }
121-
}
122-
</style>
123-
124-
<div class="content fade-in">
125-
{{ content }}
126-
</div>
108+
}

0 commit comments

Comments
 (0)