--- import Link from '@/components/Link.astro' import { ScrollArea } from '@/components/ui/scroll-area' import { getCombinedReadingTime, getParentId, getParentPost, getPostById, getPostReadingTime, getSubpostsForParent, isSubpost, } from '@/lib/data-utils' import { Icon } from 'astro-icon/components' const { parentId } = Astro.props const currentPostId = Astro.params.id as string const isCurrentSubpost = isSubpost(currentPostId) const rootParentId = isCurrentSubpost ? getParentId(currentPostId) : parentId const currentPost = !isCurrentSubpost ? await getPostById(currentPostId) : null const subposts = await getSubpostsForParent(rootParentId) const parentPost = isCurrentSubpost ? await getParentPost(currentPostId) : null const activePost = parentPost || currentPost const isActivePost = activePost?.id === currentPostId const activePostReadingTime = activePost ? await getPostReadingTime(activePost.id) : null const activePostCombinedReadingTime = activePost && subposts.length > 0 ? await getCombinedReadingTime(activePost.id) : null const subpostsWithReadingTime = await Promise.all( subposts.map(async (subpost) => ({ ...subpost, readingTime: await getPostReadingTime(subpost.id), })), ) ---