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 publication index page
awarm.space
10 months ago
fb6d9d79
5b2fb0a5
+83
-1
2 changed files
expand all
collapse all
unified
split
app
home
Publications.tsx
lish
[handle]
[publication]
page.tsx
+1
-1
app/home/Publications.tsx
···
53
53
return (
54
54
<Link
55
55
className="pubListItem w-full p-3 opaque-container rounded-lg! text-secondary text-center hover:no-underline flex flex-col gap-1 place-items-center transparent-outline outline-2 outline-offset-1 hover:outline-border basis-0 grow min-w-0"
56
56
-
href={`/lish/${props.handle}/${props.name}/`}
56
56
+
href={`/lish/${props.handle}/${props.name}/dashboard`}
57
57
>
58
58
<div className="w-6 h-6 rounded-full bg-test" />
59
59
<h4 className="font-bold w-full truncate">{props.name}</h4>
+82
app/lish/[handle]/[publication]/page.tsx
···
1
1
+
import { IdResolver } from "@atproto/identity";
2
2
+
import { supabaseServerClient } from "supabase/serverClient";
3
3
+
import { Metadata } from "next";
4
4
+
5
5
+
import { ThemeProvider } from "components/ThemeManager/ThemeProvider";
6
6
+
import React from "react";
7
7
+
import { get_publication_data } from "app/api/rpc/[command]/get_publication_data";
8
8
+
import { AtUri } from "@atproto/syntax";
9
9
+
import { PubLeafletDocument } from "lexicons/api";
10
10
+
import Link from "next/link";
11
11
+
12
12
+
const idResolver = new IdResolver();
13
13
+
14
14
+
export async function generateMetadata(props: {
15
15
+
params: Promise<{ publication: string; handle: string }>;
16
16
+
}): Promise<Metadata> {
17
17
+
let did = await idResolver.handle.resolve((await props.params).handle);
18
18
+
if (!did) return { title: "Publication 404" };
19
19
+
20
20
+
let { result: publication } = await get_publication_data.handler(
21
21
+
{
22
22
+
did,
23
23
+
publication_name: decodeURIComponent((await props.params).publication),
24
24
+
},
25
25
+
{ supabase: supabaseServerClient },
26
26
+
);
27
27
+
if (!publication) return { title: "404 Publication" };
28
28
+
return { title: decodeURIComponent((await props.params).publication) };
29
29
+
}
30
30
+
31
31
+
//This is the admin dashboard of the publication
32
32
+
export default async function Publication(props: {
33
33
+
params: Promise<{ publication: string; handle: string }>;
34
34
+
}) {
35
35
+
let params = await props.params;
36
36
+
let did = await idResolver.handle.resolve((await props.params).handle);
37
37
+
if (!did) return <PubNotFound />;
38
38
+
let { data: publication } = await supabaseServerClient
39
39
+
.from("publications")
40
40
+
.select(
41
41
+
`*,
42
42
+
documents_in_publications(documents(*))
43
43
+
`,
44
44
+
)
45
45
+
.eq("identity_did", did)
46
46
+
.eq("name", decodeURIComponent((await props.params).publication))
47
47
+
.single();
48
48
+
if (!publication) return <PubNotFound />;
49
49
+
50
50
+
try {
51
51
+
return (
52
52
+
<ThemeProvider entityID={null}>
53
53
+
<div>publication index page </div>
54
54
+
{publication.documents_in_publications.map((doc) => {
55
55
+
if (!doc.documents) return null;
56
56
+
let uri = new AtUri(doc.documents.uri);
57
57
+
let record = doc.documents.data as PubLeafletDocument.Record;
58
58
+
return (
59
59
+
<React.Fragment key={doc.documents?.uri}>
60
60
+
<div className="flex w-full ">
61
61
+
<Link
62
62
+
href={`/lish/${params.handle}/${params.publication}/${uri.rkey}`}
63
63
+
className="publishedPost grow flex flex-col gap-2 hover:!no-underline"
64
64
+
>
65
65
+
<h3 className="text-primary">{record.title}</h3>
66
66
+
</Link>
67
67
+
</div>
68
68
+
<hr className="last:hidden border-border-light" />
69
69
+
</React.Fragment>
70
70
+
);
71
71
+
})}
72
72
+
</ThemeProvider>
73
73
+
);
74
74
+
} catch (e) {
75
75
+
console.log(e);
76
76
+
return <pre>{JSON.stringify(e, undefined, 2)}</pre>;
77
77
+
}
78
78
+
}
79
79
+
80
80
+
const PubNotFound = () => {
81
81
+
return <div>ain't no pub here</div>;
82
82
+
};