refactor: remove repo name repitition

This commit is contained in:
afn 2022-10-12 15:30:06 -04:00
parent 3dbf275443
commit 7328c700f5
3 changed files with 6 additions and 20 deletions

View File

@ -1,15 +1,15 @@
<script lang="ts"> <script lang="ts">
export let username: string; export let name: string;
export let pfp: string; export let pfp: string;
export let url: string; export let url: string;
let alt = `${username}'s contributor profile picture` let alt = `${name}'s profile picture`
</script> </script>
<a href={url} target="_blank"> <a href={url} target="_blank">
<button> <button>
<img src={pfp} alt={alt}><slot/> <img src={pfp} alt={alt}><slot/>
</button> </button>
<h2>{username}</h2> <h2>{name}</h2>
</a> </a>
<style> <style>

View File

@ -11,7 +11,7 @@
onMount (() => { onMount (() => {
ContributorsStore.subscribe(async (data) => { ContributorsStore.subscribe(async (data) => {
contribs = await data; contribs = await data;
contribs = contribs[repo] contribs = contribs[repo].contributors
}); });
}); });
@ -29,7 +29,7 @@
<div class="contrib-host"> <div class="contrib-host">
{#each contribs as contrib} {#each contribs as contrib}
{#if !usersIwantToExplodeSoBadly.includes(contrib.login)} {#if !usersIwantToExplodeSoBadly.includes(contrib.login)}
<ContributorButton username={contrib.login} pfp={contrib.avatar_url} url={contrib.html_url} /> <ContributorButton name={contrib.login} pfp={contrib.avatar_url} url={contrib.html_url} />
{/if} {/if}
{/each} {/each}
</div> </div>

View File

@ -1,25 +1,11 @@
import { readable } from "svelte/store"; import { readable } from "svelte/store";
const fetchContributors = async () => { const fetchContributors = async () => {
let cli,
patcher,
patches,
integrations,
manager;
const response = await fetch('https://releases.rvcd.win/contributors'); const response = await fetch('https://releases.rvcd.win/contributors');
const json = await response.json(); const json = await response.json();
({ 0: cli, 1: patcher, 2: patches, 3: integrations, 4: manager } = json.repositories); let { 0: cli, 1: patcher, 2: patches, 3: integrations, 4: manager } = json.repositories;
cli = cli.contributors
patcher = patcher.contributors
patches = patches.contributors
integrations = integrations.contributors
manager = manager.contributors
return {cli, patcher, patches, integrations, manager}; return {cli, patcher, patches, integrations, manager};
}; };
const ContributorsStore = readable(fetchContributors()); const ContributorsStore = readable(fetchContributors());