forked from
slices.network/slices
Highly ambitious ATProtocol AppView service and sdks
1import type { NetworkSlicesSliceDefsSliceView } from "../client.ts";
2
3export interface SliceParams {
4 handle: string;
5 sliceId: string;
6}
7
8export function extractSliceParams(
9 params?: URLPatternResult,
10): SliceParams | null {
11 const handle = params?.pathname.groups.handle;
12 const sliceId = params?.pathname.groups.rkey;
13
14 if (!handle || !sliceId) {
15 return null;
16 }
17
18 return { handle, sliceId };
19}
20
21export function buildSliceUrl(
22 handle: string,
23 sliceId: string,
24 path?: string,
25): string {
26 const basePath = `/profile/${handle}/slice/${sliceId}`;
27 return path ? `${basePath}/${path}` : basePath;
28}
29
30// Helper to build slice URLs from slice view
31export function buildSliceUrlFromView(
32 slice: NetworkSlicesSliceDefsSliceView,
33 sliceId: string,
34 path?: string,
35): string {
36 const handle = slice.creator?.handle || "unknown";
37 return buildSliceUrl(handle, sliceId, path);
38}