diff --git a/apps/page/components/post.tsx b/apps/page/components/post.tsx index ca013c8..13f8446 100644 --- a/apps/page/components/post.tsx +++ b/apps/page/components/post.tsx @@ -1,3 +1,4 @@ +import { PostType } from "@changes-page/supabase/types/page"; import { PostTypeBadge } from "@changes-page/ui"; import classNames from "classnames"; import dynamic from "next/dynamic"; @@ -47,11 +48,15 @@ export default function Post({ >
- +
- + {(post?.tags ?? []).map((tag, idx) => ( +
+ +
+ ))} {isPinned && }
diff --git a/apps/page/lib/data.ts b/apps/page/lib/data.ts index 1753e02..12e42c6 100644 --- a/apps/page/lib/data.ts +++ b/apps/page/lib/data.ts @@ -70,6 +70,9 @@ export const BLACKLISTED_SLUGS = [ "press-kit", ]; +const postSelectParams = + "id,title,content,tags,publication_date,updated_at,created_at,allow_reactions"; + function translateHostToPageIdentifier(host: string): { page: string | null; domain: string | null; @@ -209,12 +212,9 @@ async function fetchPosts( ): Promise<{ posts: IPost[]; postsCount: number }> { const postsQuery = supabaseAdmin .from("posts") - .select( - "id,title,content,type,publication_date,updated_at,created_at,allow_reactions", - { - count: "exact", - } - ) + .select(postSelectParams, { + count: "exact", + }) .eq("page_id", String(pageId)) .eq("status", "published") .range( @@ -242,9 +242,7 @@ async function fetchPosts( // Get pinned post const { data: pinnedPost, error: pinnedPostError } = await supabaseAdmin .from("posts") - .select( - "id,title,content,type,publication_date,updated_at,created_at,allow_reactions" - ) + .select(postSelectParams) .eq("id", pinned_post_id) .eq("status", "published") .maybeSingle(); @@ -283,7 +281,7 @@ export type IPostPublicData = Pick< | "id" | "title" | "content" - | "type" + | "tags" | "publication_date" | "updated_at" | "created_at" @@ -299,9 +297,7 @@ async function fetchPostById( }> { const { data: post, error: postError } = await supabaseAdmin .from("posts") - .select( - "id,title,content,type,publication_date,updated_at,created_at,allow_reactions" - ) + .select(postSelectParams) .eq("id", String(postId)) .eq("page_id", String(pageId)) .eq("status", "published") diff --git a/apps/page/pages/_sites/[site]/plain.tsx b/apps/page/pages/_sites/[site]/plain.tsx index 356164c..88ce472 100644 --- a/apps/page/pages/_sites/[site]/plain.tsx +++ b/apps/page/pages/_sites/[site]/plain.tsx @@ -2,6 +2,7 @@ import { IPage, IPageSettings, IPost, + PostType, PostTypeToLabel, } from "@changes-page/supabase/types/page"; import { DateTime } from "@changes-page/utils"; @@ -61,7 +62,10 @@ export default function Index({

{post.title}

- {PostTypeToLabel[post?.type]},{" "} + {(post.tags ?? []) + .map((tag) => PostTypeToLabel[tag as PostType]) + .join(", ")} + {" | "}