Skip to content

Commit

Permalink
feat(seo): add og:image to post metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
mateusfg7 committed Jul 4, 2023
1 parent 9500e19 commit 5fef014
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 0 additions & 2 deletions src/app/(blog)/post/[slug]/og/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ export async function GET(
return NextResponse.json({ error: 'Post not found' }, { status: 404 })
}

console.log()

return new ImageResponse(
(
<div
Expand Down
8 changes: 7 additions & 1 deletion src/app/(blog)/post/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useMDXComponent } from 'next-contentlayer/hooks'
import { allPosts, type Post } from 'contentlayer/generated'

import { slug } from '@/shared/lib/slug'
import { host } from '@/shared/lib/webserver-constants'
import { Folder, CalendarBlank, Clock, Tag } from '@/shared/lib/phosphor-icons'
import { Date } from '@/shared/components/date'
import { TopButton } from './components/top-button'
Expand All @@ -31,7 +32,12 @@ export function generateMetadata({ params }: Props): Metadata {
tags: post.tags.split(',').map(tag => tag.trim()),
authors: 'Mateus Felipe Gonçalves <[email protected]>',
type: 'article',
url: `https://mfg-b.vercel.app/post/${params.slug}`
url: `https://mfg-b.vercel.app/post/${params.slug}`,
images: {
url: `${host}/post/${post.id}/og`,
width: 1200,
height: 630
}
}
}
}
Expand Down

0 comments on commit 5fef014

Please sign in to comment.