fix sdk linking issues (#783)

This commit is contained in:
Madison 2025-07-22 01:59:16 -05:00 committed by GitHub
parent 018be1fdff
commit d94e62b620
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 36 additions and 19 deletions

View File

@ -1,8 +1,10 @@
'use client';
import Link from 'fumadocs-core/link';
import { usePathname } from 'next/navigation';
import type { ReactNode } from 'react';
import { cn } from '../../lib/cn';
import { DEFAULT_PLATFORM, getCurrentPlatform, getPlatformUrl } from '../../lib/platform-utils';
import { Box, Code, Zap } from '../icons';
type SDKItem = {
@ -55,6 +57,21 @@ function getColorForType(type: string): string {
}
export function SDKOverview({ sections }: SDKOverviewProps) {
const pathname = usePathname();
const currentPlatform = getCurrentPlatform(pathname);
// Function to build proper absolute URLs for SDK links
const buildSDKUrl = (href: string): string => {
// If href already starts with /, it's already absolute
if (href.startsWith('/')) return href;
// Use the current platform or fallback to default platform
const platform = currentPlatform || DEFAULT_PLATFORM;
// Build the absolute URL using getPlatformUrl utility
return getPlatformUrl(platform, `sdk/${href}`);
};
return (
<div className="grid gap-8 mt-6">
{sections.map((section, sectionIndex) => (
@ -67,7 +84,7 @@ export function SDKOverview({ sections }: SDKOverviewProps) {
{section.items.map((item, itemIndex) => (
<Link
key={itemIndex}
href={item.href}
href={buildSDKUrl(item.href)}
className={cn(
'group relative flex items-center gap-3 p-4 rounded-lg border transition-all duration-200',
'hover:shadow-md hover:shadow-fd-primary/5 hover:border-fd-primary/20',

View File

@ -12,39 +12,39 @@ export const sdkSections = [
{
title: "General",
items: [
{ name: "StackClientApp", href: "./objects/stack-app#stackclientapp", icon: "object" },
{ name: "StackServerApp", href: "./objects/stack-app#stackserverapp", icon: "object" },
{ name: "Project", href: "./types/project#project", icon: "type" },
{ name: "StackClientApp", href: "objects/stack-app#stackclientapp", icon: "object" },
{ name: "StackServerApp", href: "objects/stack-app#stackserverapp", icon: "object" },
{ name: "Project", href: "types/project#project", icon: "type" },
]
},
{
title: "Users & user data",
items: [
{ name: "CurrentUser", href: "./types/user#currentuser", icon: "type" },
{ name: "ServerUser", href: "./types/user#serveruser", icon: "type" },
{ name: "CurrentServerUser", href: "./types/user#currentserveruser", icon: "type" },
{ name: "ContactChannel", href: "./types/contact-channel#contactchannel", icon: "type" },
{ name: "ServerContactChannel", href: "./types/contact-channel#servercontactchannel", icon: "type" },
{ name: "CurrentUser", href: "types/user#currentuser", icon: "type" },
{ name: "ServerUser", href: "types/user#serveruser", icon: "type" },
{ name: "CurrentServerUser", href: "types/user#currentserveruser", icon: "type" },
{ name: "ContactChannel", href: "types/contact-channel#contactchannel", icon: "type" },
{ name: "ServerContactChannel", href: "types/contact-channel#servercontactchannel", icon: "type" },
]
},
{
title: "Teams",
items: [
{ name: "Team", href: "./types/team#team", icon: "type" },
{ name: "ServerTeam", href: "./types/team#serverteam", icon: "type" },
{ name: "TeamPermission", href: "./types/team-permission#teampermission", icon: "type" },
{ name: "ServerTeamPermission", href: "./types/team-permission#serverteampermission", icon: "type" },
{ name: "TeamUser", href: "./types/team-user#teamuser", icon: "type" },
{ name: "ServerTeamUser", href: "./types/team-user#serverteamuser", icon: "type" },
{ name: "TeamProfile", href: "./types/team-profile#teamprofile", icon: "type" },
{ name: "ServerTeamProfile", href: "./types/team-profile#serverteamprofile", icon: "type" },
{ name: "Team", href: "types/team#team", icon: "type" },
{ name: "ServerTeam", href: "types/team#serverteam", icon: "type" },
{ name: "TeamPermission", href: "types/team-permission#teampermission", icon: "type" },
{ name: "ServerTeamPermission", href: "types/team-permission#serverteampermission", icon: "type" },
{ name: "TeamUser", href: "types/team-user#teamuser", icon: "type" },
{ name: "ServerTeamUser", href: "types/team-user#serverteamuser", icon: "type" },
{ name: "TeamProfile", href: "types/team-profile#teamprofile", icon: "type" },
{ name: "ServerTeamProfile", href: "types/team-profile#serverteamprofile", icon: "type" },
]
},
{
title: "Hooks",
items: [
{ name: "useStackApp", href: "./hooks/use-stack-app", icon: "hook" },
{ name: "useUser", href: "./hooks/use-user", icon: "hook" },
{ name: "useStackApp", href: "hooks/use-stack-app", icon: "hook" },
{ name: "useUser", href: "hooks/use-user", icon: "hook" },
]
}
];