summaryrefslogtreecommitdiffstats
path: root/templates_html/base.html
blob: dd893f5004de74a3829e93ddca1a6c6daef49479 (plain)
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
    <head>
        <meta charset="utf-8" />
        <meta name="generator" content="pandoc" />
        <meta
            name="viewport"
            content="width=device-width, initial-scale=1.0, user-scalable=yes"
        />
        <link rel="shortcut icon" type="image/png" href="/favicon.png" />
        <meta
            name="author"
            content="{{ page.author | default(value=config.author) }}"
        />

        {% if page.date %}
        <meta name="dcterms.date" content="{{ page.date }}" />
        {% endif %}

        {% if page.extra.keywords %}
        <meta
            name="keywords"
            content="{{ page.extra.keywords | join(sep=', ') }}"
        />
        {% endif %}

        {% block title %}
        {% if page.title %}
        <title>{{ page.title }} — {{ config.title }}</title>
        {% elif section.title %}
        <title>{{ section.title }} — {{ config.title }}</title>
        {% else %}
        <title>{{ config.title }}</title>
        {% endif %}
        {% endblock %}

        {% block description %}
        {% if page.description %}
        <meta name="description" content="{{ page.description }}" />
        {% elif page.summary %}
        <meta name="description" content="{{ page.summary | striptags }}" />
        {% else %}
        <meta name="description" content="{{ config.description }}" />
        {% endif %}
        {% endblock %}

        <style>
            @font-face {
                font-family: "PT Sans";
                src: url("/PTSans-Regular.ttf") format("truetype");
                font-weight: normal;
                font-style: normal;
            }

            @font-face {
                font-family: "PT Sans";
                src: url("/PTSans-Bold.ttf") format("truetype");
                font-weight: bold;
                font-style: normal;
            }

            @font-face {
                font-family: "PT Sans";
                src: url("/PTSans-Italic.ttf") format("truetype");
                font-weight: normal;
                font-style: italic;
            }

            @font-face {
                font-family: "PT Sans";
                src: url("/PTSans-BoldItalic.ttf") format("truetype");
                font-weight: bold;
                font-style: italic;
            }
        </style>
        <link rel="stylesheet" href="/style.css" />

        <link
            rel="alternate"
            type="application/atom+xml"
            title="Atom Feed for jan.systems"
            href="/atom.xml"
        />

        <link rel="authorization_endpoint" href="https://indieauth.com/auth" />
    </head>
    <body>
        <div class="header-row">
            <a class="page-title" href="/">Jan Sydänviita (né Tuomi)</a>
            <div id="dark-mode-btn"></div>
        </div>
        <nav>
            <a href="/posts">posts</a>
            <span aria-hidden="true"> &#x2022; </span>
            <a href="/linklog">linklog</a>
            <span aria-hidden="true"> &#x2022; </span>
            <a href="/now">now</a>
            <span aria-hidden="true"> &#x2022; </span>
            <a href="/projects">projects</a>
        </nav>

        <main>{% block content %}{% endblock %}</main>

        <script>
            const b = document.createElement("button");
            b.innerHTML = "🌓";
            b.setAttribute("id", "dark-mode-btn");
            b.setAttribute("aria-label", "Toggle dark mode");
            document.querySelector("#dark-mode-btn").replaceWith(b);

            const initialManualColorScheme =
                localStorage.getItem("colorScheme");
            // If null, no manual color scheme is set
            if (initialManualColorScheme === "dark") {
                document.body.parentElement.classList.add("dark");
            } else if (initialManualColorScheme === "light") {
                document.body.parentElement.classList.add("light");
            }

            function getCurrentManualColorScheme() {
                if (document.body.parentElement.classList.contains("dark"))
                    return "dark";
                if (document.body.parentElement.classList.contains("light"))
                    return "light";
                return null;
            }

            document
                .querySelector("#dark-mode-btn")
                .addEventListener("click", function () {
                    const manualColorScheme = getCurrentManualColorScheme();
                    const userPreferenceIsDark =
                        window.matchMedia &&
                        window.matchMedia("(prefers-color-scheme: dark)")
                            .matches;

                    const currentColorScheme =
                        manualColorScheme ??
                        (userPreferenceIsDark ? "dark" : "light");
                    const newColorScheme =
                        currentColorScheme === "dark" ? "light" : "dark";

                    document.body.parentElement.classList.remove(
                        "dark",
                        "light",
                    );
                    document.body.parentElement.classList.add(newColorScheme);

                    localStorage.setItem("colorScheme", newColorScheme);
                });
        </script>

        <div style="display: none" class="h-card">
            <a class="u-url" href="https://jan.systems">jan.systems</a>
            <a class="u-url" href="https://github.com/jantuomi" rel="me"
                >GitHub</a
            >
            <p class="p-note">
                Minimalist, digital gardener, senior software engineer.
            </p>
            <img
                class="u-photo"
                src="https://jan.systems/files/Jan_Tuomi_headshot.jpg"
                loading="lazy"
            />
            <p class="p-name">Jan Sydänviita (né Tuomi)</p>
            <p class="p-nickname">@jantuomi</p>
            <p class="p-country-name">Finland</p>
        </div>
    </body>
</html>