UNPKG

@sanity/scheduled-publishing

Version:

> [!IMPORTANT] > As of [v3.39.0](https://www.sanity.io/changelog/e6013ee5-8214-4e03-9593-f7b19124b8a3) of Sanity Studio, this plugin has been deprecated and the Scheduled Publishing functionality has been moved into the core studio package. > Read more an

21 lines (18 loc) 595 B
import type {Schedule} from '../types' import {getLastExecuteDate} from './scheduleUtils' export function sortByExecuteDate({reverseOrder}: {reverseOrder: boolean} = {reverseOrder: false}) { return function (a: Schedule, b: Schedule): number { const aExecuteDate = getLastExecuteDate(a) const bExecuteDate = getLastExecuteDate(b) if (aExecuteDate === bExecuteDate) { return 0 } if (aExecuteDate === null) { return 1 } if (bExecuteDate === null) { return -1 } return (aExecuteDate > bExecuteDate ? 1 : -1) * (reverseOrder ? -1 : 1) } }