From 8d092a3a4aca9561f3ac852e01518f48c8ef68fe Mon Sep 17 00:00:00 2001
From: Aiden Bai <aiden.bai05@gmail.com>
Date: Tue, 03 May 2022 16:22:51 +0000
Subject: [PATCH] Remove unnecessary 'url' argument in graph.html

---
 layouts/partials/head.html |   18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/layouts/partials/head.html b/layouts/partials/head.html
index ea67a00..93051cb 100644
--- a/layouts/partials/head.html
+++ b/layouts/partials/head.html
@@ -21,10 +21,13 @@
     href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&family=Source+Sans+Pro:wght@400;600;700&family=Fira+Code:wght@400;700&display=swap"
     rel="stylesheet"
   />
-  {{$sass := resources.Match "styles/[!_]*.scss" }} {{$css := slice }} {{range
-  $sass}} {{$scss := . | resources.ToCSS (dict "outputStyle" "compressed") }}
-  {{$css = $css | append $scss}} {{end}} {{$finalCss := $css | resources.Concat
-  "styles.css" | resources.Fingerprint "md5" | resources.Minify }}
+  {{$sass := resources.Match "styles/[!_]*.scss" }}
+  {{$css := slice }}
+  {{range $sass}}
+  {{$scss := . | resources.ToCSS (dict "outputStyle" "compressed") }}
+  {{$css = $css | append $scss}}
+  {{end}}
+  {{$finalCss := $css | resources.Concat "styles.css" | resources.Fingerprint "md5" | resources.Minify  }}
   <link href="{{$finalCss.Permalink}}" rel="stylesheet" />
 
   {{ $darkMode := resources.Get "js/darkmode.js" | resources.Fingerprint "md5" |
@@ -55,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
@@ -62,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
@@ -71,7 +75,6 @@
         container.textContent = "";
 
         drawGraph(
-          {{strings.TrimRight "/" .Page.Permalink}},
           {{strings.TrimRight "/" .Site.BaseURL}},
           {{$.Site.Data.graphConfig.paths}},
           {{$.Site.Data.graphConfig.depth}},
@@ -86,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" . }}

--
Gitblit v1.10.0