fix: max depth truncate + post elements alignment

Changed files
+66 -85
app
+7 -53
app/components/BskyComments.vue
···
<div>No replies yet!</div>
</div>
-
<div v-else v-for="reply in post.replies" class="mt-6">
-
<BskyPost :post="reply" :depth="0" />
-
-
<!-- <a :href="`https://bsky.app/profile/${reply.post.author.handle}`" class="flex items-center gap-2 text-blue-500 hover:underline w-fit">
-
<img :src="reply.post.author.avatar" :alt="reply.post.author.displayName" class="size-8 rounded-full" />
-
<span>
-
{{ reply.post.author.displayName }}
-
</span>
-
</a>
-
<div class="ml-10">{{ reply.post.record.text }}</div>
-
<div class="flex items-baseline gap-4 ml-10 mt-2">
-
<p class="text-gray-500 text-sm" title="Replies">
-
<Icon name="ri:reply-line" class="-mb-[2px] mr-1" />
-
{{reply.post.replyCount}}
-
</p>
-
<p class="text-gray-500 text-sm" title="Likes">
-
<Icon name="ri:heart-3-line" class="-mb-[2px] mr-1" />
-
<span>
-
{{reply.post.likeCount}}
-
</span>
-
</p>
-
<p class="text-gray-500 text-sm" title="Bookmarks">
-
<Icon name="ri:bookmark-line" class="-mb-[2px] mr-1" />
-
{{reply.post.bookmarkCount}}
-
</p>
-
</div>
-
-
<div v-for="rep in reply.replies" class="mt-6 ml-10">
-
<a :href="`https://bsky.app/profile/${rep.post.author.handle}`" class="flex items-center gap-2 text-blue-500 hover:underline w-fit">
-
<img :src="rep.post.author.avatar" :alt="rep.post.author.displayName" class="size-8 rounded-full" />
-
<span>
-
{{ rep.post.author.displayName }}
-
</span>
-
</a>
-
<div class="ml-10">{{ rep.post.record.text }}</div>
-
<div class="flex items-baseline gap-4 ml-10 mt-2">
-
<p class="text-gray-500 text-sm" title="Replies">
-
<Icon name="ri:reply-line" class="-mb-[2px] mr-1" />
-
{{rep.post.replyCount}}
-
</p>
-
<p class="text-gray-500 text-sm" title="Likes">
-
<Icon name="ri:heart-3-line" class="-mb-[2px] mr-1" />
-
<span>
-
{{rep.post.likeCount}}
-
</span>
-
</p>
-
<p class="text-gray-500 text-sm" title="Bookmarks">
-
<Icon name="ri:bookmark-line" class="-mb-[2px] mr-1" />
-
{{rep.post.bookmarkCount}}
-
</p>
-
</div>
-
</div> -->
-
</div>
+
<BskyPost
+
v-else
+
v-for="reply in post.replies"
+
:key="reply.post.cid"
+
:post="reply"
+
:depth="0"
+
/>
</div>
</div>
</template>
+59 -32
app/components/BskyPost.vue
···
}>();
const { post, depth } = toRefs(props);
-
const MAX_DEPTH = 2; // Max number of replies to a reply
+
const MAX_DEPTH = 3; // Max number of replies to a reply
+
+
console.log(post);
</script>
<template>
-
<div v-if="post && depth <= MAX_DEPTH" :class="['mt-6', depth > 0 ? 'ml-10' : '']">
-
<a :href="`https://bsky.app/profile/${post.post.author.handle}`" class="flex items-center gap-2 text-blue-500 hover:underline w-fit">
+
<div v-if="post && depth < MAX_DEPTH" class="mt-6 bsky-post">
+
<a :href="`https://bsky.app/profile/${post.post.author.handle}`">
<img :src="post.post.author.avatar" :alt="post.post.author.displayName" class="size-8 rounded-full" />
-
<span>
-
{{ post.post.author.displayName }}
-
</span>
</a>
-
<div class="ml-10">{{ post.post.record.text }}</div>
-
<div class="flex items-baseline gap-4 ml-10 mt-2">
-
<p class="text-gray-500 text-sm" title="Replies">
-
<Icon name="ri:reply-line" class="-mb-[2px] mr-1" />
-
{{post.post.replyCount}}
-
</p>
-
<p class="text-gray-500 text-sm" title="Likes">
-
<Icon name="ri:heart-3-line" class="-mb-[2px] mr-1" />
-
<span>
-
{{post.post.likeCount}}
-
</span>
-
</p>
-
<p class="text-gray-500 text-sm" title="Bookmarks">
-
<Icon name="ri:bookmark-line" class="-mb-[2px] mr-1" />
-
{{post.post.bookmarkCount}}
-
</p>
-
</div>
+
<div class="flex flex-col gap-1">
+
<a :href="`https://bsky.app/profile/${post.post.author.handle}`" class="text-md font-bold w-fit">
+
{{ post.post.author.displayName }}
+
</a>
+
<div>
+
{{ post.post.record.text }}
+
</div>
+
<div class="flex items-baseline gap-4 mt-2">
+
<p class="text-gray-500 text-sm" title="Replies">
+
<Icon name="ri:reply-line" class="-mb-[2px] mr-1" />
+
{{post.post.replyCount}}
+
</p>
+
<p class="text-gray-500 text-sm" title="Likes">
+
<Icon name="ri:heart-3-line" class="-mb-[2px] mr-1" />
+
<span>
+
{{post.post.likeCount}}
+
</span>
+
</p>
+
<p class="text-gray-500 text-sm" title="Bookmarks">
+
<Icon name="ri:bookmark-line" class="-mb-[2px] mr-1" />
+
{{post.post.bookmarkCount}}
+
</p>
+
</div>
-
<div v-if="post.replies">
-
<div v-if="depth === MAX_DEPTH">
-
<a :href="`https://bsky.app/profile/${post.post.author.handle}/post/${extractPostId(post.post.uri)}`" class="text-gray-500 text-sm flex items-center gap-2 mt-4 ml-10">
-
View more replies on Bluesky
-
<Icon name='ri:arrow-drop-right-line' />
-
</a>
-
</div>
-
<div v-for="reply in post.replies">
-
<BskyPost v-if="reply.$type === 'app.bsky.feed.defs#threadViewPost'" :post="reply" :depth="depth + 1" />
+
<div v-if="post.replies && post.replies.length > 0">
+
<div v-if="depth+1 === MAX_DEPTH">
+
<a :href="`https://bsky.app/profile/${post.post.author.handle}/post/${extractPostId(post.post.uri)}`" class="text-gray-500 text-sm flex items-center gap-2 mt-4">
+
View more replies on Bluesky
+
<Icon name='ri:arrow-drop-right-line' />
+
</a>
+
</div>
+
<div v-else v-for="reply in post.replies">
+
<BskyPost v-if="reply.$type === 'app.bsky.feed.defs#threadViewPost'" :post="reply" :depth="depth + 1" />
+
</div>
</div>
</div>
</div>
</template>
+
+
<style scoped>
+
.bsky-post {
+
@apply gap-2 md:gap-4;
+
+
display: grid;
+
grid-template-columns: auto 1fr;
+
grid-template-areas:
+
"avatar content";
+
align-items: start;
+
+
& > a:has(> img) {
+
grid-area: avatar;
+
}
+
+
& > div {
+
grid-area: content;
+
}
+
+
}
+
</style>