20 lines
796 B
TypeScript
20 lines
796 B
TypeScript
import { getEntry, type CollectionEntry } from "astro:content";
|
|
import type { CopyrightedCharacters } from "../content/config";
|
|
|
|
export async function formatCopyrightedCharacters(copyrightedCharacters: CopyrightedCharacters) {
|
|
return await Promise.all(
|
|
Object.values(
|
|
Object.keys(copyrightedCharacters).reduce(
|
|
(acc, character) => {
|
|
const user = copyrightedCharacters[character];
|
|
if (!(user.id in acc)) {
|
|
acc[user.id] = [getEntry(user), []];
|
|
}
|
|
acc[user.id][1].push(character);
|
|
return acc;
|
|
},
|
|
{} as Record<string, [Promise<CollectionEntry<"users">>, string[]]>,
|
|
),
|
|
).map(async ([userPromise, characters]) => [await userPromise, characters] as [CollectionEntry<"users">, string[]]),
|
|
);
|
|
}
|