From 56841873f918bd52bbbeff6e42f910a72a533fef Mon Sep 17 00:00:00 2001 From: Vojta Holik Date: Fri, 10 Jan 2025 17:01:52 +0100 Subject: [PATCH] fix(aih): meta tags --- .../ai-hero/src/app/(content)/[post]/page.tsx | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/apps/ai-hero/src/app/(content)/[post]/page.tsx b/apps/ai-hero/src/app/(content)/[post]/page.tsx index 90e84e0d2..7ce0ed4d3 100644 --- a/apps/ai-hero/src/app/(content)/[post]/page.tsx +++ b/apps/ai-hero/src/app/(content)/[post]/page.tsx @@ -14,7 +14,7 @@ import { Share } from '@/components/share' import Spinner from '@/components/spinner' import { courseBuilderAdapter } from '@/db' import type { List } from '@/lib/lists' -import { getAllLists, getListForPost } from '@/lib/lists-query' +import { getAllLists, getList, getListForPost } from '@/lib/lists-query' import { type Post } from '@/lib/posts' import { getAllPosts, getPost } from '@/lib/posts-query' import { getPricingProps } from '@/lib/pricing-query' @@ -58,20 +58,27 @@ export async function generateMetadata( parent: ResolvingMetadata, ): Promise { const params = await props.params - const post = await getPost(params.post) + let resource - if (!post) { + resource = await getPost(params.post) + + if (!resource) { + resource = await getList(params.post) + } + + if (!resource) { return parent as Metadata } return { - title: post.fields.title, + title: resource.fields.title, + description: resource.fields.description, openGraph: { images: [ getOGImageUrlForResource({ - fields: { slug: post.fields.slug }, - id: post.id, - updatedAt: post.updatedAt, + fields: { slug: resource.fields.slug }, + id: resource.id, + updatedAt: resource.updatedAt, }), ], },