mirror of
https://github.com/fmhy/edit.git
synced 2026-01-18 01:41:52 +11:00
posts setup
This commit is contained in:
parent
8f457fa166
commit
5ae23bea33
14 changed files with 528 additions and 229 deletions
9
.vitepress/utils.ts
Normal file
9
.vitepress/utils.ts
Normal 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[]>,
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue