Skip to content

Commit f45e058

Browse files
committed
Support navigation loader on localhost
1 parent 0d6bc56 commit f45e058

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

docs/dokka-presets/scripts/custom-navigation-loader.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,15 @@ function extractModulePath(href) {
1616

1717
// the URL pattern is always ".../kotlin/api/<version>/..."
1818
const apiIndex = segments.indexOf('api');
19-
if (apiIndex === -1) return null;
2019

21-
// segment after "api" is the version ("latest", "1.4.109", etc.)
22-
// segment after _that_ is the module name (or "index.html" if we're at the root)
23-
return segments[apiIndex + 2] ?? 'index.html';
20+
if (apiIndex !== -1) {
21+
// segment after "api" is the version ("latest", "1.4.109", etc.)
22+
// segment after _that_ is the module name (or "index.html" if we're at the root)
23+
return segments[apiIndex + 2] ?? 'index.html';
24+
}
25+
26+
// locally-hosted docs don't have /kotlin/api segment
27+
return segments[0] ?? 'index.html';
2428
} catch {
2529
return null;
2630
}

0 commit comments

Comments
 (0)