Skip to content

Commit 72bac98

Browse files
committed
add article:modified_time
1 parent 2bb4c20 commit 72bac98

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

src/layouts/Layout.astro

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export interface Props {
3030
link?: object[]
3131
structuredData?: object[]
3232
pubDate?: Date
33+
modifiedDate?: Date
3334
}
3435
3536
const {
@@ -42,6 +43,7 @@ const {
4243
link = [],
4344
structuredData = [],
4445
pubDate,
46+
modifiedDate,
4547
} = Astro.props
4648
4749
const canonicalUrl = new URL(Astro.url.pathname, Astro.site).toString()
@@ -129,6 +131,7 @@ import "../styles/global.css"
129131
},
130132
article: pubDate ? {
131133
publishedTime: pubDate.toISOString(),
134+
modifiedTime: modifiedDate ? modifiedDate.toISOString() : undefined,
132135
} : undefined,
133136
}}
134137
extend={{

src/lib/search-index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,15 @@ export default function searchIndex(config) {
7777
)
7878
const ogTitleValue = ogTitleTag.getAttribute("content")
7979

80+
const articleModifiedTag = postDocument.querySelector(
81+
"meta[property='article:modified_time']"
82+
)
8083
const articlePublishedTag = postDocument.querySelector(
8184
"meta[property='article:published_time']"
8285
)
83-
const publishedDate = articlePublishedTag
86+
const publishedDate = articleModifiedTag
87+
? articleModifiedTag.getAttribute("content")
88+
: articlePublishedTag
8489
? articlePublishedTag.getAttribute("content")
8590
: null
8691

src/pages/blog/[id].astro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ const blogPostSchema = [
8484
ogImageAlt={hasFeatureImage ? entry.data.featureImage.alt : null}
8585
structuredData={blogPostSchema}
8686
pubDate={entry.data.pubDate}
87+
modifiedDate={entry.data.modifiedDate}
8788
>
8889
<main class="max-w-4xl mx-auto mb-24">
8990
<Heading

0 commit comments

Comments
 (0)