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
27
pulls
pipelines
add some metadata to pubs
awarm.space
11 months ago
d341be6e
20e36e53
+38
2 changed files
expand all
collapse all
unified
split
app
lish
[handle]
[publication]
[rkey]
page.tsx
page.tsx
+19
app/lish/[handle]/[publication]/[rkey]/page.tsx
···
11
11
PubLeafletDocument,
12
12
PubLeafletPagesLinearDocument,
13
13
} from "lexicons/src";
14
14
+
import { Metadata } from "next";
14
15
15
16
const idResolver = new IdResolver();
17
17
+
export async function generateMetadata(props: {
18
18
+
params: { publication: string; handle: string; rkey: string };
19
19
+
}): Promise<Metadata> {
20
20
+
let did = await idResolver.handle.resolve(props.params.handle);
21
21
+
if (!did) return { title: "Publication 404" };
22
22
+
23
23
+
let { data: document } = await supabaseServerClient
24
24
+
.from("documents")
25
25
+
.select("*")
26
26
+
.eq("uri", AtUri.make(did, ids.PubLeafletDocument, props.params.rkey))
27
27
+
.single();
28
28
+
29
29
+
if (!document) return { title: "404" };
30
30
+
let record = document.data as PubLeafletDocument.Record;
31
31
+
return {
32
32
+
title: record.title + " - " + decodeURIComponent(props.params.publication),
33
33
+
};
34
34
+
}
16
35
export default async function Post(props: {
17
36
params: { publication: string; handle: string; rkey: string };
18
37
}) {
+19
app/lish/[handle]/[publication]/page.tsx
···
9
9
PubLeafletPublication,
10
10
} from "lexicons/src";
11
11
import { CallToActionButton } from "./CallToActionButton";
12
12
+
import { Metadata } from "next";
12
13
13
14
const idResolver = new IdResolver();
15
15
+
16
16
+
export async function generateMetadata(props: {
17
17
+
params: { publication: string; handle: string };
18
18
+
}): Promise<Metadata> {
19
19
+
let did = await idResolver.handle.resolve(props.params.handle);
20
20
+
if (!did) return { title: "Publication 404" };
21
21
+
22
22
+
let { data: publication } = await supabaseServerClient
23
23
+
.from("publications")
24
24
+
.select(
25
25
+
"*, documents_in_publications(documents(*)), leaflets_in_publications(*, permission_tokens(*, permission_token_rights(*), custom_domain_routes!custom_domain_routes_edit_permission_token_fkey(*) ))",
26
26
+
)
27
27
+
.eq("identity_did", did)
28
28
+
.eq("name", decodeURIComponent(props.params.publication))
29
29
+
.single();
30
30
+
if (!publication) return { title: "404 Publication" };
31
31
+
return { title: decodeURIComponent(props.params.publication) };
32
32
+
}
14
33
15
34
export default async function Publication(props: {
16
35
params: { publication: string; handle: string };