-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPostJSONLd.tsx
More file actions
44 lines (42 loc) · 1.39 KB
/
PostJSONLd.tsx
File metadata and controls
44 lines (42 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { Post } from '@/app/types/Post';
const PostJSONLd = ({ post }: { post: Post }) => {
const baseUrl =
process.env.NEXT_PUBLIC_DEPLOYMENT_URL ||
process.env.NEXT_PUBLIC_URL ||
'https://shipfriend.dev';
return (
<script
type="application/ld+json"
dangerouslySetInnerHTML={{
__html: JSON.stringify({
'@context': 'https://schema.org',
'@type': 'BlogPosting',
headline: post.title,
alternativeHeadline: post.subTitle, // 서브타이틀용
description: post.subTitle || post.content.substring(0, 160),
articleBody: post.content, // 본문 전체
author: {
'@type': 'Person',
name: post.author,
},
datePublished: new Date(post.date).toISOString(),
dateModified: new Date(post.updatedAt || post.date).toISOString(),
wordCount: post.content.split(/\s+/g).length,
timeRequired: `PT${post.timeToRead}M`, // ISO 8601 duration format
// 이미지가 있는 경우
image: post.thumbnailImage,
// 블로그/사이트 정보
publisher: {
'@type': 'Organization',
name: 'ShipFriend TechBlog',
logo: {
'@type': 'ImageObject',
url: `${baseUrl}/favicon.ico`,
},
},
}),
}}
/>
);
};
export default PostJSONLd;