-
Notifications
You must be signed in to change notification settings - Fork 126
Expand file tree
/
Copy pathlayout.html
More file actions
72 lines (66 loc) · 2.25 KB
/
layout.html
File metadata and controls
72 lines (66 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{ title|striptags|e }}</title>
<link rel="stylesheet" type="text/css"
href="{{ pathto('_static/style.css', true) }}">
<script>
// Dark mode initialization
(function() {
const savedTheme = localStorage.getItem('theme');
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
const shouldUseDark = savedTheme === 'dark' || (!savedTheme && prefersDark);
if (shouldUseDark) {
document.documentElement.classList.add('dark-mode');
}
})();
</script>
</head>
<body>
<div class="theme-toggle">
<button id="theme-toggle" aria-label="Toggle dark mode">
<span class="theme-icon">🌙</span>
</button>
</div>
{% if title != 'Python Design Patterns' %}
<p class="motto">
•
<a href="/">Home Page</a>
•
</p>
{% endif %}
<article>
{{ body }}
</article>
<hr>
<p class="copyright">
© 2018–2020 <a href="http://rhodesmill.org/brandon/">Brandon Rhodes</a>
</p>
<script>
// Dark mode toggle functionality
(function() {
const themeToggle = document.getElementById('theme-toggle');
const themeIcon = document.querySelector('.theme-icon');
function updateThemeIcon() {
const isDark = document.documentElement.classList.contains('dark-mode');
themeIcon.textContent = isDark ? '☀️' : '🌙';
}
function toggleTheme() {
const isDark = document.documentElement.classList.contains('dark-mode');
if (isDark) {
document.documentElement.classList.remove('dark-mode');
localStorage.setItem('theme', 'light');
} else {
document.documentElement.classList.add('dark-mode');
localStorage.setItem('theme', 'dark');
}
updateThemeIcon();
}
themeToggle.addEventListener('click', toggleTheme);
updateThemeIcon(); // Set initial icon
})();
</script>
</body>
</html>