Toolkit for fetching sponsors info and generating sponsors images.
Supports:
Usage
Create .env
file with:
SPONSORKIT_GITHUB_TOKEN=
SPONSORKIT_GITHUB_LOGIN=
SPONSORKIT_PATREON_TOKEN=
SPONSORKIT_OPENCOLLECTIVE_KEY=
SPONSORKIT_OPENCOLLECTIVE_ID=
SPONSORKIT_OPENCOLLECTIVE_SLUG=
SPONSORKIT_OPENCOLLECTIVE_GH_HANDLE=
SPONSORKIT_OPENCOLLECTIVE_TYPE=
SPONSORKIT_AFDIAN_USER_ID=
SPONSORKIT_AFDIAN_TOKEN=
SPONSORKIT_POLAR_TOKEN=
SPONSORKIT_POLAR_ORGANIZATION=
Only one provider is required to be configured.
Run:
npx sponsorkit
Example Setup | GitHub Actions Setup | Generated SVG
Configurations
Create sponsorkit.config.js
file with:
import { defineConfig, tierPresets } from 'sponsorkit'
export default defineConfig({
github: {
login: 'antfu',
type: 'user',
},
opencollective: {
},
patreon: {
},
afdian: {
},
polar: {
},
width: 800,
renderer: 'tiers',
formats: ['json', 'svg', 'png'],
tiers: [
{
title: 'Past Sponsors',
monthlyDollars: -1,
preset: tierPresets.xs,
},
{
title: 'Backers',
preset: tierPresets.base,
},
{
title: 'Sponsors',
monthlyDollars: 10,
preset: tierPresets.medium,
},
{
title: 'Silver Sponsors',
monthlyDollars: 50,
preset: tierPresets.large,
},
{
title: 'Gold Sponsors',
monthlyDollars: 100,
preset: tierPresets.xl,
},
],
})
Also check the example.
Programmatic Utilities
You can also use SponsorKit programmatically:
import { fetchSponsors } from 'sponsorkit'
const sponsors = await fetchSponsors(token, login)
Check the type definition or source code for more utils available.
Renderers
We provide two renderers built-in:
tiers
: Render sponsors in tiers.circles
: Render sponsors in packed circles.
Tiers Renderer
export default defineConfig({
renderer: 'tiers',
})
Circles Renderer
export default defineConfig({
renderer: 'circles',
})
Multiple Renders
We also support rendering multiple images at once with different configurations, via renders
field:
import { defineConfig, tierPresets } from 'sponsorkit'
export default defineConfig({
github: { },
width: 800,
tiers: [
],
renders: [
{
name: 'sponsors.tiers',
formats: ['svg'],
},
{
name: 'sponsors.wide',
width: 1200,
},
{
name: 'sponsors.circles',
renderer: 'circles',
width: 600,
},
],
})
License
MIT License © 2022 Anthony Fu