diff --git a/src/components/backlinks.tsx b/src/components/backlinks.tsx index 8ecde5f..0f0fb03 100644 --- a/src/components/backlinks.tsx +++ b/src/components/backlinks.tsx @@ -1,6 +1,12 @@ import * as TID from "@atcute/tid"; import { createResource, createSignal, For, onMount, Show } from "solid-js"; -import { getAllBacklinks, getDidBacklinks, getRecordBacklinks } from "../utils/api.js"; +import { + getAllBacklinks, + getDidBacklinks, + getRecordBacklinks, + LinksWithDids, + LinksWithRecords, +} from "../utils/api.js"; import { localDateFromTimestamp } from "../utils/date.js"; import { Button } from "./button.jsx"; @@ -128,7 +134,7 @@ const BacklinkItems = ({ dids: boolean; cursor?: string; }) => { - const [links, setLinks] = createSignal(); + const [links, setLinks] = createSignal(); const [more, setMore] = createSignal(false); onMount(async () => { @@ -147,7 +153,7 @@ const BacklinkItems = ({ return ( Loading…

}> - + {(did) => ( - + {({ did, collection, rkey }) => (

- + setMore(true)}>Load More}> diff --git a/src/utils/api.ts b/src/utils/api.ts index 12d02ec..d8d7726 100644 --- a/src/utils/api.ts +++ b/src/utils/api.ts @@ -119,6 +119,18 @@ interface LinkData { }; } +type LinksWithRecords = { + cursor: string; + total: number; + linking_records: Array<{ did: string; collection: string; rkey: string }>; +}; + +type LinksWithDids = { + cursor: string; + total: number; + linking_dids: Array; +}; + const getConstellation = async ( endpoint: string, target: string, @@ -152,7 +164,8 @@ const getRecordBacklinks = ( path: string, cursor?: string, limit?: number, -) => getConstellation("/links", target, collection, path, cursor, limit || 100); +): Promise => + getConstellation("/links", target, collection, path, cursor, limit || 100); const getDidBacklinks = ( target: string, @@ -160,7 +173,8 @@ const getDidBacklinks = ( path: string, cursor?: string, limit?: number, -) => getConstellation("/links/distinct-dids", target, collection, path, cursor, limit || 100); +): Promise => + getConstellation("/links/distinct-dids", target, collection, path, cursor, limit || 100); export { didDocCache, @@ -175,4 +189,6 @@ export { resolvePDS, validateHandle, type LinkData, + type LinksWithDids, + type LinksWithRecords, };