/** * Given an doc id like `2025-01-01-some-name`, will return a date matching * the starting portion of the id. */ export function idToDate(id: string, fallback: () => Date) { const dateString = /^(?\d{4}-\d{2}-\d{2})/.exec(id)?.groups?.date; return dateString ? new Date(dateString) : fallback(); }