From aaed5dc1f1849a54869743596a6133548e83392d Mon Sep 17 00:00:00 2001
From: Aiden Bai <aiden.bai05@gmail.com>
Date: Tue, 03 May 2022 17:54:39 +0000
Subject: [PATCH] Support /path root sites

---
 assets/js/graph.js |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/assets/js/graph.js b/assets/js/graph.js
index 5739acd..e1bbbeb 100644
--- a/assets/js/graph.js
+++ b/assets/js/graph.js
@@ -7,10 +7,13 @@
   enableZoom
 ) {
   const container = document.getElementById('graph-container')
-
   const { index, links, content } = await fetchData
+
+  const rawUrl = new URL(window.location.href);
   // Use .pathname to remove hashes / searchParams / text fragments
-  const curPage = window.location.pathname.replace(/\/$/g, "")
+  const cleanUrl = rawUrl.origin + rawUrl.pathname
+
+  const curPage = cleanUrl.replace(/\/$/g, "").replace(baseUrl, "")
 
   const parseIdsFromLinks = (links) => [
     ...new Set(links.flatMap((link) => [link.source, link.target])),

--
Gitblit v1.10.0