Skip to content

Commit 2569ab2

Browse files
committed
Compute offset for listings when attempting to find nearest
Fixes #953
1 parent eb0b1ac commit 2569ab2

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/resources/formats/html/quarto.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,17 @@ window.document.addEventListener("DOMContentLoaded", function (_event) {
168168
return response.json().then(function (listingPaths) {
169169
const listingHrefs = [];
170170
for (const listingPath of listingPaths) {
171+
const pathWithoutLeadingSlash = listingPath.listing.substring(1);
171172
for (const item of listingPath.items) {
172173
if (item === thisPath || item === thisPath + "index.html") {
173-
listingHrefs.push(listingPath.listing);
174+
// Resolve this path against the offset to be sure
175+
// we already are using the correct path to the listing
176+
// (this adjusts the listing urls to be rooted against
177+
// whatever root the page is actually running against)
178+
const relative = offsetRelativeUrl(pathWithoutLeadingSlash);
179+
const baseUrl = window.location;
180+
const resolvedPath = new URL(relative, baseUrl);
181+
listingHrefs.push(resolvedPath.pathname);
174182
break;
175183
}
176184
}

0 commit comments

Comments
 (0)