-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #555 from oddbird/oss-sponsors
oss sponsors
- Loading branch information
Showing
17 changed files
with
516 additions
and
267 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// https://opencollective.com/oddbird-open-source/members/all.json | ||
import eleventyFetch from '@11ty/eleventy-fetch'; | ||
|
||
const FilteredProfiles = [ | ||
// if there are backers we need to exclude… | ||
]; | ||
|
||
const getDefaultAvatarUrl = (url) => { | ||
const slug = url.split('/').at(-1); | ||
return slug ? `https://images.opencollective.com/${slug}/avatar.png` : null; | ||
}; | ||
|
||
export default async () => { | ||
try { | ||
const url = | ||
'https://opencollective.com/oddbird-open-source/members/all.json?limit=1000'; | ||
const json = await eleventyFetch(url, { | ||
type: 'json', | ||
duration: '0s', | ||
directory: '.cache/eleventy-fetch/', | ||
dryRun: false, | ||
}); | ||
|
||
const supporters = json | ||
.filter( | ||
(c) => | ||
c.role === 'BACKER' && | ||
c.totalAmountDonated && | ||
!FilteredProfiles.includes(c.name), | ||
) | ||
.map((c) => ({ | ||
name: c.name, | ||
tier: c.tier, | ||
website: c.website || c.profile, | ||
image: c.image || getDefaultAvatarUrl(c.profile), | ||
total: c.totalAmountDonated, | ||
})) | ||
.sort( | ||
(a, b) => | ||
// Sort by total amount donated (desc) | ||
b.total - a.total, | ||
); | ||
|
||
return { | ||
supporters, | ||
}; | ||
} catch (e) { | ||
// eslint-disable-next-line no-console | ||
console.error('Failed fetching Open Collective backers.', e); | ||
return { | ||
supporters: [], | ||
}; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
{% import 'layout.macros.njk' as layout %} | ||
|
||
{% macro block( | ||
supporters, | ||
title='Open Source Sponsors' | ||
) %} | ||
{{ layout.title(title) }} | ||
|
||
<h3>Current Sponsors</h3> | ||
<p> | ||
A huge thank you to the individuals and organizations | ||
sponsoring OddBird's open source work! | ||
</p> | ||
|
||
{{ faces(supporters) }} | ||
|
||
<h3>Sponsor OddBird's OSS Work</h3> | ||
<p> | ||
We love contributing back to the languages & tools | ||
that developers rely on, | ||
from CSS & Sass to browser polyfills and Python. | ||
Help us keep that work sustainable | ||
and focused on developer needs! | ||
</p> | ||
|
||
{{ donate() }} | ||
{% endmacro %} | ||
|
||
{% macro faces(supporters) %} | ||
<div face-pile="donors"> | ||
{% for supporter in supporters -%} | ||
{%- if supporter.image != none -%} | ||
<a | ||
href="{{ supporter.website }}" | ||
data-supporters-tier="{{ supporter.tier | slugify }}" | ||
data-supporters-slug="{{ supporter.name | slugify }}" | ||
rel="sponsored noopener noreferrer" | ||
target="_blank" | ||
>{% ocAvatar supporter.image, supporter.name %}</a> | ||
{%- endif -%} | ||
{%- endfor %} | ||
</div> | ||
{% endmacro %} | ||
|
||
{% macro donate() -%} | ||
<a href="https://opencollective.com/oddbird-open-source" class="donate-link"> | ||
<img | ||
src="https://opencollective.com/oddbird-open-source/donate/[email protected]?color=blue" | ||
alt="Donate to our collective" | ||
width="596" | ||
height="96" | ||
/> | ||
</a> | ||
{%- endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
permalink: /{{ page.fileSlug }}/index.html | ||
oss: owner | ||
sponsors: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* @docs | ||
label: OSS Support Filters | ||
category: File | ||
*/ | ||
|
||
/* @docs | ||
label: openCollectiveAvatar | ||
category: Image | ||
note: Generate Open Collective avatar | ||
params: | ||
url: | ||
type: url | ||
note: image url | ||
username: | ||
type: string | ||
default: '' | ||
*/ | ||
export const openCollectiveAvatar = (url, username = '') => { | ||
const alt = `Open Collective Avatar${username ? ` for ${username}` : ''}`; | ||
const size = 'width="66" height="66"'; | ||
|
||
return `<img src="https://v1.image.11ty.dev/${encodeURIComponent( | ||
url, | ||
)}/webp/66/" ${size} alt="${alt}" loading="lazy" decoding="async">`; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
[data-layout='main'] { | ||
grid-area: main; | ||
margin-block-end: var(--spacer); | ||
} | ||
|
||
[data-main] { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[face-pile] { | ||
display: flex; | ||
flex-wrap: wrap; | ||
gap: var(--shim); | ||
|
||
> * { | ||
border: thin solid; | ||
border-radius: 100%; | ||
flex: none; | ||
overflow: clip; | ||
} | ||
|
||
img { | ||
aspect-ratio: 1; | ||
block-size: 2lh; | ||
inline-size: auto; | ||
max-width: unset; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* eslint-disable max-len */ | ||
|
||
import { openCollectiveAvatar } from '#filters/support.js'; | ||
|
||
describe('support filters', () => { | ||
test('openCollectiveAvatar', () => { | ||
const url = | ||
'https://v1.image.11ty.dev/https%3A%2F%2Fwww.example.com/webp/66/'; | ||
expect(openCollectiveAvatar('https://www.example.com', 'User Name')).toBe( | ||
`<img src="${url}" width="66" height="66" alt="Open Collective Avatar for User Name" loading="lazy" decoding="async">`, | ||
); | ||
expect(openCollectiveAvatar('https://www.example.com')).toBe( | ||
`<img src="${url}" width="66" height="66" alt="Open Collective Avatar" loading="lazy" decoding="async">`, | ||
); | ||
}); | ||
}); |
Oops, something went wrong.