mirror of
https://github.com/KazooTTT/kazoottt-blog-v2.git
synced 2025-06-21 09:41:29 +08:00
24 lines
593 B
TypeScript
24 lines
593 B
TypeScript
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();
|
|
}
|