Skip to content

Build your personal knowledge base with Trilium Notes

client/contributor list: add support for honorific contributors

Adorian Doran92f10489115f
diff --git a/apps/client/src/services/contributors_list.ts b/apps/client/src/services/contributors_list.ts
index 060b9c6dda..ab1f6c1755 100644
--- a/apps/client/src/services/contributors_list.ts
+++ b/apps/client/src/services/contributors_list.ts
@@ -7,6 +7,10 @@ export interface Contributor {
url: string;
}
+// Keep honorific contributors at top of the list, even if their commit count
+// is exceeded by another users.
+const PINNED_CONTRIBUTORS = ["eliandoran", "zadam"];
+
export default async function getContributors() {
const response = await fetch("https://api.github.com/repos/TriliumNext/Trilium/contributors");
@@ -21,10 +25,25 @@ export default async function getContributors() {
function getList(contributorInfo: any[]) {
return contributorInfo
+ // Filter out bots and private profiles
.filter((c) => c.type === "User" && c.user_view_type === "public")
- .sort((a, b) => b.contributions - a.contributions)
+ // Sort by the commit count. Honorific contributors are always first.
+ .sort(contributorOrderer)
.map((c) => {return {
name: c.login,
url: c.html_url
} as Contributor});
+}
+
+function contributorOrderer(a, b) {
+ const isAPinned = PINNED_CONTRIBUTORS.includes(a.login);
+ const isBPinned = PINNED_CONTRIBUTORS.includes(b.login);
+
+ // Pinned contributors come first
+ if (isAPinned !== isBPinned) {
+ return isAPinned ? -1 : 1;
+ }
+
+ // Within each group, sort by contributions
+ return b.contributions - a.contributions;
}
\ No newline at end of file