forked from
jollywhoppers.com/witchsky.app
Bluesky app fork with some witchin' additions 馃挮
1import {type AppBskyGraphDefs, AtUri} from '@atproto/api'
2
3export function makeProfileLink(
4 info: {
5 did: string
6 handle: string
7 },
8 ...segments: string[]
9) {
10 return [`/profile`, info.did, ...segments].join('/')
11}
12
13export function makeCustomFeedLink(
14 did: string,
15 rkey: string,
16 segment?: string | undefined,
17 feedCacheKey?: 'discover' | 'explore' | undefined,
18) {
19 return (
20 [`/profile`, did, 'feed', rkey, ...(segment ? [segment] : [])].join('/') +
21 (feedCacheKey ? `?feedCacheKey=${encodeURIComponent(feedCacheKey)}` : '')
22 )
23}
24
25export function makeListLink(did: string, rkey: string, ...segments: string[]) {
26 return [`/profile`, did, 'lists', rkey, ...segments].join('/')
27}
28
29export function makeTagLink(did: string) {
30 return `/search?q=${encodeURIComponent(did)}`
31}
32
33export function makeSearchLink(props: {query: string; from?: 'me' | string}) {
34 return `/search?q=${encodeURIComponent(
35 props.query + (props.from ? ` from:${props.from}` : ''),
36 )}`
37}
38
39export function makeStarterPackLink(
40 starterPackOrName:
41 | AppBskyGraphDefs.StarterPackViewBasic
42 | AppBskyGraphDefs.StarterPackView
43 | string,
44 rkey?: string,
45) {
46 if (typeof starterPackOrName === 'string') {
47 return `https://bsky.app/start/${starterPackOrName}/${rkey}`
48 } else {
49 const uriRkey = new AtUri(starterPackOrName.uri).rkey
50 return `https://bsky.app/start/${starterPackOrName.creator.handle}/${uriRkey}`
51 }
52}