Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

Commit cfee562

Browse files
committed
fix: Use JSON-LD differently
1 parent 7c278e5 commit cfee562

File tree

5 files changed

+74
-62
lines changed

5 files changed

+74
-62
lines changed

www/src/components/seo.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@ export const SEO: React.FC<React.PropsWithChildren<SEOProps>> = ({
6363
<meta name="msapplication-TileColor" content="#0f172a" />
6464
{noIndex && <meta name="robots" content="noindex, nofollow" />}
6565
{breadcrumbListItems.length >= 1 && (
66-
<script type="application/ld+json">{JSON.stringify(breadcrumbList(breadcrumbListItems))}</script>
66+
<script
67+
type="application/ld+json"
68+
dangerouslySetInnerHTML={{ __html: JSON.stringify(breadcrumbList(breadcrumbListItems)) }}
69+
/>
6770
)}
6871
{children}
6972
</>

www/src/pages/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ export default Index
326326

327327
export const Head = () => (
328328
<SEO>
329-
<script type="application/ld+json">{JSON.stringify(homepage)}</script>
329+
<script type="application/ld+json" dangerouslySetInnerHTML={{ __html: JSON.stringify(homepage) }} />
330330
</SEO>
331331
)
332332

www/src/templates/garden.tsx

+23-20
Original file line numberDiff line numberDiff line change
@@ -167,26 +167,29 @@ export const Head: HeadFC<DataProps> = ({ data: { garden } }) => (
167167
<meta name="twitter:data2" value={garden.icon} />
168168
<meta name="article:published_time" content={garden.seoDate} />
169169
<meta name="article:modified_time" content={garden.seoLastUpdated} />
170-
<script type="application/ld+json">
171-
{JSON.stringify(
172-
article({
173-
isGarden: true,
174-
post: {
175-
title: garden.title,
176-
description: garden.excerpt,
177-
slug: garden.slug,
178-
image: `/social/digital-garden.png`,
179-
date: garden.seoDate,
180-
lastUpdated: garden.seoLastUpdated,
181-
year: garden.yearDate,
182-
},
183-
category: {
184-
name: `Digital Garden`,
185-
slug: `/garden`,
186-
},
187-
})
188-
)}
189-
</script>
170+
<script
171+
type="application/ld+json"
172+
dangerouslySetInnerHTML={{
173+
__html: JSON.stringify(
174+
article({
175+
isGarden: true,
176+
post: {
177+
title: garden.title,
178+
description: garden.excerpt,
179+
slug: garden.slug,
180+
image: `/social/digital-garden.png`,
181+
date: garden.seoDate,
182+
lastUpdated: garden.seoLastUpdated,
183+
year: garden.yearDate,
184+
},
185+
category: {
186+
name: `Digital Garden`,
187+
slug: `/garden`,
188+
},
189+
})
190+
),
191+
}}
192+
/>
190193
</SEO>
191194
)
192195

www/src/templates/prose.tsx

+23-20
Original file line numberDiff line numberDiff line change
@@ -40,26 +40,29 @@ export const Head: HeadFC<WritingViewDataProps> = ({ data: { post } }) => (
4040
<meta name="twitter:data2" value={post.category.name} />
4141
<meta name="article:published_time" content={post.seoDate} />
4242
<meta name="article:modified_time" content={post.seoLastUpdated} />
43-
<script type="application/ld+json">
44-
{JSON.stringify(
45-
article({
46-
isGarden: false,
47-
post: {
48-
title: post.title,
49-
description: post.description ? post.description : post.excerpt,
50-
date: post.seoDate,
51-
lastUpdated: post.seoLastUpdated,
52-
year: post.yearDate,
53-
image: post.image,
54-
slug: post.slug,
55-
},
56-
category: {
57-
name: post.category.name,
58-
slug: post.category.slug,
59-
},
60-
})
61-
)}
62-
</script>
43+
<script
44+
type="application/ld+json"
45+
dangerouslySetInnerHTML={{
46+
__html: JSON.stringify(
47+
article({
48+
isGarden: false,
49+
post: {
50+
title: post.title,
51+
description: post.description ? post.description : post.excerpt,
52+
date: post.seoDate,
53+
lastUpdated: post.seoLastUpdated,
54+
year: post.yearDate,
55+
image: post.image,
56+
slug: post.slug,
57+
},
58+
category: {
59+
name: post.category.name,
60+
slug: post.category.slug,
61+
},
62+
})
63+
),
64+
}}
65+
/>
6366
</SEO>
6467
)
6568

www/src/templates/tutorial.tsx

+23-20
Original file line numberDiff line numberDiff line change
@@ -57,26 +57,29 @@ export const Head: HeadFC<WritingViewDataProps> = ({ data: { post } }) => (
5757
<meta name="twitter:data2" value={post.category.name} />
5858
<meta name="article:published_time" content={post.seoDate} />
5959
<meta name="article:modified_time" content={post.seoLastUpdated} />
60-
<script type="application/ld+json">
61-
{JSON.stringify(
62-
article({
63-
isGarden: false,
64-
post: {
65-
title: post.title,
66-
description: post.description ? post.description : post.excerpt,
67-
date: post.seoDate,
68-
lastUpdated: post.seoLastUpdated,
69-
year: post.yearDate,
70-
image: post.image,
71-
slug: post.slug,
72-
},
73-
category: {
74-
name: post.category.name,
75-
slug: post.category.slug,
76-
},
77-
})
78-
)}
79-
</script>
60+
<script
61+
type="application/ld+json"
62+
dangerouslySetInnerHTML={{
63+
__html: JSON.stringify(
64+
article({
65+
isGarden: false,
66+
post: {
67+
title: post.title,
68+
description: post.description ? post.description : post.excerpt,
69+
date: post.seoDate,
70+
lastUpdated: post.seoLastUpdated,
71+
year: post.yearDate,
72+
image: post.image,
73+
slug: post.slug,
74+
},
75+
category: {
76+
name: post.category.name,
77+
slug: post.category.slug,
78+
},
79+
})
80+
),
81+
}}
82+
/>
8083
</SEO>
8184
)
8285

0 commit comments

Comments
 (0)