a tool for shared writing and social publishing

add publication index page

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