2026-06-29 10:48:48 -04:00
|
|
|
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(
|
2026-06-30 12:03:32 -04:00
|
|
|
a: CollectionEntry<"writing" | "projects">,
|
|
|
|
|
b: CollectionEntry<"writing" | "projects">,
|
2026-06-29 10:48:48 -04:00
|
|
|
) {
|
|
|
|
|
return b.data.publishDate.getTime() - a.data.publishDate.getTime();
|
|
|
|
|
}
|