feat: improve page metadata display

This commit is contained in:
Travis Fischer
2022-04-08 08:16:14 -04:00
parent 1147254e6a
commit 89b3c8faba
5 changed files with 66 additions and 24 deletions

View File

@@ -75,17 +75,26 @@ export default withOGImage<'query', 'id'>({
// getPageProperty<string>('Description', block, recordMap) ||
// config.description
const timeUpdated = getPageProperty<number>(
'Last Updated',
block,
recordMap
)
const timePublished = getPageProperty<number>(
'Published',
block,
recordMap
)
const datePublished = timePublished ? new Date(timePublished) : undefined
const dateUpdated = timeUpdated
? new Date(timeUpdated)
: timePublished
? new Date(timePublished)
: undefined
const date =
isBlogPost && datePublished
? `${datePublished.toLocaleString('en-US', {
isBlogPost && dateUpdated
? `${dateUpdated.toLocaleString('en-US', {
month: 'long'
})} ${datePublished.getFullYear()}`
})} ${dateUpdated.getFullYear()}`
: undefined
const detail = date || site.domain