Skip to content

Commit 6e0da87

Browse files
committed
Add a page for contributors
1 parent 8816ff3 commit 6e0da87

File tree

6 files changed

+127
-8
lines changed

6 files changed

+127
-8
lines changed

src/lib/constants/footer/links.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import {
99
PencilSquare,
1010
Calendar,
1111
RectangleGroup,
12-
Cog
12+
Cog,
13+
UserGroup
1314
} from 'svelte-hero-icons';
1415

1516
type Link = {
@@ -99,6 +100,11 @@ export const links: LinkGroup[] = [
99100
name: i('nav.footer.else.holiday'),
100101
action: () => goto('/holiday'),
101102
icon: Calendar
103+
},
104+
{
105+
name: i('nav.footer.else.contributors'),
106+
action: () => goto('/contributions'),
107+
icon: UserGroup
102108
}
103109
]
104110
}

src/lib/constants/launcher.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import {
1515
UserMinus,
1616
PaintBrush,
1717
ViewColumns,
18-
type IconSource
18+
type IconSource,
19+
UserGroup
1920
} from 'svelte-hero-icons';
2021
import { derived, type Readable } from 'svelte/store';
2122

@@ -173,6 +174,16 @@ export const launcherItems: LauncherItem[] = [
173174
},
174175
searchTerms: split(i('launcher.holidays.terms'))
175176
},
177+
{
178+
label: i('launcher.contributions'),
179+
description: null,
180+
icon: UserGroup,
181+
callback: () => {
182+
goto('/contributions');
183+
closeLauncher();
184+
},
185+
searchTerms: split(i('launcher.contributions.terms'))
186+
},
176187
{
177188
label: i('launcher.logout'),
178189
description: null,

src/lib/locales/de.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ const de = {
5151
'launcher.settings.color.terms': 'Farben\nBunt',
5252
'launcher.settings.timetable': 'Stundenplan',
5353
'launcher.settings.timetable.terms': 'Stundenplan\nZeit',
54+
'launcher.contributions': 'Mitwirkende',
55+
'launcher.contributions.terms': 'Mitwirkende\nHelfende',
5456
'launcher.logout': 'Ausloggen',
5557
'launcher.logout.terms': 'Signout\nAnonymous',
5658
'launcher.holidays': 'Ferien',
@@ -110,6 +112,7 @@ const de = {
110112
'nav.footer.else': 'Sonstige',
111113
'nav.footer.else.settings': 'Einstellungen',
112114
'nav.footer.else.holiday': 'Ferien',
115+
'nav.footer.else.contributors': 'Mitwirkende',
113116

114117
title: 'Startseite',
115118
'title.calendar': 'Kalendar',
@@ -624,6 +627,16 @@ Deine bisherigen Einstellungen sind leider nicht mit der neuen Version kompatibe
624627
'tags.new.success': 'Erfolgreich Tag $tag erstellt',
625628
'tags.new.error.alreadyTaken': 'Dieses Tag existiert bereits',
626629

630+
'contributions.title': 'Mitwirkende',
631+
'contributions.count': {
632+
counts: {
633+
default: '$contributions Beiträge',
634+
1: 'Ein Beitrag',
635+
2: 'Zwei Beiträge',
636+
3: 'Drei Beiträge'
637+
}
638+
},
639+
627640
literal: '$literal'
628641
} as const satisfies I18nDict;
629642

src/lib/locales/en.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ const en = {
4949
'launcher.settings.color.terms': 'Colors',
5050
'launcher.settings.timetable': 'Timetable',
5151
'launcher.settings.timetable.terms': 'Timetable\nSchedule',
52+
'launcher.contributions': 'Contributors',
53+
'launcher.contributions.terms': 'Contributors',
5254
'launcher.logout': 'Ausloggen',
5355
'launcher.logout.terms': 'Abmelden\nAnonym',
5456
'launcher.holidays': 'Holidays',
@@ -107,6 +109,7 @@ const en = {
107109
'nav.footer.else': 'Else',
108110
'nav.footer.else.settings': 'Settings',
109111
'nav.footer.else.holiday': 'Holiday',
112+
'nav.footer.else.contributors': 'Contributors',
110113

111114
title: 'Homepage',
112115
'title.calendar': 'Calendar',
@@ -611,6 +614,16 @@ Your current settings sadly won't be compatible withthe new version. But you can
611614
'tags.new.success': 'Successfully created Tag $tag',
612615
'tags.new.error.alreadyTaken': 'This tag already exists',
613616

617+
'contributions.title': 'Contributors',
618+
'contributions.count': {
619+
counts: {
620+
default: '$contributions contributions',
621+
1: 'One contribution',
622+
2: 'Two contribution',
623+
3: 'Three contribution'
624+
}
625+
},
626+
614627
literal: '$literal'
615628
} as const satisfies I18nDict;
616629

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,48 @@
1+
import { z } from 'zod';
12
import type { PageServerLoad } from './$types';
3+
import { fromEntries, objectEntries } from '$lib/utils/objects/entries';
24

35
export const prerender = true;
46

7+
const REPOS = {
8+
frontend: 'Dlurak/dlool_frontend_v2',
9+
backend: 'Dlurak/dlool_backend_v2'
10+
} as const satisfies Record<'frontend' | 'backend', string>;
11+
12+
const scheme = z.array(
13+
z.object({
14+
login: z.string(),
15+
id: z.number(),
16+
node_id: z.string(),
17+
avatar_url: z.string(),
18+
gravatar_id: z.string(),
19+
url: z.string(),
20+
html_url: z.string(),
21+
followers_url: z.string(),
22+
following_url: z.string(),
23+
gists_url: z.string(),
24+
starred_url: z.string(),
25+
subscriptions_url: z.string(),
26+
organizations_url: z.string(),
27+
repos_url: z.string(),
28+
events_url: z.string(),
29+
received_events_url: z.string(),
30+
type: z.string(),
31+
site_admin: z.boolean(),
32+
contributions: z.number()
33+
})
34+
);
35+
536
export const load: PageServerLoad = async ({ fetch }) => {
6-
const test = await fetch(
7-
'https://api.github.com/repos/dlurak/dlool_frontend_v2/collaborators'
8-
).then((r) => r.json());
9-
console.log(test);
10-
return {};
37+
const data = objectEntries(REPOS).map(([key, value]) => {
38+
const url = `https://api.github.com/repos/${value}/contributors` as const;
39+
const data = fetch(url)
40+
.then((r) => r.json())
41+
.then(scheme.parse);
42+
return Promise.all([Promise.resolve(key), data]);
43+
});
44+
45+
const entries = await Promise.all(data);
46+
47+
return { contributions: fromEntries(entries) };
1148
};

src/routes/contributions/+page.svelte

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,46 @@
11
<script lang="ts">
2+
import MetaData from '$lib/components/utils/MetaData.svelte';
3+
import Store from '$lib/components/utils/Store.svelte';
4+
import { i } from '$lib/i18n/store';
5+
import { fmtNum } from '$lib/utils/intl';
6+
import { objectEntries } from '$lib/utils/objects/entries';
27
import type { PageServerData } from './$types';
38
49
export let data: PageServerData;
510
</script>
611

7-
{JSON.stringify(data)}
12+
<MetaData title={i('contributions.title')} />
13+
14+
<div class="flex w-full flex-col gap-2">
15+
{#each objectEntries(data.contributions) as [category, contris]}
16+
<section>
17+
<h2 class="mb-2 border-b border-b-zinc-300 dark:border-b-zinc-800">{category}</h2>
18+
<div class="flex gap-2 py-2">
19+
{#each contris as con}
20+
<div
21+
class="
22+
flex flex-col gap-2 rounded px-2 py-1 outline outline-2 outline-zinc-300
23+
dark:outline-zinc-700
24+
"
25+
>
26+
<img src={con.avatar_url} alt="" class="h-36 w-36 rounded" loading="lazy" />
27+
<span class="flex flex-col text-center">
28+
<a class="text-lg" href={con.html_url}>
29+
{con.login}
30+
</a>
31+
<span class="text-sm">
32+
<Store
33+
store={i(
34+
'contributions.count',
35+
{ contributions: fmtNum(con.contributions) },
36+
{ count: con.contributions }
37+
)}
38+
/>
39+
</span>
40+
</span>
41+
</div>
42+
{/each}
43+
</div>
44+
</section>
45+
{/each}
46+
</div>

0 commit comments

Comments
 (0)