diff --git a/src/app/db/data.ts b/src/app/db/data.ts index a5a1c73..42163a9 100644 --- a/src/app/db/data.ts +++ b/src/app/db/data.ts @@ -441,7 +441,7 @@ export const authors: Readonly<{ [key: string]: Author }> = { 'Student@srvhs', ], image: '/img/profiles/wlin.jpg', - nationality: ['twn', 'chn', 'usa'], + nationality: ['twn', 'chn', 'jpn', 'usa'], formerAffiliations: ['Intern@raid-zero'], bio: 'Hi, I am Kaito or Warren. I am a Self-taught programmer and engineer. I go around doing dumb things such as my projects. I have a dream of building a community. I am currently part of many projects.', website: 'https://kaitotlex.carrd.co/', @@ -468,7 +468,7 @@ export const authors: Readonly<{ [key: string]: Author }> = { 'Mentor@team-1280', ], formerAffiliations: ['Captain@team-1280', 'Student@srvhs'], - nationality: ['usa'], + nationality: ['irl', 'usa'], image: '/img/profiles/edanko.jpg', }, arvenkatesh: { @@ -768,6 +768,11 @@ export const nationalities: Readonly<{ [key: string]: Nationality }> = { demonym: 'Filipino', flag: 'https://upload.wikimedia.org/wikipedia/commons/thumb/9/99/Flag_of_the_Philippines.svg/2880px-Flag_of_the_Philippines.svg.png', }, + irl: { + name: 'Republic of Ireland', + demonym: 'Irish', + flag: 'https://upload.wikimedia.org/wikipedia/commons/4/45/Flag_of_Ireland.svg', + }, unknown: { name: 'Undetermined', demonym: 'Undetermined', diff --git a/src/app/page.tsx b/src/app/page.tsx index 1132f39..480b3ad 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -1,28 +1,65 @@ import Link from 'next/link' -import { documents, authors, affiliations } from './db/data' +import { documents, authors, affiliations, Author } from './db/data' import News from './components/News' import RandomDocs from './components/RandomDocs' import RecentDocuments from './components/RecentDocuments' +function sortAuthorsByDocumentsPublished(authors: { + [key: string]: Author +}): { id: string; author: Author }[] { + // Initialize a map to count documents for each author + const authorDocumentCount: { [key: string]: number } = {} + + // Iterate over documents to count the number for each author + Object.values(documents).forEach((document) => { + document.manifest.authors.forEach((authorId) => { + if (authorDocumentCount[authorId]) { + authorDocumentCount[authorId] += 1 + } else { + authorDocumentCount[authorId] = 1 + } + }) + }) + + // Convert the authors object into an array of objects including the author ID + const authorsWithId = Object.keys(authors).map((id) => ({ + id, + author: authors[id], + count: authorDocumentCount[id] || 0, // Include the count for sorting + })) + + // Sort authors by their document count in descending order + authorsWithId.sort((a, b) => b.count - a.count) + + // Return the sorted array, excluding the count property + return authorsWithId.map(({ id, author }) => ({ id, author })) +} + export default function Home() { const AuthorDisplay = () => { - return Object.entries(authors).map(([author, data], index) => { - let affiliationSlug = data.affiliation[0].split('@')[1] - let affiliation = affiliations[affiliationSlug] - return ( -