personal-website/app/blog/[slug]/head.tsx
Filipe Medeiros 5ff4edc634
feat: lots of stuff sorry
Signed-off-by: Filipe Medeiros <hello@filipesm.eu>
2023-12-03 12:25:54 +01:00

51 lines
1.4 KiB
TypeScript

import { notFound } from 'next/navigation'
import { getBlogPostBySlug } from '@/lib/notion/content/blogPosts'
import getProxiedAssetUrl from '@/lib/notion/utils/getProxiedAssetUrl'
import richTextAsPlainText from '@/lib/notion/utils/richTextToPlainText'
export default async function Head({
params: { slug },
}: {
params: { slug: string }
}) {
const blogPost = await getBlogPostBySlug({ slug })
if (!blogPost) {
notFound()
}
const title = `${richTextAsPlainText(
blogPost.properties.Name.title,
)} - Filipe Medeiros`
const description = richTextAsPlainText(
blogPost.properties.MetaDescription.rich_text,
)
return (
<>
<title>{title}</title>
<meta name="description" content={description} />
<meta
name="og:image"
content={`https://filipesm.eu${getProxiedAssetUrl({
pageId: blogPost.id,
lastEditedTime: blogPost.last_edited_time,
})}`}
/>
<link rel="canonical" href={`https://filipesm.eu/blog/${slug}`} />
<meta
name="twitter:card"
content={
blogPost.properties.MetaTwitterCard.select?.name ??
'summary_large_image'
}
/>
<meta property="og:url" content={`https://filipesm.eu/blog/${slug}`} />
<meta property="og:title" content={title} />
<meta property="og:description" content={description} />
<meta property="type" content="article" />
</>
)
}