Aiden Bai
2022-05-03 8d092a3a4aca9561f3ac852e01518f48c8ef68fe
layouts/partials/head.html
@@ -58,6 +58,7 @@
          content,
        }))
  </script>
  {{if $.Site.Data.config.enableSPA}}
  <script type="module">
    import { router, navigate } from "https://unpkg.com/million/dist/router.mjs";
    // SPA navigation for access later
@@ -65,7 +66,7 @@
    // We only mutate document.title and content within .singlePage element
    router(".singlePage");
    const callback = () => {
      // requestAnimationFrame()
      // requestAnimationFrame() delays graph draw until SPA routing is finished
      const draw = () => {
        const container = document.getElementById("graph-container");
        // retry if the graph is not ready
@@ -74,7 +75,6 @@
        container.textContent = "";
        drawGraph(
          {{strings.TrimRight "/" .Page.Permalink}},
          {{strings.TrimRight "/" .Site.BaseURL}},
          {{$.Site.Data.graphConfig.paths}},
          {{$.Site.Data.graphConfig.depth}},
@@ -89,5 +89,8 @@
    window.addEventListener("million:navigate", callback);
    window.addEventListener("DOMContentLoaded", callback);
  </script>
  {{else}}
  <script>window.navigate = (url) => window.location.href = url</script>
  {{end}}
</head>
{{ template "_internal/google_analytics.html" . }}