Skip to content

Commit d94e62b

Browse files
authored
fix sdk linking issues (stack-auth#783)
1 parent 018be1f commit d94e62b

File tree

2 files changed

+36
-19
lines changed

2 files changed

+36
-19
lines changed

docs/src/components/sdk/overview.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
'use client';
22

33
import Link from 'fumadocs-core/link';
4+
import { usePathname } from 'next/navigation';
45
import type { ReactNode } from 'react';
56
import { cn } from '../../lib/cn';
7+
import { DEFAULT_PLATFORM, getCurrentPlatform, getPlatformUrl } from '../../lib/platform-utils';
68
import { Box, Code, Zap } from '../icons';
79

810
type SDKItem = {
@@ -55,6 +57,21 @@ function getColorForType(type: string): string {
5557
}
5658

5759
export function SDKOverview({ sections }: SDKOverviewProps) {
60+
const pathname = usePathname();
61+
const currentPlatform = getCurrentPlatform(pathname);
62+
63+
// Function to build proper absolute URLs for SDK links
64+
const buildSDKUrl = (href: string): string => {
65+
// If href already starts with /, it's already absolute
66+
if (href.startsWith('/')) return href;
67+
68+
// Use the current platform or fallback to default platform
69+
const platform = currentPlatform || DEFAULT_PLATFORM;
70+
71+
// Build the absolute URL using getPlatformUrl utility
72+
return getPlatformUrl(platform, `sdk/${href}`);
73+
};
74+
5875
return (
5976
<div className="grid gap-8 mt-6">
6077
{sections.map((section, sectionIndex) => (
@@ -67,7 +84,7 @@ export function SDKOverview({ sections }: SDKOverviewProps) {
6784
{section.items.map((item, itemIndex) => (
6885
<Link
6986
key={itemIndex}
70-
href={item.href}
87+
href={buildSDKUrl(item.href)}
7188
className={cn(
7289
'group relative flex items-center gap-3 p-4 rounded-lg border transition-all duration-200',
7390
'hover:shadow-md hover:shadow-fd-primary/5 hover:border-fd-primary/20',

docs/templates/sdk/index.mdx

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,39 +12,39 @@ export const sdkSections = [
1212
{
1313
title: "General",
1414
items: [
15-
{ name: "StackClientApp", href: "./objects/stack-app#stackclientapp", icon: "object" },
16-
{ name: "StackServerApp", href: "./objects/stack-app#stackserverapp", icon: "object" },
17-
{ name: "Project", href: "./types/project#project", icon: "type" },
15+
{ name: "StackClientApp", href: "objects/stack-app#stackclientapp", icon: "object" },
16+
{ name: "StackServerApp", href: "objects/stack-app#stackserverapp", icon: "object" },
17+
{ name: "Project", href: "types/project#project", icon: "type" },
1818
]
1919
},
2020
{
2121
title: "Users & user data",
2222
items: [
23-
{ name: "CurrentUser", href: "./types/user#currentuser", icon: "type" },
24-
{ name: "ServerUser", href: "./types/user#serveruser", icon: "type" },
25-
{ name: "CurrentServerUser", href: "./types/user#currentserveruser", icon: "type" },
26-
{ name: "ContactChannel", href: "./types/contact-channel#contactchannel", icon: "type" },
27-
{ name: "ServerContactChannel", href: "./types/contact-channel#servercontactchannel", icon: "type" },
23+
{ name: "CurrentUser", href: "types/user#currentuser", icon: "type" },
24+
{ name: "ServerUser", href: "types/user#serveruser", icon: "type" },
25+
{ name: "CurrentServerUser", href: "types/user#currentserveruser", icon: "type" },
26+
{ name: "ContactChannel", href: "types/contact-channel#contactchannel", icon: "type" },
27+
{ name: "ServerContactChannel", href: "types/contact-channel#servercontactchannel", icon: "type" },
2828
]
2929
},
3030
{
3131
title: "Teams",
3232
items: [
33-
{ name: "Team", href: "./types/team#team", icon: "type" },
34-
{ name: "ServerTeam", href: "./types/team#serverteam", icon: "type" },
35-
{ name: "TeamPermission", href: "./types/team-permission#teampermission", icon: "type" },
36-
{ name: "ServerTeamPermission", href: "./types/team-permission#serverteampermission", icon: "type" },
37-
{ name: "TeamUser", href: "./types/team-user#teamuser", icon: "type" },
38-
{ name: "ServerTeamUser", href: "./types/team-user#serverteamuser", icon: "type" },
39-
{ name: "TeamProfile", href: "./types/team-profile#teamprofile", icon: "type" },
40-
{ name: "ServerTeamProfile", href: "./types/team-profile#serverteamprofile", icon: "type" },
33+
{ name: "Team", href: "types/team#team", icon: "type" },
34+
{ name: "ServerTeam", href: "types/team#serverteam", icon: "type" },
35+
{ name: "TeamPermission", href: "types/team-permission#teampermission", icon: "type" },
36+
{ name: "ServerTeamPermission", href: "types/team-permission#serverteampermission", icon: "type" },
37+
{ name: "TeamUser", href: "types/team-user#teamuser", icon: "type" },
38+
{ name: "ServerTeamUser", href: "types/team-user#serverteamuser", icon: "type" },
39+
{ name: "TeamProfile", href: "types/team-profile#teamprofile", icon: "type" },
40+
{ name: "ServerTeamProfile", href: "types/team-profile#serverteamprofile", icon: "type" },
4141
]
4242
},
4343
{
4444
title: "Hooks",
4545
items: [
46-
{ name: "useStackApp", href: "./hooks/use-stack-app", icon: "hook" },
47-
{ name: "useUser", href: "./hooks/use-user", icon: "hook" },
46+
{ name: "useStackApp", href: "hooks/use-stack-app", icon: "hook" },
47+
{ name: "useUser", href: "hooks/use-user", icon: "hook" },
4848
]
4949
}
5050
];

0 commit comments

Comments
 (0)