import { createResource, For, Match, Show, Switch, type Component, } from "solid-js"; import styles from "./PostComments.module.css"; const createPostLink = (post: BlueskyPost) => { const rkey = post.post.uri.split("post/")[1]; const replyLink = `https://bsky.app/profile/${post.post.author.handle}/post/${rkey}`; return replyLink; }; type StatsProps = { link: string; replyCount: number; repostCount: number; likeCount: number; variant: "small" | "large"; }; const Stats: Component = (props) => { const isLarge = props.variant === "large"; const size = isLarge ? "20" : "16"; return ( {props.replyCount} replies {props.repostCount} reposts {props.likeCount} likes ); }; type BlueskyPost = { post: { uri: string; author: { avatar: string; // Can be an empty string displayName: string; handle: string; did: string; }; record: { text: string; }; indexedAt: string; likeCount: number; repostCount: number; replyCount: number; }; replies?: BlueskyPost[]; }; const fetchData = async (postId: string) => { const atUri = `at://did:plc:laqygfbyvnkyuhsuaxmp6ez3/app.bsky.feed.post/${postId}`; const params = new URLSearchParams({ uri: atUri }); const response = await fetch( `https://public.api.bsky.app/xrpc/app.bsky.feed.getPostThread?${params.toString()}` ); const json: { thread: BlueskyPost } = await response.json(); return json.thread; }; const PostComment: Component<{ post: BlueskyPost }> = (props) => { const profileLink = `https://bsky.app/profile/${props.post.post.author.handle}`; const replyLink = createPostLink(props.post); return ( <>
{`${ {props.post.post.author.displayName} @{props.post.post.author.handle}
{props.post.post.record.text}
{(reply) => { return ; }}
); }; type PostCommentsProps = { postId: string; }; const PostComments = (props: PostCommentsProps) => { const [commentsResource] = createResource( () => props.postId, (postId) => fetchData(postId) ); return (
<>

Comments

{(post) => ( <>

Comments

Click{" "} here {" "} to join the conversation on Bluesky.

No replies yet. Be the first to comment!

} > {(comment) => { return ; }}
)}
); }; export default PostComments;