tangled
alpha
login
or
join now
retr0.id
/
pdsls
forked from
pds.ls/pdsls
1
fork
atom
atproto explorer
1
fork
atom
overview
issues
pulls
pipelines
backlinks API types
handle.invalid
5 months ago
a96fd57b
13dd9973
verified
This commit was signed with the committer's
known signature
.
handle.invalid
SSH Key Fingerprint:
SHA256:mBrT4x0JdzLpbVR95g1hjI1aaErfC02kmLRkPXwsYCk=
+30
-8
2 changed files
expand all
collapse all
unified
split
src
components
backlinks.tsx
utils
api.ts
+12
-6
src/components/backlinks.tsx
···
1
import * as TID from "@atcute/tid";
2
import { createResource, createSignal, For, onMount, Show } from "solid-js";
3
-
import { getAllBacklinks, getDidBacklinks, getRecordBacklinks } from "../utils/api.js";
0
0
0
0
0
0
4
import { localDateFromTimestamp } from "../utils/date.js";
5
import { Button } from "./button.jsx";
6
···
128
dids: boolean;
129
cursor?: string;
130
}) => {
131
-
const [links, setLinks] = createSignal<any>();
132
const [more, setMore] = createSignal<boolean>(false);
133
134
onMount(async () => {
···
147
return (
148
<Show when={links()} fallback={<p>Loading…</p>}>
149
<Show when={dids}>
150
-
<For each={links().linking_dids}>
151
{(did) => (
152
<a
153
href={`/at://${did}`}
···
159
</For>
160
</Show>
161
<Show when={!dids}>
162
-
<For each={links().linking_records}>
163
{({ did, collection, rkey }) => (
164
<p class="relative flex w-full items-center gap-1 font-mono">
165
<a
···
177
)}
178
</For>
179
</Show>
180
-
<Show when={links().cursor}>
181
<Show when={more()} fallback={<Button onClick={() => setMore(true)}>Load More</Button>}>
182
<BacklinkItems
183
target={target}
184
collection={collection}
185
path={path}
186
dids={dids}
187
-
cursor={links().cursor}
188
/>
189
</Show>
190
</Show>
···
1
import * as TID from "@atcute/tid";
2
import { createResource, createSignal, For, onMount, Show } from "solid-js";
3
+
import {
4
+
getAllBacklinks,
5
+
getDidBacklinks,
6
+
getRecordBacklinks,
7
+
LinksWithDids,
8
+
LinksWithRecords,
9
+
} from "../utils/api.js";
10
import { localDateFromTimestamp } from "../utils/date.js";
11
import { Button } from "./button.jsx";
12
···
134
dids: boolean;
135
cursor?: string;
136
}) => {
137
+
const [links, setLinks] = createSignal<LinksWithDids | LinksWithRecords>();
138
const [more, setMore] = createSignal<boolean>(false);
139
140
onMount(async () => {
···
153
return (
154
<Show when={links()} fallback={<p>Loading…</p>}>
155
<Show when={dids}>
156
+
<For each={(links() as LinksWithDids).linking_dids}>
157
{(did) => (
158
<a
159
href={`/at://${did}`}
···
165
</For>
166
</Show>
167
<Show when={!dids}>
168
+
<For each={(links() as LinksWithRecords).linking_records}>
169
{({ did, collection, rkey }) => (
170
<p class="relative flex w-full items-center gap-1 font-mono">
171
<a
···
183
)}
184
</For>
185
</Show>
186
+
<Show when={links()?.cursor}>
187
<Show when={more()} fallback={<Button onClick={() => setMore(true)}>Load More</Button>}>
188
<BacklinkItems
189
target={target}
190
collection={collection}
191
path={path}
192
dids={dids}
193
+
cursor={links()!.cursor}
194
/>
195
</Show>
196
</Show>
+18
-2
src/utils/api.ts
···
119
};
120
}
121
0
0
0
0
0
0
0
0
0
0
0
0
122
const getConstellation = async (
123
endpoint: string,
124
target: string,
···
152
path: string,
153
cursor?: string,
154
limit?: number,
155
-
) => getConstellation("/links", target, collection, path, cursor, limit || 100);
0
156
157
const getDidBacklinks = (
158
target: string,
···
160
path: string,
161
cursor?: string,
162
limit?: number,
163
-
) => getConstellation("/links/distinct-dids", target, collection, path, cursor, limit || 100);
0
164
165
export {
166
didDocCache,
···
175
resolvePDS,
176
validateHandle,
177
type LinkData,
0
0
178
};
···
119
};
120
}
121
122
+
type LinksWithRecords = {
123
+
cursor: string;
124
+
total: number;
125
+
linking_records: Array<{ did: string; collection: string; rkey: string }>;
126
+
};
127
+
128
+
type LinksWithDids = {
129
+
cursor: string;
130
+
total: number;
131
+
linking_dids: Array<string>;
132
+
};
133
+
134
const getConstellation = async (
135
endpoint: string,
136
target: string,
···
164
path: string,
165
cursor?: string,
166
limit?: number,
167
+
): Promise<LinksWithRecords> =>
168
+
getConstellation("/links", target, collection, path, cursor, limit || 100);
169
170
const getDidBacklinks = (
171
target: string,
···
173
path: string,
174
cursor?: string,
175
limit?: number,
176
+
): Promise<LinksWithDids> =>
177
+
getConstellation("/links/distinct-dids", target, collection, path, cursor, limit || 100);
178
179
export {
180
didDocCache,
···
189
resolvePDS,
190
validateHandle,
191
type LinkData,
192
+
type LinksWithDids,
193
+
type LinksWithRecords,
194
};