tangled
alpha
login
or
join now
leaflet.pub
/
leaflet
289
fork
atom
a tool for shared writing and social publishing
289
fork
atom
overview
issues
28
pulls
pipelines
add profile data to post page
awarm.space
9 months ago
c85cb855
b7841b25
+53
-26
1 changed file
expand all
collapse all
unified
split
app
lish
[did]
[publication]
[rkey]
page.tsx
+53
-26
app/lish/[did]/[publication]/[rkey]/page.tsx
···
14
14
import { getPublicationURL } from "app/lish/createPub/getPublicationURL";
15
15
import { TextBlock } from "./TextBlock";
16
16
import { ThemeProvider } from "components/ThemeManager/ThemeProvider";
17
17
+
import { BskyAgent } from "@atproto/api";
17
18
18
19
export async function generateMetadata(props: {
19
20
params: Promise<{ publication: string; did: string; rkey: string }>;
···
21
22
let did = decodeURIComponent((await props.params).did);
22
23
if (!did) return { title: "Publication 404" };
23
24
24
24
-
let { data: document } = await supabaseServerClient
25
25
-
.from("documents")
26
26
-
.select("*")
27
27
-
.eq(
28
28
-
"uri",
29
29
-
AtUri.make(did, ids.PubLeafletDocument, (await props.params).rkey),
30
30
-
)
31
31
-
.single();
25
25
+
let [{ data: document }] = await Promise.all([
26
26
+
supabaseServerClient
27
27
+
.from("documents")
28
28
+
.select("*")
29
29
+
.eq(
30
30
+
"uri",
31
31
+
AtUri.make(did, ids.PubLeafletDocument, (await props.params).rkey),
32
32
+
)
33
33
+
.single(),
34
34
+
]);
32
35
33
36
if (!document) return { title: "404" };
34
37
let record = document.data as PubLeafletDocument.Record;
···
44
47
}) {
45
48
let did = decodeURIComponent((await props.params).did);
46
49
if (!did) return <div> can't resolve handle</div>;
47
47
-
let { data: document } = await supabaseServerClient
48
48
-
.from("documents")
49
49
-
.select("*, documents_in_publications(publications(*))")
50
50
-
.eq(
51
51
-
"uri",
52
52
-
AtUri.make(did, ids.PubLeafletDocument, (await props.params).rkey),
53
53
-
)
54
54
-
.single();
50
50
+
let agent = new BskyAgent({ service: "https://public.api.bsky.app" });
51
51
+
let [{ data: document }, { data: profile }] = await Promise.all([
52
52
+
supabaseServerClient
53
53
+
.from("documents")
54
54
+
.select("*, documents_in_publications(publications(*))")
55
55
+
.eq(
56
56
+
"uri",
57
57
+
AtUri.make(did, ids.PubLeafletDocument, (await props.params).rkey),
58
58
+
)
59
59
+
.single(),
60
60
+
agent.getProfile({ actor: did }),
61
61
+
]);
55
62
if (!document?.data || !document.documents_in_publications[0].publications)
56
63
return <div>notfound</div>;
57
64
let record = document.data as PubLeafletDocument.Record;
···
78
85
{record.description ? (
79
86
<p className="italic text-secondary">{record.description}</p>
80
87
) : null}
81
81
-
{record.publishedAt ? (
82
82
-
<p className="text-sm text-tertiary pt-3">
83
83
-
Published{" "}
84
84
-
{new Date(record.publishedAt).toLocaleDateString(undefined, {
85
85
-
year: "numeric",
86
86
-
month: "long",
87
87
-
day: "2-digit",
88
88
-
})}
89
89
-
</p>
90
90
-
) : null}
88
88
+
89
89
+
<div className="text-sm text-tertiary pt-3 flex gap-1">
90
90
+
{profile ? (
91
91
+
<>
92
92
+
<a
93
93
+
className="text-tertiary"
94
94
+
href={`https://bsky.app/profile/${profile.handle}`}
95
95
+
>
96
96
+
by {profile.displayName}
97
97
+
</a>
98
98
+
</>
99
99
+
) : null}
100
100
+
{record.publishedAt ? (
101
101
+
<>
102
102
+
{" "}
103
103
+
|
104
104
+
<p>
105
105
+
Published{" "}
106
106
+
{new Date(record.publishedAt).toLocaleDateString(
107
107
+
undefined,
108
108
+
{
109
109
+
year: "numeric",
110
110
+
month: "long",
111
111
+
day: "2-digit",
112
112
+
},
113
113
+
)}
114
114
+
</p>
115
115
+
</>
116
116
+
) : null}
117
117
+
</div>
91
118
</div>
92
119
<div className="postContent flex flex-col ">
93
120
{blocks.map((b, index) => {