diff --git a/src/components/ui/XLogPost.tsx b/src/components/ui/XLogPost.tsx index c5d8b553..b0e3259c 100644 --- a/src/components/ui/XLogPost.tsx +++ b/src/components/ui/XLogPost.tsx @@ -12,6 +12,7 @@ import { Loading } from "../common/Loading" import { Time } from "../common/Time" import PostCover from "../home/PostCover" import { Avatar } from "./Avatar" +import { UniLink } from "./UniLink" interface Props { slug: string @@ -33,119 +34,117 @@ const XLogPost: FC = ({ slug, handle, url }) => { translateTo: locale, }) - const images = page.data?.metadata?.content?.attachments - ?.filter((attachment) => attachment.name === "image") - .map((img) => img.address || "") - .concat(page.data.metadata.content.images ?? []) - .filter(Boolean) - const isMobile = isMobileDevice() + const images = page.data?.metadata.content.images || [] const isShort = !!page.data?.metadata?.content?.tags?.includes("short") - const toggleExpand = useCallback( + const preventNavigate = useCallback( (e: React.MouseEvent) => { e.stopPropagation() - setIsExpanded((prev) => !prev) + e.preventDefault() }, [], ) - const handleRedirect = useCallback(() => { - window.open(url, "_blank") - }, [url]) + const toggleExpand = useCallback( + (e: React.MouseEvent) => { + preventNavigate(e) + setIsExpanded((prev) => !prev) + }, + [preventNavigate], + ) if (page.isLoading) return return ( -
+
e.stopPropagation()} className={cn( - "w-full h-full mb-2 sm:mb-0 align-middle flex items-center justify-center", - isExpanded ? "sm:w-[350px]" : "sm:w-[150px]", - "transition-all duration-500 ease-in-out", + "flex flex-col md:flex-row w-full bg-zinc-50 rounded-xl p-4 gap-x-4 hover:cursor-pointer my-2 transition-all duration-500 ease-in-out", + isExpanded ? "sm:h-[350px]" : "sm:h-[150px]", )} > - -
-
-
- {page.data?.metadata?.content?.title && ( -
- {page.data?.metadata?.content?.title} -
+
-

- {isShort - ? page.data?.metadata?.content?.content - : page.data?.metadata?.content?.summary} -

+ > + +
+
+
+ {page.data?.metadata?.content?.title && ( +
+ {page.data?.metadata?.content?.title} +
+ )} +
+

+ {isShort + ? page.data?.metadata?.content?.content + : page.data?.metadata?.content?.summary} +

+
+
+ +
+ + + + + + +
+ + {site.data?.metadata?.content?.name} + + {site.data?.handle && ( + + {"@" + site.data?.handle} + + )} +
+ + +
- -
- - - - - - -
- - {site.data?.metadata?.content?.name} - - {site.data?.handle && ( - - {"@" + site.data?.handle} - - )} -
- - -
-
-
+
) }