posts setup

This commit is contained in:
taskylizard 2023-12-31 06:57:10 +00:00
parent 8f457fa166
commit 5ae23bea33
No known key found for this signature in database
GPG key ID: 1820131ED1A24120
14 changed files with 528 additions and 229 deletions

9
.vitepress/utils.ts Normal file
View file

@ -0,0 +1,9 @@
export function groupBy<T, K extends keyof any>(arr: T[], key: (i: T) => K): Record<K, T[]> {
return arr.reduce(
(groups, item) => {
(groups[key(item)] ||= []).push(item);
return groups;
},
{} as Record<K, T[]>,
);
}