Initial commit

This commit is contained in:
KazooTTT
2025-02-05 14:07:58 +08:00
committed by GitHub
commit ea645368e9
85 changed files with 11210 additions and 0 deletions

23
src/utils/date.ts Normal file
View File

@ -0,0 +1,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">,
b: CollectionEntry<"post" | "note">,
) {
return b.data.publishDate.getTime() - a.data.publishDate.getTime();
}