Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/antfu-collective/sponsorkit
π Toolkit for generating sponsors images π
https://github.com/antfu-collective/sponsorkit
github-sponsors sponsors
Last synced: about 2 months ago
JSON representation
π Toolkit for generating sponsors images π
- Host: GitHub
- URL: https://github.com/antfu-collective/sponsorkit
- Owner: antfu-collective
- License: mit
- Created: 2022-02-24T16:26:20.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-17T06:16:49.000Z (4 months ago)
- Last Synced: 2024-05-20T02:15:33.680Z (4 months ago)
- Topics: github-sponsors, sponsors
- Language: TypeScript
- Homepage:
- Size: 527 KB
- Stars: 629
- Watchers: 4
- Forks: 46
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SponsorKit
[![NPM version](https://img.shields.io/npm/v/sponsorkit?color=a1b858&label=)](https://www.npmjs.com/package/sponsorkit)
Toolkit for fetching sponsors info and generating sponsors images.
Supports:
- [**GitHub Sponsors**](https://github.com/sponsors)
- [**Patreon**](https://www.patreon.com/)
- [**OpenCollective**](https://opencollective.com/)
- [**Afdian**](https://afdian.net/)
- [**Polar**](https://polar.sh/)## Usage
Create `.env` file with:
```ini
; 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=; Polar provider.
; Get your token at https://polar.sh/settings
SPONSORKIT_POLAR_TOKEN=
; The name of the organization to fetch sponsorships from.
; If not set, it will fetch the sponsorships of the user.
SPONSORKIT_POLAR_ORGANIZATION=
```> Only one provider is required to be configured.
Run:
```base
npx sponsorkit
```[Example Setup](./example/) | [GitHub Actions Setup](https://github.com/antfu/static/blob/master/.github/workflows/scheduler.yml) | [Generated SVG](https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg)
### Configurations
Create `sponsorkit.config.js` file with:
```ts
import { defineConfig, tierPresets } from 'sponsorkit'export default defineConfig({
// Providers configs
github: {
login: 'antfu',
type: 'user',
},
opencollective: {
// ...
},
patreon: {
// ...
},
afdian: {
// ...
},
polar: {
// ...
},// Rendering configs
width: 800,
renderer: 'tiers', // or 'circles'
formats: ['json', 'svg', 'png'],
tiers: [
// Past sponsors, currently only supports GitHub
{
title: 'Past Sponsors',
monthlyDollars: -1,
preset: tierPresets.xs,
},
// Default tier
{
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](./example/).
### Programmatic Utilities
You can also use SponsorKit programmatically:
```ts
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
```ts
export default defineConfig({
renderer: 'tiers',
// ...
})
```#### Circles Renderer
```ts
export default defineConfig({
renderer: 'circles',
// ...
})
```### Multiple Renders
We also support rendering multiple images at once with different configurations, via `renders` field:
```ts
import { defineConfig, tierPresets } from 'sponsorkit'export default defineConfig({
// Providers configs
github: { /* ... */ },// Default configs
width: 800,
tiers: [
/* ... */
],// Define multiple renders, each will inherit the top-level configs
renders: [
{
name: 'sponsors.tiers',
formats: ['svg'],
},
{
name: 'sponsors.wide',
width: 1200,
},
{
name: 'sponsors.circles',
renderer: 'circles',
width: 600,
},
// ...
],
})
```## License
[MIT](./LICENSE) License Β© 2022 [Anthony Fu](https://github.com/antfu)