Skip to content

Commit fb53ec8

Browse files
committed
Merge #129: add component to display contributors
8df5b46 change title of defaultContributorsList and remove token (Graeme Byrne) 9841a81 add default values for Contributors.svelte (Graeme Byrne) 158a94e cache requests to github api in store and remove token (Graeme Byrne) dfe74b3 clean up +page.server.ts (Graeme Byrne) ec727a9 fix lint error in +page.server.ts (Graeme Byrne) 65913e9 get list of repos from GitHub API (Graeme Byrne) bc46c91 fix tailwind lint error (Graeme Byrne) 896104f add component to display contributors (Graeme Byrne) Pull request description: * in `routes/(home)/+page.server.ts`, fetch contributors data from GitHub API to use in Torrust repos. * Create a `Contributor` type for data coming from GitHub API and store it in `'$lib/utils/types'` to be imported * Create an array of repo names and store it in `'$lib/constants/constants'` to be imported and reactively mapped over together with a baseURL * Create a Personal Access Token, store it in `.env` and store it in `const token = import.meta.env.VITE_GITHUB_TOKEN;` to order to increase GitHub API rate limits. * Fetch contributor data from multiple GitHub repository URLs concurrently using Promise.all. It sends authenticated GET requests (with a token in the headers) to each URL and parses the JSON response for all the requests. * Flatten the array of contributor arrays into a single array of all contributors. * Remove duplicate contributors from the all contributors array. * Pass array into `routes/(home)/+page.svelte`, which passes it into component `Contributors.svelte` in order to loop over and display each contributor on the home page. * On each of the `(pages)` routes there wasn't responsiveness to make Table of Contents appear above the text on smaller screens and to the left on wider screens, so I added that to each. ACKs for top commit: josecelano: ACK 8df5b46 Tree-SHA512: 71189d32b15e63b460288da401808c830583d20b0f4e46e04feef3f6ef53cf3e54d95b6132970938944db61f6f3fadb991dfc5626cb014993af7dccff6633e8a
2 parents 137417c + 8df5b46 commit fb53ec8

16 files changed

+502
-93
lines changed

package-lock.json

-25
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
"@iconify/svelte": "^4.0.2",
2323
"@melt-ui/pp": "^0.3.2",
2424
"@melt-ui/svelte": "^0.86.0",
25-
"@skeletonlabs/skeleton": "^2.10.3",
26-
"@skeletonlabs/tw-plugin": "^0.4.0",
2725
"@sveltejs/adapter-static": "^3.0.1",
2826
"@sveltejs/kit": "^2.5.25",
2927
"@types/swiper": "^5.4.3",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<script lang="ts">
2+
export let contributors;
3+
export let error;
4+
import { defaultContributorsList } from '$lib/constants/constants';
5+
</script>
6+
7+
<div class="container">
8+
<h2>Contributors</h2>
9+
<p>Here are the people responsible for creating and maintaining Torrust.</p>
10+
<div class="flex">
11+
{#if !error && contributors && contributors.length > 0}
12+
{#each contributors as contributor}
13+
<div>
14+
<a href={contributor.html_url} target="_blank" title={contributor.login}>
15+
<img src={contributor.avatar_url} alt="contributor" />
16+
</a>
17+
</div>
18+
{/each}
19+
{:else}
20+
{#each defaultContributorsList as contributor}
21+
<div>
22+
<a
23+
href="https://github.com/{contributor.html_url}"
24+
target="_blank"
25+
title={contributor.html_url}
26+
>
27+
<img src={contributor.avatar_url} alt="contributor" />
28+
</a>
29+
</div>
30+
{/each}
31+
{/if}
32+
</div>
33+
</div>
34+
35+
<style lang="scss">
36+
@import '$lib/scss/breakpoints.scss';
37+
38+
.container {
39+
margin: 0 auto;
40+
max-width: 800px;
41+
}
42+
43+
.flex {
44+
display: flex;
45+
flex-wrap: wrap;
46+
justify-content: center;
47+
gap: 20px;
48+
padding-top: 2rem;
49+
}
50+
51+
h2 {
52+
text-align: center;
53+
color: rgba(245, 245, 245, 0.96);
54+
padding-top: 4rem;
55+
font-size: 1.8rem;
56+
font-weight: bold;
57+
}
58+
59+
p {
60+
color: rgba(245, 245, 245, 0.96);
61+
text-align: center;
62+
padding-top: 2rem;
63+
}
64+
65+
img {
66+
width: 50px;
67+
border-radius: 50%;
68+
}
69+
</style>

src/lib/components/singletons/TorrustIndexPost.svelte

+14-9
Original file line numberDiff line numberDiff line change
@@ -228,18 +228,12 @@ cd /tmp \
228228
@import '$lib/scss/breakpoints.scss';
229229
230230
.wrapper {
231-
display: grid;
232-
grid-template-columns: 300px 1fr;
233-
gap: 4rem;
231+
display: flex;
232+
flex-direction: column;
233+
gap: 2rem;
234234
position: relative;
235235
}
236236
237-
.wrapper :global(.toc) {
238-
position: sticky;
239-
top: 4rem;
240-
height: min-content;
241-
}
242-
243237
.content-preview {
244238
flex: 1;
245239
word-break: keep-all;
@@ -288,6 +282,17 @@ cd /tmp \
288282
}
289283
290284
@include for-desktop-up {
285+
.wrapper {
286+
flex-direction: row;
287+
gap: 4rem;
288+
}
289+
290+
.wrapper :global(.toc) {
291+
position: sticky;
292+
top: 4rem;
293+
height: min-content;
294+
}
295+
291296
.content-preview {
292297
overflow-y: scroll;
293298
scrollbar-width: none;

src/lib/components/singletons/TorrustTrackerPost.svelte

+14-9
Original file line numberDiff line numberDiff line change
@@ -248,18 +248,12 @@ cd /tmp \
248248
<style lang="scss">
249249
@import '$lib/scss/breakpoints.scss';
250250
.wrapper {
251-
display: grid;
252-
grid-template-columns: 300px 1fr;
253-
gap: 4rem;
251+
display: flex;
252+
flex-direction: column;
253+
gap: 2rem;
254254
position: relative;
255255
}
256256
257-
.wrapper :global(.toc) {
258-
position: sticky;
259-
top: 4rem;
260-
height: min-content;
261-
}
262-
263257
.content-preview {
264258
flex: 1;
265259
word-break: keep-all;
@@ -307,6 +301,17 @@ cd /tmp \
307301
}
308302
309303
@include for-desktop-up {
304+
.wrapper {
305+
flex-direction: row;
306+
gap: 4rem;
307+
}
308+
309+
.wrapper :global(.toc) {
310+
position: sticky;
311+
top: 4rem;
312+
height: min-content;
313+
}
314+
310315
.content-preview {
311316
overflow-y: scroll;
312317
scrollbar-width: none;

0 commit comments

Comments
 (0)