import {mergeConfig} from '../../configStore' import {date} from '../types' import type {PublishedDateField, FieldReturn} from '../../types' // *[_type == 'post' && publishedDate > now()] // *[_type == 'post' && publishedDate + "T23:59:59Z" > now()] // *[_type == 'post' && publishedDate > $now] // *[_type == 'post' && dateTime(publishedDate + "T23:59:59Z") > dateTime(now()) + (14 * 24 * 60 * 60)] // +14 days export const publishedDate = ( props?: PublishedDateField, mergeProps?: Partial, ): FieldReturn => { const [currentDate] = new Date().toISOString().split('T') const dateFormat = 'MMMM DD, YYYY' const defaultProps: Partial = { name: 'publishedDate', options: {dateFormat}, initialValue: currentDate, required: true, } return date(mergeConfig('publishedDate', props, mergeProps, defaultProps)) }