forked from
pds.ls/pdsls
atproto explorer
1export type AppUrl = `${string}.${string}` | `localhost:${number}`;
2
3export enum App {
4 Bluesky,
5 Tangled,
6 Whitewind,
7 Frontpage,
8 Pinksea,
9 Linkat,
10}
11
12export const appList: Record<AppUrl, App> = {
13 "localhost:19006": App.Bluesky,
14 "blacksky.community": App.Bluesky,
15 "bsky.app": App.Bluesky,
16 "catsky.social": App.Bluesky,
17 "deer.aylac.top": App.Bluesky,
18 "deer-social-ayla.pages.dev": App.Bluesky,
19 "deer.social": App.Bluesky,
20 "main.bsky.dev": App.Bluesky,
21 "social.daniela.lol": App.Bluesky,
22 "tangled.org": App.Tangled,
23 "whtwnd.com": App.Whitewind,
24 "frontpage.fyi": App.Frontpage,
25 "pinksea.art": App.Pinksea,
26 "linkat.blue": App.Linkat,
27};
28
29export const appHandleLink: Record<App, (url: string[]) => string> = {
30 [App.Bluesky]: (path) => {
31 const baseType = path[0];
32 const user = path[1];
33
34 if (baseType === "profile") {
35 if (path[2]) {
36 const type = path[2];
37 const rkey = path[3];
38
39 if (type === "post") {
40 return `at://${user}/app.bsky.feed.post/${rkey}`;
41 } else if (type === "list") {
42 return `at://${user}/app.bsky.graph.list/${rkey}`;
43 } else if (type === "feed") {
44 return `at://${user}/app.bsky.feed.generator/${rkey}`;
45 } else if (type === "follows") {
46 return `at://${user}/app.bsky.graph.follow/${rkey}`;
47 }
48 } else {
49 return `at://${user}`;
50 }
51 } else if (baseType === "starter-pack") {
52 return `at://${user}/app.bsky.graph.starterpack/${path[2]}`;
53 }
54 return `at://${user}`;
55 },
56 [App.Tangled]: (path) => {
57 if (path[0] === "strings") {
58 return `at://${path[1]}/sh.tangled.string/${path[2]}`;
59 }
60
61 let query: string | undefined;
62 if (path[path.length - 1].includes("?")) {
63 const split = path[path.length - 1].split("?");
64 query = split[1];
65 path[path.length - 1] = split[0];
66 }
67
68 const user = path[0].replace("@", "");
69
70 if (path.length === 1) {
71 if (query === "tab=repos") {
72 return `at://${user}/sh.tangled.repo`;
73 } else if (query === "tab=starred") {
74 return `at://${user}/sh.tangled.feed.star`;
75 } else if (query === "tab=strings") {
76 return `at://${user}/sh.tangled.string`;
77 }
78 } else if (path.length === 2) {
79 // no way to convert the repo name to an rkey afaik
80 // same reason why there's nothing related to issues in here
81 return `at://${user}/sh.tangled.repo`;
82 }
83
84 return `at://${user}`;
85 },
86 [App.Whitewind]: (path) => {
87 if (path.length === 2) {
88 return `at://${path[0]}/com.whtwnd.blog.entry/${path[1]}`;
89 }
90
91 return `at://${path[0]}/com.whtwnd.blog.entry`;
92 },
93 [App.Frontpage]: (path) => {
94 if (path.length === 3) {
95 return `at://${path[1]}/fyi.unravel.frontpage.post/${path[2]}`;
96 } else if (path.length === 5) {
97 return `at://${path[3]}/fyi.unravel.frontpage.comment/${path[4]}`;
98 }
99
100 return `at://${path[0]}`;
101 },
102 [App.Pinksea]: (path) => {
103 if (path.length === 2) {
104 return `at://${path[0]}/com.shinolabs.pinksea.oekaki/${path[1]}`;
105 }
106
107 return `at://${path[0]}`;
108 },
109 [App.Linkat]: (path) => `at://${path[0]}/blue.linkat.board/self`,
110};