@simon_he/sponsorkit
v0.0.9
Published
Toolkit for generating sponsors images
Downloads
20
Readme
SponsorKit
Toolkit for generating sponsors images. Supports GitHub Sponsors, Patreon, OpenCollective and Afdian.
Usage
Create .env
file with:
; GitHub provider.
; Token requires the `read:user` and `read:org` scopes.
SPONSORKIT_GITHUB_TOKEN=
SPONSORKIT_GITHUB_LOGIN=
; Patreon provider.
; Create v2 API key at https://www.patreon.com/portal/registration/register-clients
; and use the "Creator’s Access Token".
SPONSORKIT_PATREON_TOKEN=
; OpenCollective provider.
; Create an API key at https://opencollective.com/applications
SPONSORKIT_OPENCOLLECTIVE_KEY=
; and provide the ID, slug or GitHub handle of your account.
SPONSORKIT_OPENCOLLECTIVE_ID=
; or
SPONSORKIT_OPENCOLLECTIVE_SLUG=
; or
SPONSORKIT_OPENCOLLECTIVE_GH_HANDLE=
; If it is a personal account, set it to `person`. Otherwise not set or set to `collective`
SPONSORKIT_OPENCOLLECTIVE_TYPE=
; Afdian provider.
; Get user_id at https://afdian.net/dashboard/dev
SPONSORKIT_AFDIAN_USER_ID=
; Create token at https://afdian.net/dashboard/dev
SPONSORKIT_AFDIAN_TOKEN=
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, presets } from '@simon_he/sponsorkit'
import { customGithubUser } from './sponsors'
const customGithubUser = [
{
user: 'github_username',
monthlyDollars: 666,
}
]
export default defineConfig({
// includePrivate: true,
type: 'all',
tiers: [
{
title: 'Past Sponsors',
monthlyDollars: -1,
preset: presets.xs,
},
{
title: 'Backers',
// to replace the entire tier rendering
// compose: (composer, tierSponsors, config) => {
// composer.addRaw(
// '<-- custom svg -->',
// )
// },
},
{
title: 'Sponsors',
monthlyDollars: 10,
preset: presets.medium,
// to insert custom elements after the tier block
composeAfter: (composer, _tierSponsors, _config) => {
composer.addSpan(10)
},
},
{
title: 'Silver Sponsors',
monthlyDollars: 50,
preset: presets.large,
},
{
title: 'Gold Sponsors',
monthlyDollars: 100,
preset: presets.xl,
},
],
customGithubUser
})
Also check the example.
Utils
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.
Sponsors
MIT License © 2022 Anthony Fu