a tool for shared writing and social publishing

add comment/quote counts + links to post list

+50 -17
+50 -17
app/lish/[did]/[publication]/page.tsx
··· 11 11 PublicationThemeProvider, 12 12 } from "components/ThemeManager/PublicationThemeProvider"; 13 13 import { SpeedyLink } from "components/SpeedyLink"; 14 + import { QuoteTiny } from "components/Icons/QuoteTiny"; 15 + import { CommentTiny } from "components/Icons/CommentTiny"; 14 16 15 17 export default async function Publication(props: { 16 18 params: Promise<{ publication: string; did: string }>; ··· 34 36 .select( 35 37 `*, 36 38 publication_subscriptions(*), 37 - documents_in_publications(documents(*)) 39 + documents_in_publications(documents( 40 + *, 41 + comments_on_documents(count), 42 + document_mentions_in_bsky(count) 43 + )) 38 44 `, 39 45 ) 40 46 .eq("identity_did", did) ··· 121 127 .map((doc) => { 122 128 if (!doc.documents) return null; 123 129 let uri = new AtUri(doc.documents.uri); 124 - let record = doc.documents 130 + let doc_record = doc.documents 125 131 .data as PubLeafletDocument.Record; 132 + let quotes = 133 + doc.documents.document_mentions_in_bsky[0].count || 0; 134 + let comments = 135 + record?.preferences?.showComments === false 136 + ? 0 137 + : doc.documents.comments_on_documents[0].count || 0; 138 + 126 139 return ( 127 140 <React.Fragment key={doc.documents?.uri}> 128 - <div className="flex w-full "> 141 + <div className="flex w-full grow flex-col "> 129 142 <SpeedyLink 130 143 href={`${getPublicationURL(publication)}/${uri.rkey}`} 131 - className="publishedPost grow flex flex-col hover:!no-underline" 144 + className="publishedPost hover:!no-underline flex flex-col" 132 145 > 133 - <h3 className="text-primary">{record.title}</h3> 146 + <h3 className="text-primary">{doc_record.title}</h3> 134 147 <p className="italic text-secondary"> 135 - {record.description} 148 + {doc_record.description} 136 149 </p> 137 - <p className="text-sm text-tertiary pt-2"> 138 - {record.publishedAt && 139 - new Date(record.publishedAt).toLocaleDateString( 140 - undefined, 141 - { 142 - year: "numeric", 143 - month: "long", 144 - day: "2-digit", 145 - }, 146 - )}{" "} 150 + </SpeedyLink> 151 + 152 + <div className="text-sm text-tertiary flex gap-1 flex-wrap pt-2"> 153 + <p className="text-sm text-tertiary "> 154 + {doc_record.publishedAt && 155 + new Date( 156 + doc_record.publishedAt, 157 + ).toLocaleDateString(undefined, { 158 + year: "numeric", 159 + month: "long", 160 + day: "2-digit", 161 + })}{" "} 147 162 </p> 148 - </SpeedyLink> 163 + {comments > 0 || quotes > 0 ? "| " : ""} 164 + {quotes > 0 && ( 165 + <SpeedyLink 166 + href={`${getPublicationURL(publication)}/${uri.rkey}?interactionDrawer=quotes`} 167 + className="flex flex-row gap-0 text-sm text-tertiary items-center flex-wrap" 168 + > 169 + <QuoteTiny /> {quotes} 170 + </SpeedyLink> 171 + )} 172 + {comments > 0 && 173 + record?.preferences?.showComments !== false && ( 174 + <SpeedyLink 175 + href={`${getPublicationURL(publication)}/${uri.rkey}?interactionDrawer=comments`} 176 + className="flex flex-row gap-0 text-sm text-tertiary items-center flex-wrap" 177 + > 178 + <CommentTiny /> {comments} 179 + </SpeedyLink> 180 + )} 181 + </div> 149 182 </div> 150 183 <hr className="last:hidden border-border-light" /> 151 184 </React.Fragment>