import { h } from 'preact'; import PropTypes from 'prop-types'; import { Dropdown, ButtonNew as Button } from '@crayons'; import CogIcon from '@images/cog.svg'; /** * Component comprising a trigger button and dropdown with additional post options. * * @param {Object} props * @param {Object} props.passedData The current post options data * @param {Function} props.onSaveDraft Callback for when the post draft is saved * @param {Function} props.onConfigChange Callback for when the config options have changed */ function toISOStringLocal(datetime) { const month = (datetime.getMonth() + 1).toString().padStart(2, '0'); const day = datetime.getDate().toString().padStart(2, '0'); return [ datetime.getFullYear(), '-', month, '-', day, 'T', datetime.toLocaleTimeString(), ].join(''); } export const Options = ({ passedData: { published = false, publishedAt = '', timezone = Intl.DateTimeFormat().resolvedOptions().timeZone, allSeries = [], canonicalUrl = '', series = '', }, schedulingEnabled, onSaveDraft, onConfigChange, previewLoading, }) => { let publishedField = ''; let existingSeries = ''; let publishedAtField = ''; const publishedDate = new Date(publishedAt); const currentDate = new Date(); const localPublishedAt = toISOStringLocal(publishedDate); const minPublishedAt = toISOStringLocal(currentDate); const readonlyPublishedAt = published && publishedDate < currentDate; if (allSeries.length > 0) { const seriesNames = allSeries.map((name, index) => { return ( ); }); existingSeries = (
Change meta tag
{` `}
canonical_url
{` `}
if this post was first published elsewhere (like your own blog).
Will this post be part of a series? Give the series a unique name. (Series visible once it has multiple posts)
{existingSeries}