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 | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/assets/js/graph.js b/assets/js/graph.js
index c32035d..e1bbbeb 100644
--- a/assets/js/graph.js
+++ b/assets/js/graph.js
@@ -1,5 +1,4 @@
async function drawGraph(
- _url,
baseUrl,
pathColors,
depth,
@@ -8,9 +7,13 @@
enableZoom
) {
const container = document.getElementById('graph-container')
-
const { index, links, content } = await fetchData
- const curPage = window.location.href.replace(baseUrl, '').slice(0, -1)
+
+ const rawUrl = new URL(window.location.href);
+ // Use .pathname to remove hashes / searchParams / text fragments
+ 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