diff --git a/app/lish/[did]/[publication]/page.tsx b/app/lish/[did]/[publication]/page.tsx index b61984f3..3bd91f8f 100644 --- a/app/lish/[did]/[publication]/page.tsx +++ b/app/lish/[did]/[publication]/page.tsx @@ -5,9 +5,14 @@ import { ThemeProvider } from "components/ThemeManager/ThemeProvider"; import React from "react"; import { get_publication_data } from "app/api/rpc/[command]/get_publication_data"; import { AtUri } from "@atproto/syntax"; -import { PubLeafletDocument, PubLeafletPublication } from "lexicons/api"; +import { + AtpBaseClient, + PubLeafletDocument, + PubLeafletPublication, +} from "lexicons/api"; import Link from "next/link"; import { getPublicationURL } from "app/lish/createPub/getPublicationURL"; +import { BskyAgent } from "@atproto/api"; export async function generateMetadata(props: { params: Promise<{ publication: string; did: string }>; @@ -33,18 +38,22 @@ export default async function Publication(props: { let params = await props.params; let did = decodeURIComponent(params.did); if (!did) return ; - let { data: publication } = await supabaseServerClient - .from("publications") - .select( - `*, + let agent = new BskyAgent({ service: "https://public.api.bsky.app" }); + let [{ data: publication }, { data: profile }] = await Promise.all([ + supabaseServerClient + .from("publications") + .select( + `*, documents_in_publications(documents(*)) `, - ) - .eq("identity_did", did) - .eq("name", decodeURIComponent(params.publication)) - .single(); + ) + .eq("identity_did", did) + .eq("name", decodeURIComponent(params.publication)) + .single(), + agent.getProfile({ actor: did }), + ]); - let record = publication?.record as PubLeafletPublication.Record; + let record = publication?.record as PubLeafletPublication.Record | null; if (!publication) return ; try { @@ -54,7 +63,7 @@ export default async function Publication(props: {
- {record.icon && ( + {record?.icon && (
-

{record.description}

+

{record?.description}

+ {profile && ( +

+ + by {profile.displayName} + {" "} + + @{profile.handle} + +

+ )}
{publication.documents_in_publications