Skip to content

Commit 9c357bc

Browse files
committed
Navigation Types: Play nice with subfolder deploys
1 parent 2ce517f commit 9c357bc

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

demo/navigation-types/scripts.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@
55

66
import { useAutoTypes } from "../js/navigation.js";
77

8-
const basePath = window.location.pathname.startsWith("/demo") ? "/demo" : "";
8+
// Because this demo can be hosted anywhere (in a root, or a subfolder) we need to determine the basePath
9+
// that acts as as a prefix to the routes.
10+
const basePath = window.location.pathname.substring(
11+
0,
12+
window.location.pathname.indexOf("/navigation-types"),
13+
);
914
const routeMap = {
1015
index: `${basePath}/navigation-types/demo{.html}?`,
1116
detail: `${basePath}/navigation-types/detail/:id{.html}?`,

0 commit comments

Comments
 (0)