Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
client: retrieve the contributor list
Adorian Doran6481b90daf22
diff --git a/apps/client/src/services/contributors_list.ts b/apps/client/src/services/contributors_list.tsindex 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 filediff --git a/apps/client/vite.config.mts b/apps/client/vite.config.mtsindex 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});