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