From 6481b90daf22aec878b41b0f2fa6040daf7fe4d2 Mon Sep 17 00:00:00 2001 From: Adorian Doran Date: Sat, 21 Mar 2026 19:59:19 +0200 Subject: [PATCH] client: retrieve the contributor list --- apps/client/src/services/contributors_list.ts | 29 ++++++++++++++++++- apps/client/vite.config.mts | 10 +++++-- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/apps/client/src/services/contributors_list.ts b/apps/client/src/services/contributors_list.ts index d2daf1921a..060b9c6dda 100644 --- a/apps/client/src/services/contributors_list.ts +++ b/apps/client/src/services/contributors_list.ts @@ -1,3 +1,30 @@ +export interface ContributorList { + contributors: Contributor[]; +} + +export interface Contributor { + name: string; + url: string; +} + export default async function getContributors() { - return {contributors: []} + const response = await fetch("https://api.github.com/repos/TriliumNext/Trilium/contributors"); + + if (response.ok) { + return { + contributors: getList(await response.json()) + } as ContributorList + } else { + throw new Error(`Unable to request the contributor list from GitHub. Reason: ${response.statusText}`); + } +} + +function getList(contributorInfo: any[]) { + return contributorInfo + .filter((c) => c.type === "User" && c.user_view_type === "public") + .sort((a, b) => b.contributions - a.contributions) + .map((c) => {return { + name: c.login, + url: c.html_url + } as Contributor}); } \ No newline at end of file diff --git a/apps/client/vite.config.mts b/apps/client/vite.config.mts index 29ad43db20..08effeea2f 100644 --- a/apps/client/vite.config.mts +++ b/apps/client/vite.config.mts @@ -14,8 +14,14 @@ const isDev = process.env.NODE_ENV === "development"; const buildContributorListPlugin = { name: "build-contributor-list-plugin", writeBundle: async () => { - console.log("Retrieving the contributors list..."); - const jsonData = await getContributors(); + console.log("Retrieving the contributor list..."); + + let jsonData: any = {}; + try { + jsonData = await getContributors(); + } catch (ex) { + console.error(ex); + } const assetsDir = resolve(__dirname, "dist/assets"); mkdirSync(assetsDir, {recursive: true});