diff --git a/src/app/author/page.tsx b/src/app/author/page.tsx index 9d11a7b..0144594 100644 --- a/src/app/author/page.tsx +++ b/src/app/author/page.tsx @@ -1,4 +1,4 @@ -import { affiliations, authors } from '@/app/db/data' +import { affiliations, authors, documents } from '@/app/db/data' import cardEffects from '@/app/styles/cardEffects.module.css' import { Zilla_Slab } from 'next/font/google' import Image from 'next/image' @@ -53,20 +53,32 @@ const AuthorCard = ({ ) } +const getNumberOfDocumentsByAuthor = (authorId: string) => { + // Filter documents by author + const filteredDocuments = Object.entries(documents) + .filter(([_, doc]) => doc.manifest.authors.includes(authorId)) + .map(([slug, doc]) => ({ slug, doc })) + + return filteredDocuments.length +} + const Page = () => { + const sortedAuthors = Object.entries(authors).sort((a, b) => { + const numDocsA = getNumberOfDocumentsByAuthor(a[0]) + const numDocsB = getNumberOfDocumentsByAuthor(b[0]) + return numDocsB - numDocsA + }) + return (

Authors

- {Object.keys(authors).map((authorShortName) => { + {sortedAuthors.map((entry) => { return ( - - + + ) })}