_website: Fix placement of script (again).

This commit is contained in:
Qi Xiao 2018-11-04 21:03:32 +00:00
parent 7421828e1c
commit adb2340aed

View File

@ -68,6 +68,20 @@
This snippet can be generated by contentIs("article").
*/}}
{{ template "content" . }}
<script>
// If the domain starts with "dark.", trigger dark mode.
if (location.hostname.startsWith('dark.')) {
document.body.classList.add('dark');
}
// Pressing d triggers dark mode. This is useful for debugging.
window.addEventListener('keypress', function(ev) {
if (String.fromCodePoint(ev.keyCode || ev.charCode) == 'd') {
document.body.classList.toggle('dark');
}
});
</script>
</body>
</html>
@ -112,18 +126,4 @@
{{ end }}
</ul>
</div>
<script>
// If the domain starts with "dark.", trigger dark mode.
if (location.hostname.startsWith('dark.')) {
document.body.classList.add('dark');
}
// Pressing d triggers dark mode. This is useful for debugging.
window.addEventListener('keypress', function(ev) {
if (String.fromCodePoint(ev.keyCode || ev.charCode) == 'd') {
document.body.classList.toggle('dark');
}
});
</script>
{{ end }}