summaryrefslogtreecommitdiff
path: root/site/themes/sine/layouts/partials/head.html
blob: e7c23e5095cdb52c1298f449036967fc21e92c50 (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
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />

<title>{{ if not .IsHome }}{{ .Title }} | {{ end }}{{ .Site.Title }}</title>

<!-- Scuffed fix for theme change flash -->
<script>
  // Run as early as possible
  (function() {
    const theme = localStorage.getItem("theme");
    const preloadClass = theme === "dark" ? "preload-dark" : "preload-light";

    // Add preload class to <html>
    document.documentElement.classList.add(preloadClass);

    // Wait for stylesheet(s) to load, then remove class
    window.addEventListener("load", function() {
      document.documentElement.classList.remove(preloadClass);
    });
  })();
</script>
<style>
  /* Temporary background colors before stylesheet is fully loaded */
  .preload-light * {
    background: #ffffff !important;
  }
  .preload-dark * {
    background: #161616 !important;
  }
</style>

<link rel="stylesheet" href="/css/style.css" type="text/css" media="all" />

{{ with .OutputFormats.Get "rss" -}}
  {{ printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }}
{{ end -}}