import type { CollectionEntry } from "astro:content"; import { siteConfig } from "@/site.config"; export function getFormattedDate( date: Date | undefined, options?: Intl.DateTimeFormatOptions, ): string { if (date === undefined) { return "Invalid Date"; } return new Intl.DateTimeFormat(siteConfig.date.locale, { ...(siteConfig.date.options as Intl.DateTimeFormatOptions), ...options, }).format(date); } export function collectionDateSort( a: CollectionEntry<"post" | "note">, b: CollectionEntry<"post" | "note">, ) { return b.data.date.getTime() - a.data.date.getTime(); }