personal-website/app/blog/[slug]/head.tsx
Filipe Medeiros 9a9638237f
feat: initial commit
Signed-off-by: Filipe Medeiros <hello@filipesm.eu>
2023-12-03 12:25:52 +01:00

37 lines
949 B
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'
const Head = async ({ params: { slug } }: { params: { slug: string } }) => {
const blogPost = await getBlogPostBySlug({ slug })
if (!blogPost) {
notFound()
}
return (
<>
<title>{`${richTextAsPlainText(
blogPost.properties.Name.title,
)} - Spencer Sharp`}</title>
<meta
name="description"
content={richTextAsPlainText(
blogPost.properties.MetaDescription.rich_text,
)}
/>
<meta
name="og:image"
content={`https://filipesm.eu${getProxiedAssetUrl({
pageId: blogPost.id,
lastEditedTime: blogPost.last_edited_time,
})}`}
/>
</>
)
}
export default Head