From b146d410d9d9ce10f81d065e8681f5d3c6cf4da7 Mon Sep 17 00:00:00 2001 From: Aiden Bai Date: Tue, 3 May 2022 10:54:39 -0700 Subject: [PATCH] Support /path root sites --- assets/js/graph.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/assets/js/graph.js b/assets/js/graph.js index 5739acdc..e1bbbebe 100644 --- a/assets/js/graph.js +++ b/assets/js/graph.js @@ -7,10 +7,13 @@ async function drawGraph( 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])),