[site] only show 20 avatars instead of current massive wall (#6974)

pull/6981/head
Ben McCann 3 years ago committed by GitHub
parent fe36911017
commit c2149e8529
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -20,7 +20,8 @@ if (!force && fs.existsSync(outputFile)) {
const base = `https://api.github.com/repos/sveltejs/svelte/contributors`; const base = `https://api.github.com/repos/sveltejs/svelte/contributors`;
const { GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET } = process.env; const { GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET } = process.env;
const SIZE = 64; const MAX = 20;
const SIZE = 128;
async function main() { async function main() {
const contributors = []; const contributors = [];
@ -37,7 +38,8 @@ async function main() {
const authors = contributors const authors = contributors
.filter(({ login }) => !login.includes('[bot]')) .filter(({ login }) => !login.includes('[bot]'))
.sort((a, b) => b.contributions - a.contributions); .sort((a, b) => b.contributions - a.contributions)
.slice(0, MAX);
const sprite = new Jimp(SIZE * authors.length, SIZE); const sprite = new Jimp(SIZE * authors.length, SIZE);

@ -17,7 +17,8 @@ if (!force && fs.existsSync(outputFile)) {
process.exit(0); process.exit(0);
} }
const SIZE = 64; const MAX = 20;
const SIZE = 128;
async function main() { async function main() {
const res = await fetch('https://opencollective.com/svelte/members/all.json'); const res = await fetch('https://opencollective.com/svelte/members/all.json');
@ -28,12 +29,13 @@ async function main() {
let backers = [...unique.values()] let backers = [...unique.values()]
.filter(({ role }) => role === 'BACKER') .filter(({ role }) => role === 'BACKER')
.sort((a, b) => b.totalAmountDonated - a.totalAmountDonated); .sort((a, b) => b.totalAmountDonated - a.totalAmountDonated)
.slice(0, 3 * MAX);
const included = []; const included = [];
for (let i = 0; i < backers.length; i += 1) { for (let i = 0; included.length < MAX; i += 1) {
const backer = backers[i]; const backer = backers[i];
console.log(`${i} / ${backers.length}: ${backer.name}`); console.log(`${included.length + 1} / ${MAX}: ${backer.name}`);
try { try {
const image_data = await fetch(backer.image); const image_data = await fetch(backer.image);

@ -3,24 +3,32 @@
</script> </script>
<style> <style>
#contributors {
margin: 0.4em 0;
}
.contributor { .contributor {
width: 2.4em; width: 4.2em;
height: 2.4em; height: 4.2em;
border-radius: 50%; border-radius: 50%;
text-indent: -9999px; text-indent: -9999px;
display: inline-block; display: inline-block;
background: no-repeat url(/contributors.jpg); background: no-repeat url(/contributors.jpg);
background-size: auto 102%; background-size: auto 102%;
margin: 0 0.5em 0.5em 0; margin: 0 1.5em 1.5em 0;
border: 2px solid var(--second); border: 2px solid var(--second);
} }
</style> </style>
{#each contributors as contributor, i} <div id="contributors">
<a {#each contributors as contributor, i}
class="contributor" <a
style="background-position: {(100 * i) / (contributors.length - 1)}% 0" class="contributor"
href="https://github.com/{contributor}"> style="background-position: {(100 * i) / (contributors.length - 1)}% 0"
{contributor} href="https://github.com/{contributor}">
</a> {contributor}
{/each} </a>
{/each}
</div>
<p>And so <a href="https://github.com/sveltejs/svelte/graphs/contributors">many more →</a></p>

@ -3,25 +3,33 @@
</script> </script>
<style> <style>
#donors {
margin: 0.4em 0;
}
.donor { .donor {
width: 2.4em; width: 4.2em;
height: 2.4em; height: 4.2em;
border-radius: 50%; border-radius: 50%;
text-indent: -9999px; text-indent: -9999px;
display: inline-block; display: inline-block;
background: no-repeat url(/donors.jpg); background: no-repeat url(/donors.jpg);
background-size: auto 102%; background-size: auto 102%;
margin: 0 0.5em 0.5em 0; margin: 0 1.5em 1.5em 0;
border: 2px solid var(--second); border: 2px solid var(--second);
} }
</style> </style>
{#each donors as donor, i} <div id="donors">
<a {#each donors as donor, i}
class="donor" <a
style="background-position: {(100 * i) / (donors.length - 1)}% 0" class="donor"
alt="{donor}" style="background-position: {(100 * i) / (donors.length - 1)}% 0"
href="https://opencollective.com/svelte"> alt="{donor}"
{donor} href="https://opencollective.com/svelte">
</a> {donor}
{/each} </a>
{/each}
</div>
<p>And so <a href="https://opencollective.com/svelte">many more →</a></p>

@ -120,13 +120,13 @@ npm run dev
<p>Svelte is free and open source software, made possible by the work of hundreds of volunteers and donors. <a href="https://github.com/sveltejs/svelte">Join us</a> or <a href="https://opencollective.com/svelte">give</a>!</p> <p>Svelte is free and open source software, made possible by the work of hundreds of volunteers and donors. <a href="https://github.com/sveltejs/svelte">Join us</a> or <a href="https://opencollective.com/svelte">give</a>!</p>
<h3>Contributors</h3> <h4>Contributors</h4>
<Contributors/> <Contributors/>
<p></p> <p></p>
<h3>Donors</h3> <h4>Donors</h4>
<Donors/> <Donors/>
</Section> </Section>

Loading…
Cancel
Save