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
created profile page, 404s
cozylittle.house
3 months ago
523283c6
64e83f27
+44
-7
2 changed files
expand all
collapse all
unified
split
app
p
[didOrHandle]
[rkey]
page.tsx
page.tsx
+9
-7
app/p/[didOrHandle]/[rkey]/page.tsx
···
5
5
import { Metadata } from "next";
6
6
import { idResolver } from "app/(home-pages)/reader/idResolver";
7
7
import { DocumentPageRenderer } from "app/lish/[did]/[publication]/[rkey]/DocumentPageRenderer";
8
8
+
import { NotFoundLayout } from "components/PageLayouts/NotFoundLayout";
8
9
9
10
export async function generateMetadata(props: {
10
11
params: Promise<{ didOrHandle: string; rkey: string }>;
···
34
35
let docRecord = document.data as PubLeafletDocument.Record;
35
36
36
37
// For documents in publications, include publication name
37
37
-
let publicationName = document.documents_in_publications[0]?.publications?.name;
38
38
+
let publicationName =
39
39
+
document.documents_in_publications[0]?.publications?.name;
38
40
39
41
return {
40
42
icons: {
···
63
65
let resolved = await idResolver.handle.resolve(didOrHandle);
64
66
if (!resolved) {
65
67
return (
66
66
-
<div className="p-4 text-lg text-center flex flex-col gap-4">
67
67
-
<p>Sorry, can't resolve handle.</p>
68
68
+
<NotFoundLayout>
69
69
+
<p className="font-bold">Sorry, we can't find this handle!</p>
68
70
<p>
69
71
This may be a glitch on our end. If the issue persists please{" "}
70
72
<a href="mailto:contact@leaflet.pub">send us a note</a>.
71
73
</p>
72
72
-
</div>
74
74
+
</NotFoundLayout>
73
75
);
74
76
}
75
77
did = resolved;
76
78
} catch (e) {
77
79
return (
78
78
-
<div className="p-4 text-lg text-center flex flex-col gap-4">
79
79
-
<p>Sorry, can't resolve handle.</p>
80
80
+
<NotFoundLayout>
81
81
+
<p className="font-bold">Sorry, we can't find this leaflet!</p>
80
82
<p>
81
83
This may be a glitch on our end. If the issue persists please{" "}
82
84
<a href="mailto:contact@leaflet.pub">send us a note</a>.
83
85
</p>
84
84
-
</div>
86
86
+
</NotFoundLayout>
85
87
);
86
88
}
87
89
}
+35
app/p/[didOrHandle]/page.tsx
···
1
1
+
import { supabaseServerClient } from "supabase/serverClient";
2
2
+
import { AtUri } from "@atproto/syntax";
3
3
+
import { ids } from "lexicons/api/lexicons";
4
4
+
import { PubLeafletDocument } from "lexicons/api";
5
5
+
import { Metadata } from "next";
6
6
+
import { idResolver } from "app/(home-pages)/reader/idResolver";
7
7
+
import { DocumentPageRenderer } from "app/lish/[did]/[publication]/[rkey]/DocumentPageRenderer";
8
8
+
import { NotFoundLayout } from "components/PageLayouts/NotFoundLayout";
9
9
+
10
10
+
export default async function ProfilePage(props: {
11
11
+
params: Promise<{ didOrHandle: string }>;
12
12
+
}) {
13
13
+
let params = await props.params;
14
14
+
let didOrHandle = decodeURIComponent(params.didOrHandle);
15
15
+
16
16
+
// Resolve handle to DID if necessary
17
17
+
let did = didOrHandle;
18
18
+
if (!didOrHandle.startsWith("did:")) {
19
19
+
let resolved = await idResolver.handle.resolve(didOrHandle);
20
20
+
if (!resolved) {
21
21
+
return (
22
22
+
<NotFoundLayout>
23
23
+
<p className="font-bold">Sorry, can't resolve handle!</p>
24
24
+
<p>
25
25
+
This may be a glitch on our end. If the issue persists please{" "}
26
26
+
<a href="mailto:contact@leaflet.pub">send us a note</a>.
27
27
+
</p>
28
28
+
</NotFoundLayout>
29
29
+
);
30
30
+
}
31
31
+
did = resolved;
32
32
+
}
33
33
+
34
34
+
return <DocumentPageRenderer did={did} rkey={params.rkey} />;
35
35
+
}