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

Commit

Permalink
fix: Use JSON-LD differently
Browse files Browse the repository at this point in the history
  • Loading branch information
LekoArts committed Jul 19, 2022
1 parent 7c278e5 commit cfee562
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 62 deletions.
5 changes: 4 additions & 1 deletion www/src/components/seo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ export const SEO: React.FC<React.PropsWithChildren<SEOProps>> = ({
<meta name="msapplication-TileColor" content="#0f172a" />
{noIndex && <meta name="robots" content="noindex, nofollow" />}
{breadcrumbListItems.length >= 1 && (
<script type="application/ld+json">{JSON.stringify(breadcrumbList(breadcrumbListItems))}</script>
<script
type="application/ld+json"
dangerouslySetInnerHTML={{ __html: JSON.stringify(breadcrumbList(breadcrumbListItems)) }}
/>
)}
{children}
</>
Expand Down
2 changes: 1 addition & 1 deletion www/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ export default Index

export const Head = () => (
<SEO>
<script type="application/ld+json">{JSON.stringify(homepage)}</script>
<script type="application/ld+json" dangerouslySetInnerHTML={{ __html: JSON.stringify(homepage) }} />
</SEO>
)

Expand Down
43 changes: 23 additions & 20 deletions www/src/templates/garden.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,26 +167,29 @@ export const Head: HeadFC<DataProps> = ({ data: { garden } }) => (
<meta name="twitter:data2" value={garden.icon} />
<meta name="article:published_time" content={garden.seoDate} />
<meta name="article:modified_time" content={garden.seoLastUpdated} />
<script type="application/ld+json">
{JSON.stringify(
article({
isGarden: true,
post: {
title: garden.title,
description: garden.excerpt,
slug: garden.slug,
image: `/social/digital-garden.png`,
date: garden.seoDate,
lastUpdated: garden.seoLastUpdated,
year: garden.yearDate,
},
category: {
name: `Digital Garden`,
slug: `/garden`,
},
})
)}
</script>
<script
type="application/ld+json"
dangerouslySetInnerHTML={{
__html: JSON.stringify(
article({
isGarden: true,
post: {
title: garden.title,
description: garden.excerpt,
slug: garden.slug,
image: `/social/digital-garden.png`,
date: garden.seoDate,
lastUpdated: garden.seoLastUpdated,
year: garden.yearDate,
},
category: {
name: `Digital Garden`,
slug: `/garden`,
},
})
),
}}
/>
</SEO>
)

Expand Down
43 changes: 23 additions & 20 deletions www/src/templates/prose.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,29 @@ export const Head: HeadFC<WritingViewDataProps> = ({ data: { post } }) => (
<meta name="twitter:data2" value={post.category.name} />
<meta name="article:published_time" content={post.seoDate} />
<meta name="article:modified_time" content={post.seoLastUpdated} />
<script type="application/ld+json">
{JSON.stringify(
article({
isGarden: false,
post: {
title: post.title,
description: post.description ? post.description : post.excerpt,
date: post.seoDate,
lastUpdated: post.seoLastUpdated,
year: post.yearDate,
image: post.image,
slug: post.slug,
},
category: {
name: post.category.name,
slug: post.category.slug,
},
})
)}
</script>
<script
type="application/ld+json"
dangerouslySetInnerHTML={{
__html: JSON.stringify(
article({
isGarden: false,
post: {
title: post.title,
description: post.description ? post.description : post.excerpt,
date: post.seoDate,
lastUpdated: post.seoLastUpdated,
year: post.yearDate,
image: post.image,
slug: post.slug,
},
category: {
name: post.category.name,
slug: post.category.slug,
},
})
),
}}
/>
</SEO>
)

Expand Down
43 changes: 23 additions & 20 deletions www/src/templates/tutorial.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,26 +57,29 @@ export const Head: HeadFC<WritingViewDataProps> = ({ data: { post } }) => (
<meta name="twitter:data2" value={post.category.name} />
<meta name="article:published_time" content={post.seoDate} />
<meta name="article:modified_time" content={post.seoLastUpdated} />
<script type="application/ld+json">
{JSON.stringify(
article({
isGarden: false,
post: {
title: post.title,
description: post.description ? post.description : post.excerpt,
date: post.seoDate,
lastUpdated: post.seoLastUpdated,
year: post.yearDate,
image: post.image,
slug: post.slug,
},
category: {
name: post.category.name,
slug: post.category.slug,
},
})
)}
</script>
<script
type="application/ld+json"
dangerouslySetInnerHTML={{
__html: JSON.stringify(
article({
isGarden: false,
post: {
title: post.title,
description: post.description ? post.description : post.excerpt,
date: post.seoDate,
lastUpdated: post.seoLastUpdated,
year: post.yearDate,
image: post.image,
slug: post.slug,
},
category: {
name: post.category.name,
slug: post.category.slug,
},
})
),
}}
/>
</SEO>
)

Expand Down

0 comments on commit cfee562

Please sign in to comment.