mirror of
https://github.com/zadam/trilium.git
synced 2026-05-07 14:47:27 +02:00
client: retrieve the contributor list
This commit is contained in:
@@ -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});
|
||||
}
|
||||
@@ -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});
|
||||
|
||||
Reference in New Issue
Block a user