"use client"; import { AtUri } from "@atproto/api"; import { PubIcon } from "components/ActionBar/Publications"; import { CommentTiny } from "components/Icons/CommentTiny"; import { QuoteTiny } from "components/Icons/QuoteTiny"; import { Separator } from "components/Layout"; import { usePubTheme } from "components/ThemeManager/PublicationThemeProvider"; import { BaseThemeProvider } from "components/ThemeManager/ThemeProvider"; import { useSmoker } from "components/Toast"; import { PubLeafletDocument, PubLeafletPublication } from "lexicons/api"; import { blobRefToSrc } from "src/utils/blobRefToSrc"; import type { Post } from "app/(home-pages)/reader/getReaderFeed"; import Link from "next/link"; import { InteractionPreview } from "./InteractionsPreview"; import { useLocalizedDate } from "src/hooks/useLocalizedDate"; export const PostListing = (props: Post) => { let pubRecord = props.publication?.pubRecord as | PubLeafletPublication.Record | undefined; let postRecord = props.documents.data as PubLeafletDocument.Record; let postUri = new AtUri(props.documents.uri); let uri = props.publication ? props.publication?.uri : props.documents.uri; // For standalone documents (no publication), pass isStandalone to get correct defaults let isStandalone = !pubRecord; let theme = usePubTheme(pubRecord?.theme || postRecord?.theme, isStandalone); let themeRecord = pubRecord?.theme || postRecord?.theme; let backgroundImage = themeRecord?.backgroundImage?.image?.ref && uri ? blobRefToSrc(themeRecord.backgroundImage.image.ref, new AtUri(uri).host) : null; let backgroundImageRepeat = themeRecord?.backgroundImage?.repeat; let backgroundImageSize = themeRecord?.backgroundImage?.width || 500; let showPageBackground = pubRecord ? pubRecord?.theme?.showPageBackground : postRecord.theme?.showPageBackground ?? true; let quotes = props.documents.document_mentions_in_bsky?.[0]?.count || 0; let comments = pubRecord?.preferences?.showComments === false ? 0 : props.documents.comments_on_documents?.[0]?.count || 0; let tags = (postRecord?.tags as string[] | undefined) || []; // For standalone posts, link directly to the document let postHref = props.publication ? `${props.publication.href}/${postUri.rkey}` : `/p/${postUri.host}/${postUri.rkey}`; return (

{postRecord.title}

{postRecord.description}

{props.publication && pubRecord && ( )}
); }; const PubInfo = (props: { href: string; pubRecord: PubLeafletPublication.Record; uri: string; }) => { return (

{props.pubRecord.name}
); }; const PostInfo = (props: { publishedAt: string | undefined }) => { let localizedDate = useLocalizedDate(props.publishedAt || "", { year: "numeric", month: "short", day: "numeric", }); return (
{props.publishedAt && ( <>
{localizedDate}
)}
); };