blob: 035d157c4d53cdb65fb46e86dda96e2648ed95c6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
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();
}
|