···
import { Button } from "./button.jsx";
counts: { distinct_dids: number; records: number };
const linksBySource = (links: Record<string, any>) => {
20
-
let out: Backlink[] = [];
19
+
let out: Record<string, Backlink[]> = {};
.forEach((collection) => {
···
if (paths[path].records === 0) return;
29
-
out.push({ collection, path, counts: paths[path] });
28
+
if (out[collection]) out[collection].push({ path, counts: paths[path] });
29
+
else out[collection] = [{ path, counts: paths[path] }];
···
<div class="flex w-full flex-col gap-1 text-sm wrap-anywhere">
51
-
<Show when={response()?.length === 0}>
52
-
<p>No backlinks found.</p>
54
-
<For each={response()}>
55
-
{({ collection, path, counts }) => (
52
+
when={response() && Object.keys(response()!).length}
53
+
fallback={<p>No backlinks found.</p>}
55
+
<For each={Object.keys(response()!)}>
<div class="flex items-center gap-1">
···
65
-
<div class="flex items-center gap-1">
67
-
title="Record path where the link is found"
68
-
class="iconify lucide--route shrink-0"
73
-
<div class="ml-4.5">
76
-
class="text-blue-400 hover:underline active:underline"
77
-
title="Show linking records"
80
-
show()?.collection === collection &&
81
-
show()?.path === path &&
85
-
: setShow({ collection, path, showDids: false })
88
-
{counts.records} record{counts.records < 2 ? "" : "s"}
92
-
class="text-blue-400 hover:underline active:underline"
93
-
title="Show linking DIDs"
95
-
show()?.collection === collection && show()?.path === path && show()?.showDids ?
97
-
: setShow({ collection, path, showDids: true })
100
-
{counts.distinct_dids} DID
101
-
{counts.distinct_dids < 2 ? "" : "s"}
104
-
<Show when={show()?.collection === collection && show()?.path === path}>
105
-
<Show when={show()?.showDids}>
106
-
{/* putting this in the `dids` prop directly failed to re-render. idk how to solidjs. */}
107
-
<p class="w-full font-semibold">Distinct identities</p>
109
-
target={props.target}
110
-
collection={collection}
115
-
<Show when={!show()?.showDids}>
116
-
<p class="w-full font-semibold">Records</p>
118
-
target={props.target}
119
-
collection={collection}
65
+
<For each={response()![collection]}>
66
+
{({ path, counts }) => (
67
+
<div class="ml-4.5">
68
+
<div class="flex items-center gap-1">
70
+
title="Record path where the link is found"
71
+
class="iconify lucide--route shrink-0"
75
+
<div class="ml-4.5">
78
+
class="text-blue-400 hover:underline active:underline"
79
+
title="Show linking records"
82
+
show()?.collection === collection &&
83
+
show()?.path === path &&
87
+
: setShow({ collection, path, showDids: false })
90
+
{counts.records} record{counts.records < 2 ? "" : "s"}
94
+
class="text-blue-400 hover:underline active:underline"
95
+
title="Show linking DIDs"
98
+
show()?.collection === collection &&
99
+
show()?.path === path &&
103
+
: setShow({ collection, path, showDids: true })
106
+
{counts.distinct_dids} DID
107
+
{counts.distinct_dids < 2 ? "" : "s"}
110
+
<Show when={show()?.collection === collection && show()?.path === path}>
111
+
<Show when={show()?.showDids}>
112
+
<p class="w-full font-semibold">Distinct identities</p>
114
+
target={props.target}
115
+
collection={collection}
120
+
<Show when={!show()?.showDids}>
121
+
<p class="w-full font-semibold">Records</p>
123
+
target={props.target}
124
+
collection={collection}