Skip to content

Commit 3cd0923

Browse files
authored
Merge pull request #41 from Han5991/feature/og
feat: OG 이미지 개선 (커스텀 썸네일 지원)
2 parents 46b2a1b + 43cd5e3 commit 3cd0923

File tree

4 files changed

+8
-21
lines changed

4 files changed

+8
-21
lines changed

apps/blog/web/lib/posts.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export interface PostData {
1212
date: string | null;
1313
content: string;
1414
excerpt?: string;
15+
thumbnail?: string;
1516
}
1617

1718
export function getAllPosts(): PostData[] {
@@ -53,6 +54,7 @@ export function getAllPosts(): PostData[] {
5354
date: data.date || null,
5455
content,
5556
excerpt: data.excerpt || cleanContent.slice(0, 160) + '...',
57+
thumbnail: typeof data.thumbnail === 'string' ? data.thumbnail : undefined,
5658
});
5759
}
5860
}
384 KB
Loading

apps/blog/web/public/og-default.svg

Lines changed: 0 additions & 19 deletions
This file was deleted.

apps/blog/web/src/app/posts/[...slug]/page.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,14 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {
4242
publishedTime: post.date || undefined,
4343
images: [
4444
{
45-
url: '/og-default.svg',
45+
url: post.thumbnail
46+
? post.thumbnail.startsWith('http') || post.thumbnail.startsWith('/')
47+
? post.thumbnail
48+
: `/posts/${post.relativeDir ? post.relativeDir + '/' : ''}${post.thumbnail}`
49+
: '/og-default.png',
4650
width: 1200,
4751
height: 630,
48-
alt: 'FE Lab Blog - Frontend Experimentation',
52+
alt: post.title,
4953
},
5054
],
5155
},

0 commit comments

Comments
 (0)