client: retrieve the contributor list

This commit is contained in:
Adorian Doran
2026-03-21 19:59:19 +02:00
parent 4d753398c1
commit 6481b90daf
2 changed files with 36 additions and 3 deletions

View File

@@ -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});
}

View File

@@ -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});