Skip to content

Commit

Permalink
fix(aih): meta tags
Browse files Browse the repository at this point in the history
  • Loading branch information
vojtaholik committed Jan 10, 2025
1 parent 85ee71a commit 5684187
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions apps/ai-hero/src/app/(content)/[post]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -58,20 +58,27 @@ export async function generateMetadata(
parent: ResolvingMetadata,
): Promise<Metadata> {
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,
}),
],
},
Expand Down

0 comments on commit 5684187

Please sign in to comment.