blob: b9198107784cb0102daadcdc6fba272c65c771d8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
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" | "micro">,
b: CollectionEntry<"post" | "note" | "micro">,
) {
return b.data.publishDate.getTime() - a.data.publishDate.getTime();
}
|