File tree Expand file tree Collapse file tree 6 files changed +46
-42
lines changed Expand file tree Collapse file tree 6 files changed +46
-42
lines changed Original file line number Diff line number Diff line change 33
33
34
34
<link rel="stylesheet" href="/static/styles.css" />
35
35
36
- <script>
37
- const runColorMode = (fn) => {
38
- let theme = localStorage.getItem("theme");
39
- if (theme) {
40
- document.documentElement.className = theme;
41
- document.getElementById("themes").value = theme;
42
- return;
43
- }
44
-
45
- <!-- if media queries are not ussported use this as the default theme -->
46
- if (!window.matchMedia) {
47
- document.documentElement.className = "theme-dark";
48
- }
49
-
50
- const query = window.matchMedia("(prefers-color-scheme: dark)");
51
-
52
- fn(query.matches);
53
-
54
- query.addEventListener("change", (event) => fn(event.matches));
55
- localStorage.setItem("theme", document.documentElement.className);
56
- };
57
-
58
- const isDarkMode = () =>
59
- window.matchMedia &&
60
- window.matchMedia("(prefers-color-scheme: dark)").matches;
61
-
62
- runColorMode((isDarkMode) => {
63
- document.documentElement.className = isDarkMode
64
- ? "theme-dark"
65
- : "theme-light";
66
- });
67
- </script>
36
+ <script>{%include "partials/script.js" %}</script>
68
37
69
38
{% block additionalhead %} {% endblock %}
70
39
</head>
Original file line number Diff line number Diff line change 37
37
<button id="copybtn">Copy</button>
38
38
</div>
39
39
</div>
40
+ {% endblock %}
40
41
42
+ {% block additionalfoot %}
41
43
<script>
42
- document.getElementById("copybtn").addEventListener("click", () => {
43
- const codeToCopy = document.getElementById("copy").value;
44
- navigator.clipboard.writeText(codeToCopy);
45
- });
44
+ document.getElementById("copybtn").addEventListener("click", () => {
45
+ const codeToCopy = document.getElementById("copy").value;
46
+ navigator.clipboard.writeText(codeToCopy);
47
+ });
46
48
</script>
47
49
{% endblock %}
Original file line number Diff line number Diff line change 96
96
<script src="https://unpkg.com/@highlightjs/cdn-assets@11.9.0/languages/nix.min.js"></script>
97
97
<script>
98
98
hljs.highlightAll();
99
- </script>
100
99
101
- <script>
102
100
const codeblocks = document.querySelectorAll('div.codeblock');
103
101
104
102
codeblocks.forEach((block) => {
Original file line number Diff line number Diff line change 1
1
<footer>
2
2
<span class="align-footer">
3
- <a href="https://ctp-webr.ing/isabelroses/previous"><svg xmlns="http://www.w3.org/2000/svg" class="icon" viewBox="0 0 448 512"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M9.4 233.4c-12.5 12.5-12.5 32.8 0 45.3l160 160c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L109.2 288 416 288c17.7 0 32-14.3 32-32s-14.3-32-32-32l-306.7 0L214.6 118.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-160 160z"/></svg></a>
4
- <a href="https://ctp-webr.ing/"><svg xmlns="http://www.w3.org/2000/svg" class="icon" viewBox="0 0 448 512"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M418.4 157.9c35.3-8.3 61.6-40 61.6-77.9c0-44.2-35.8-80-80-80c-43.4 0-78.7 34.5-80 77.5L136.2 151.1C121.7 136.8 101.9 128 80 128c-44.2 0-80 35.8-80 80s35.8 80 80 80c12.2 0 23.8-2.7 34.1-7.6L259.7 407.8c-2.4 7.6-3.7 15.8-3.7 24.2c0 44.2 35.8 80 80 80s80-35.8 80-80c0-27.7-14-52.1-35.4-66.4l37.8-207.7zM156.3 232.2c2.2-6.9 3.5-14.2 3.7-21.7l183.8-73.5c3.6 3.5 7.4 6.7 11.6 9.5L317.6 354.1c-5.5 1.3-10.8 3.1-15.8 5.5L156.3 232.2z"/></svg></a>
5
- <a href="https://ctp-webr.ing/isabelroses/next"><svg xmlns="http://www.w3.org/2000/svg" class="icon" viewBox="0 0 448 512"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M438.6 278.6c12.5-12.5 12.5-32.8 0-45.3l-160-160c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L338.8 224 32 224c-17.7 0-32 14.3-32 32s14.3 32 32 32l306.7 0L233.4 393.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l160-160z"/></svg></a>
3
+ <a href="https://ctp-webr.ing/isabelroses/previous" aria-label="previous catppuccin webring" ><svg xmlns="http://www.w3.org/2000/svg" class="icon" viewBox="0 0 448 512"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M9.4 233.4c-12.5 12.5-12.5 32.8 0 45.3l160 160c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L109.2 288 416 288c17.7 0 32-14.3 32-32s-14.3-32-32-32l-306.7 0L214.6 118.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-160 160z"/></svg></a>
4
+ <a href="https://ctp-webr.ing/" aria-label="catppuccin webring" ><svg xmlns="http://www.w3.org/2000/svg" class="icon" viewBox="0 0 448 512"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M418.4 157.9c35.3-8.3 61.6-40 61.6-77.9c0-44.2-35.8-80-80-80c-43.4 0-78.7 34.5-80 77.5L136.2 151.1C121.7 136.8 101.9 128 80 128c-44.2 0-80 35.8-80 80s35.8 80 80 80c12.2 0 23.8-2.7 34.1-7.6L259.7 407.8c-2.4 7.6-3.7 15.8-3.7 24.2c0 44.2 35.8 80 80 80s80-35.8 80-80c0-27.7-14-52.1-35.4-66.4l37.8-207.7zM156.3 232.2c2.2-6.9 3.5-14.2 3.7-21.7l183.8-73.5c3.6 3.5 7.4 6.7 11.6 9.5L317.6 354.1c-5.5 1.3-10.8 3.1-15.8 5.5L156.3 232.2z"/></svg></a>
5
+ <a href="https://ctp-webr.ing/isabelroses/next" aria-label="license-text catppuccin webring" ><svg xmlns="http://www.w3.org/2000/svg" class="icon" viewBox="0 0 448 512"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M438.6 278.6c12.5-12.5 12.5-32.8 0-45.3l-160-160c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L338.8 224 32 224c-17.7 0-32 14.3-32 32s14.3 32 32 32l306.7 0L233.4 393.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l160-160z"/></svg></a>
6
6
</span>
7
7
8
8
<ul class="align-footer">
Original file line number Diff line number Diff line change 16
16
name="themes"
17
17
id="themes"
18
18
aria-label="Change theme"
19
- onchange="document.documentElement.className = this.value; localStorage.setItem('theme', this.value);"
20
19
>
21
20
<option value="theme-dark">Dark</option>
22
21
<option value="theme-light">Light</option>
Original file line number Diff line number Diff line change
1
+ // set theme on intial load
2
+ setTheme ( getTheme ( ) ) ;
3
+
4
+ document . addEventListener ( "DOMContentLoaded" , ( ) => {
5
+ const themes = document . getElementById ( "themes" ) ;
6
+
7
+ setTheme ( getTheme ( ) ) ;
8
+
9
+ themes . addEventListener ( "change" , ( event ) => {
10
+ setTheme ( event . target . value ) ;
11
+ } ) ;
12
+ } ) ;
13
+
14
+ function setTheme ( theme ) {
15
+ localStorage . setItem ( "theme" , theme ) ;
16
+ document . documentElement . className = theme ;
17
+
18
+ const themes = document . getElementById ( "themes" ) ;
19
+ if ( themes ) {
20
+ themes . value = theme ;
21
+ }
22
+ }
23
+
24
+ function getTheme ( ) {
25
+ const theme = localStorage . getItem ( "theme" ) ;
26
+
27
+ if ( theme ) return theme ;
28
+
29
+ if ( ! window . matchMedia ) return "theme-dark" ;
30
+
31
+ if ( window . matchMedia ( "(prefers-color-scheme: dark)" ) . matches ) {
32
+ return "theme-dark" ;
33
+ } else {
34
+ return "theme-light" ;
35
+ }
36
+ }
You can’t perform that action at this time.
0 commit comments