Skip to content

Commit

Permalink
πŸ› Check for future date on published news #2524
Browse files Browse the repository at this point in the history
  • Loading branch information
millianapia committed Sep 16, 2024
1 parent 105f369 commit 524c767
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions sanityv3/schemas/documents/news.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,16 @@ export default {
},
prepare(selection) {
const { title, media, description, publishedDate, firstPublishedAt, isCustomDate } = selection
const currentDate = new Date()
const date =
publishedDate && isCustomDate
? formatDate(publishedDate)
: firstPublishedAt
? formatDate(firstPublishedAt)
: 'Not Published'
publishedDate && isCustomDate ? new Date(publishedDate) : firstPublishedAt ? new Date(firstPublishedAt) : null

const displayDate = date && date <= currentDate ? formatDate(date) : 'Not Published'

const ingressBlock = (description || []).find((ingressBlock) => ingressBlock._type === 'block')
return {
title,
subtitle: `Published date: ${date}`,
subtitle: `Published date: ${displayDate}`,
description: ingressBlock
? ingressBlock.children
.filter((child) => child._type === 'span')
Expand Down

0 comments on commit 524c767

Please sign in to comment.