tangled
alpha
login
or
join now
citizen428.net
/
pdsls
forked from
pds.ls/pdsls
0
fork
atom
atproto explorer
0
fork
atom
overview
issues
pulls
pipelines
show message when no backlinks found
juli.ee
5 months ago
4dde7b1f
1e542280
verified
This commit was signed with the committer's
known signature
.
juli.ee
SSH Key Fingerprint:
SHA256:mBrT4x0JdzLpbVR95g1hjI1aaErfC02kmLRkPXwsYCk=
+71
-76
1 changed file
expand all
collapse all
unified
split
src
components
backlinks.tsx
+71
-76
src/components/backlinks.tsx
···
24
24
const Backlinks = (props: { target: string }) => {
25
25
const fetchBacklinks = async () => {
26
26
const res = await getAllBacklinks(props.target);
27
27
-
setBacklinks(linksBySource(res.links));
28
28
-
return res;
27
27
+
return linksBySource(res.links);
29
28
};
30
29
31
30
const [response] = createResource(fetchBacklinks);
32
32
-
const [backlinks, setBacklinks] = createSignal<any>();
33
31
34
32
const [show, setShow] = createSignal<{
35
33
collection: string;
···
38
36
} | null>();
39
37
40
38
return (
41
41
-
<Show when={response()}>
42
42
-
<div class="flex w-full flex-col gap-1 text-sm wrap-anywhere">
43
43
-
<For each={backlinks()}>
44
44
-
{({ collection, path, counts }) => (
39
39
+
<div class="flex w-full flex-col gap-1 text-sm wrap-anywhere">
40
40
+
<Show when={response()?.length === 0}>
41
41
+
<p>No backlinks found.</p>
42
42
+
</Show>
43
43
+
<For each={response()}>
44
44
+
{({ collection, path, counts }) => (
45
45
+
<div>
45
46
<div>
46
46
-
<div>
47
47
-
<div title="Collection containing linking records" class="flex items-center gap-1">
48
48
-
<span class="iconify lucide--book-text shrink-0"></span>
49
49
-
{collection}
50
50
-
</div>
51
51
-
<div title="Record path where the link is found" class="flex items-center gap-1">
52
52
-
<span class="iconify lucide--route shrink-0"></span>
53
53
-
{path.slice(1)}
54
54
-
</div>
47
47
+
<div title="Collection containing linking records" class="flex items-center gap-1">
48
48
+
<span class="iconify lucide--book-text shrink-0"></span>
49
49
+
{collection}
50
50
+
</div>
51
51
+
<div title="Record path where the link is found" class="flex items-center gap-1">
52
52
+
<span class="iconify lucide--route shrink-0"></span>
53
53
+
{path.slice(1)}
55
54
</div>
56
56
-
<div class="ml-4.5">
57
57
-
<p>
58
58
-
<button
59
59
-
class="text-blue-400 hover:underline active:underline"
60
60
-
title="Show linking records"
61
61
-
onclick={() =>
62
62
-
(
63
63
-
show()?.collection === collection &&
64
64
-
show()?.path === path &&
65
65
-
!show()?.showDids
66
66
-
) ?
67
67
-
setShow(null)
68
68
-
: setShow({ collection, path, showDids: false })
69
69
-
}
70
70
-
>
71
71
-
{counts.records} record{counts.records < 2 ? "" : "s"}
72
72
-
</button>
73
73
-
{" from "}
74
74
-
<button
75
75
-
class="text-blue-400 hover:underline active:underline"
76
76
-
title="Show linking DIDs"
77
77
-
onclick={() =>
78
78
-
(
79
79
-
show()?.collection === collection &&
80
80
-
show()?.path === path &&
81
81
-
show()?.showDids
82
82
-
) ?
83
83
-
setShow(null)
84
84
-
: setShow({ collection, path, showDids: true })
85
85
-
}
86
86
-
>
87
87
-
{counts.distinct_dids} DID
88
88
-
{counts.distinct_dids < 2 ? "" : "s"}
89
89
-
</button>
90
90
-
</p>
91
91
-
<Show when={show()?.collection === collection && show()?.path === path}>
92
92
-
<Show when={show()?.showDids}>
93
93
-
{/* putting this in the `dids` prop directly failed to re-render. idk how to solidjs. */}
94
94
-
<p class="w-full font-semibold">Distinct identities</p>
95
95
-
<BacklinkItems
96
96
-
target={props.target}
97
97
-
collection={collection}
98
98
-
path={path}
99
99
-
dids={true}
100
100
-
/>
101
101
-
</Show>
102
102
-
<Show when={!show()?.showDids}>
103
103
-
<p class="w-full font-semibold">Records</p>
104
104
-
<BacklinkItems
105
105
-
target={props.target}
106
106
-
collection={collection}
107
107
-
path={path}
108
108
-
dids={false}
109
109
-
/>
110
110
-
</Show>
55
55
+
</div>
56
56
+
<div class="ml-4.5">
57
57
+
<p>
58
58
+
<button
59
59
+
class="text-blue-400 hover:underline active:underline"
60
60
+
title="Show linking records"
61
61
+
onclick={() =>
62
62
+
(
63
63
+
show()?.collection === collection &&
64
64
+
show()?.path === path &&
65
65
+
!show()?.showDids
66
66
+
) ?
67
67
+
setShow(null)
68
68
+
: setShow({ collection, path, showDids: false })
69
69
+
}
70
70
+
>
71
71
+
{counts.records} record{counts.records < 2 ? "" : "s"}
72
72
+
</button>
73
73
+
{" from "}
74
74
+
<button
75
75
+
class="text-blue-400 hover:underline active:underline"
76
76
+
title="Show linking DIDs"
77
77
+
onclick={() =>
78
78
+
show()?.collection === collection && show()?.path === path && show()?.showDids ?
79
79
+
setShow(null)
80
80
+
: setShow({ collection, path, showDids: true })
81
81
+
}
82
82
+
>
83
83
+
{counts.distinct_dids} DID
84
84
+
{counts.distinct_dids < 2 ? "" : "s"}
85
85
+
</button>
86
86
+
</p>
87
87
+
<Show when={show()?.collection === collection && show()?.path === path}>
88
88
+
<Show when={show()?.showDids}>
89
89
+
{/* putting this in the `dids` prop directly failed to re-render. idk how to solidjs. */}
90
90
+
<p class="w-full font-semibold">Distinct identities</p>
91
91
+
<BacklinkItems
92
92
+
target={props.target}
93
93
+
collection={collection}
94
94
+
path={path}
95
95
+
dids={true}
96
96
+
/>
97
97
+
</Show>
98
98
+
<Show when={!show()?.showDids}>
99
99
+
<p class="w-full font-semibold">Records</p>
100
100
+
<BacklinkItems
101
101
+
target={props.target}
102
102
+
collection={collection}
103
103
+
path={path}
104
104
+
dids={false}
105
105
+
/>
111
106
</Show>
112
112
-
</div>
107
107
+
</Show>
113
108
</div>
114
114
-
)}
115
115
-
</For>
116
116
-
</div>
117
117
-
</Show>
109
109
+
</div>
110
110
+
)}
111
111
+
</For>
112
112
+
</div>
118
113
);
119
114
};
120
115