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 pub page
awarm.space
9 months ago
b7841b25
7d06b477
+34
-12
1 changed file
expand all
collapse all
unified
split
app
lish
[did]
[publication]
page.tsx
+34
-12
app/lish/[did]/[publication]/page.tsx
···
5
5
import React from "react";
6
6
import { get_publication_data } from "app/api/rpc/[command]/get_publication_data";
7
7
import { AtUri } from "@atproto/syntax";
8
8
-
import { PubLeafletDocument, PubLeafletPublication } from "lexicons/api";
8
8
+
import {
9
9
+
AtpBaseClient,
10
10
+
PubLeafletDocument,
11
11
+
PubLeafletPublication,
12
12
+
} from "lexicons/api";
9
13
import Link from "next/link";
10
14
import { getPublicationURL } from "app/lish/createPub/getPublicationURL";
15
15
+
import { BskyAgent } from "@atproto/api";
11
16
12
17
export async function generateMetadata(props: {
13
18
params: Promise<{ publication: string; did: string }>;
···
33
38
let params = await props.params;
34
39
let did = decodeURIComponent(params.did);
35
40
if (!did) return <PubNotFound />;
36
36
-
let { data: publication } = await supabaseServerClient
37
37
-
.from("publications")
38
38
-
.select(
39
39
-
`*,
41
41
+
let agent = new BskyAgent({ service: "https://public.api.bsky.app" });
42
42
+
let [{ data: publication }, { data: profile }] = await Promise.all([
43
43
+
supabaseServerClient
44
44
+
.from("publications")
45
45
+
.select(
46
46
+
`*,
40
47
documents_in_publications(documents(*))
41
48
`,
42
42
-
)
43
43
-
.eq("identity_did", did)
44
44
-
.eq("name", decodeURIComponent(params.publication))
45
45
-
.single();
49
49
+
)
50
50
+
.eq("identity_did", did)
51
51
+
.eq("name", decodeURIComponent(params.publication))
52
52
+
.single(),
53
53
+
agent.getProfile({ actor: did }),
54
54
+
]);
46
55
47
47
-
let record = publication?.record as PubLeafletPublication.Record;
56
56
+
let record = publication?.record as PubLeafletPublication.Record | null;
48
57
49
58
if (!publication) return <PubNotFound />;
50
59
try {
···
54
63
<div className="publication max-w-prose w-full mx-auto h-full sm:pt-8 pt-4 px-3 pb-12 sm:pb-8">
55
64
<div className="flex flex-col pb-8 w-full text-center justify-center ">
56
65
<div className="flex flex-col gap-3 justify-center place-items-center">
57
57
-
{record.icon && (
66
66
+
{record?.icon && (
58
67
<div
59
68
className="shrink-0 w-10 h-10 rounded-full"
60
69
style={{
···
69
78
{publication.name}
70
79
</h2>
71
80
</div>
72
72
-
<p className="sm:text-lg text-tertiary">{record.description} </p>
81
81
+
<p className="sm:text-lg text-tertiary">{record?.description} </p>
82
82
+
{profile && (
83
83
+
<p className="italic">
84
84
+
<strong className="text-secondary">
85
85
+
by {profile.displayName}
86
86
+
</strong>{" "}
87
87
+
<a
88
88
+
className="text-tertiary"
89
89
+
href={`https://bsky.app/profile/${profile.handle}`}
90
90
+
>
91
91
+
@{profile.handle}
92
92
+
</a>
93
93
+
</p>
94
94
+
)}
73
95
</div>
74
96
<div className="publicationPostList w-full flex flex-col gap-4">
75
97
{publication.documents_in_publications