from ...blog.ghost_db import DBClient # adjust import path from shared.infrastructure.data_client import fetch_data from quart import g async def post_data(slug, session, include_drafts=False): client = DBClient(session) posts = (await client.posts_by_slug(slug, include_drafts=include_drafts)) if not posts: # 404 page (you can make a template for this if you want) return None post, original_post = posts[0] # Check if current user has liked this post is_liked = False if g.user: liked_data = await fetch_data("likes", "is-liked", params={ "user_id": g.user.id, "target_type": "post", "target_id": post["id"], }, required=False) is_liked = (liked_data or {}).get("liked", False) # Add is_liked to post dict post["is_liked"] = is_liked tags=await client.list_tags( limit=50000 ) # <-- new authors=await client.list_authors( limit=50000 ) return { "post": post, "original_post": original_post, "tags": tags, "authors": authors, }