Skip to content

Commit 37a5e3f

Browse files
committed
chore: Fixing polkadot navigation
1 parent b2d9b5e commit 37a5e3f

File tree

3 files changed

+77
-62
lines changed

3 files changed

+77
-62
lines changed

src/components/layout/docs-layout-client.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ export function DocsLayoutClient({ children }: DocsLayoutClientProps) {
4040
? new Set(["/stellar-contracts", "/monitor", "/relayer"])
4141
: new Set(["/stellar-contracts"]);
4242

43+
// Include shared paths in Polkadot tab only if coming from Polkadot context
44+
const polkadotUrls =
45+
isSharedPath && lastEcosystem === "polkadot"
46+
? new Set(["/substrate-runtimes", "/monitor"])
47+
: new Set(["/substrate-runtimes"]);
48+
4349
return [
4450
{
4551
title: "Ethereum & EVM",
@@ -83,6 +89,7 @@ export function DocsLayoutClient({ children }: DocsLayoutClientProps) {
8389
title: "Polkadot",
8490
url: "/substrate-runtimes",
8591
icon: <PolkadotIcon className="w-5 h-5" />,
92+
urls: polkadotUrls,
8693
},
8794
{
8895
title: "Uniswap Hooks",

src/hooks/use-navigation-tree.ts

Lines changed: 66 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -3,75 +3,79 @@
33
import { usePathname } from "next/navigation";
44
import { useEffect } from "react";
55
import {
6-
arbitrumStylusTree,
7-
ethereumEvmTree,
8-
midnightTree,
9-
polkadotTree,
10-
starknetTree,
11-
stellarTree,
12-
uniswapTree,
13-
zamaTree,
6+
arbitrumStylusTree,
7+
ethereumEvmTree,
8+
midnightTree,
9+
polkadotTree,
10+
starknetTree,
11+
stellarTree,
12+
uniswapTree,
13+
zamaTree,
1414
} from "@/navigation";
1515

1616
export function useNavigationTree() {
17-
const pathname = usePathname();
17+
const pathname = usePathname();
1818

19-
// Track ecosystem changes in sessionStorage
20-
useEffect(() => {
21-
if (typeof window === "undefined") return;
19+
// Track ecosystem changes in sessionStorage
20+
useEffect(() => {
21+
if (typeof window === "undefined") return;
2222

23-
if (pathname.startsWith("/stellar-contracts")) {
24-
sessionStorage.setItem("lastEcosystem", "stellar");
25-
} else if (
26-
pathname.startsWith("/contracts") ||
27-
pathname.startsWith("/community-contracts") ||
28-
pathname.startsWith("/upgrades-plugins") ||
29-
pathname.startsWith("/wizard") ||
30-
pathname.startsWith("/ui-builder") ||
31-
pathname.startsWith("/upgrades") ||
32-
pathname.startsWith("/defender") ||
33-
pathname.startsWith("/tools")
34-
) {
35-
sessionStorage.setItem("lastEcosystem", "ethereum");
36-
}
37-
}, [pathname]);
23+
if (pathname.startsWith("/stellar-contracts")) {
24+
sessionStorage.setItem("lastEcosystem", "stellar");
25+
} else if (pathname.startsWith("/substrate-runtimes")) {
26+
sessionStorage.setItem("lastEcosystem", "polkadot");
27+
} else if (
28+
pathname.startsWith("/contracts") ||
29+
pathname.startsWith("/community-contracts") ||
30+
pathname.startsWith("/upgrades-plugins") ||
31+
pathname.startsWith("/wizard") ||
32+
pathname.startsWith("/ui-builder") ||
33+
pathname.startsWith("/upgrades") ||
34+
pathname.startsWith("/defender") ||
35+
pathname.startsWith("/tools")
36+
) {
37+
sessionStorage.setItem("lastEcosystem", "ethereum");
38+
}
39+
}, [pathname]);
3840

39-
// Determine which navigation tree to use based on the current path
40-
if (pathname.startsWith("/contracts-stylus")) {
41-
return arbitrumStylusTree;
42-
} else if (pathname.startsWith("/contracts-cairo")) {
43-
return starknetTree;
44-
} else if (pathname.startsWith("/stellar-contracts")) {
45-
return stellarTree;
46-
} else if (pathname.startsWith("/contracts-compact")) {
47-
return midnightTree;
48-
} else if (pathname.startsWith("/confidential-contracts")) {
49-
return zamaTree;
50-
} else if (pathname.startsWith("/uniswap-hooks")) {
51-
return uniswapTree;
52-
} else if (pathname.startsWith("/substrate-runtimes")) {
53-
return polkadotTree;
54-
} else if (pathname.startsWith("/tools")) {
55-
return ethereumEvmTree;
56-
}
41+
// Determine which navigation tree to use based on the current path
42+
if (pathname.startsWith("/contracts-stylus")) {
43+
return arbitrumStylusTree;
44+
} else if (pathname.startsWith("/contracts-cairo")) {
45+
return starknetTree;
46+
} else if (pathname.startsWith("/stellar-contracts")) {
47+
return stellarTree;
48+
} else if (pathname.startsWith("/contracts-compact")) {
49+
return midnightTree;
50+
} else if (pathname.startsWith("/confidential-contracts")) {
51+
return zamaTree;
52+
} else if (pathname.startsWith("/uniswap-hooks")) {
53+
return uniswapTree;
54+
} else if (pathname.startsWith("/substrate-runtimes")) {
55+
return polkadotTree;
56+
} else if (pathname.startsWith("/tools")) {
57+
return ethereumEvmTree;
58+
}
5759

58-
// For shared paths like /monitor and /relayer, check sessionStorage to see
59-
// which ecosystem was last active, defaulting to ethereumEvmTree
60-
if (typeof window !== "undefined") {
61-
const lastEcosystem = sessionStorage.getItem("lastEcosystem");
60+
// For shared paths like /monitor and /relayer, check sessionStorage to see
61+
// which ecosystem was last active, defaulting to ethereumEvmTree
62+
if (typeof window !== "undefined") {
63+
const lastEcosystem = sessionStorage.getItem("lastEcosystem");
6264

63-
if (pathname.startsWith("/monitor") || pathname.startsWith("/relayer")) {
64-
switch (lastEcosystem) {
65-
case "stellar":
66-
return stellarTree;
67-
case "ethereum":
68-
return ethereumEvmTree;
69-
default:
70-
return ethereumEvmTree;
71-
}
72-
}
73-
}
65+
if (pathname.startsWith("/monitor") || pathname.startsWith("/relayer")) {
66+
switch (lastEcosystem) {
67+
case "stellar":
68+
return stellarTree;
69+
case "polkadot":
70+
return polkadotTree;
71+
case "ethereum":
72+
return ethereumEvmTree;
73+
default:
74+
return ethereumEvmTree;
75+
}
76+
}
77+
}
7478

75-
// Default to ethereumEvmTree for other paths
76-
return ethereumEvmTree;
79+
// Default to ethereumEvmTree for other paths
80+
return ethereumEvmTree;
7781
}

src/navigation/polkadot.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,10 @@
354354
}
355355
]
356356
},
357+
{
358+
"type": "separator",
359+
"name": "Open Source Tools"
360+
},
357361
{
358362
"type": "folder",
359363
"name": "Monitor",

0 commit comments

Comments
 (0)