0.14.4 • Published 24 days ago

sponsorkit v0.14.4

Weekly downloads
-
License
MIT
Repository
github
Last release
24 days ago

SponsorKit

NPM version

Toolkit for fetching sponsors info and generating sponsors images.

Supports:

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=

; 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:

npx sponsorkit

Example Setup | GitHub Actions Setup | Generated SVG

Configurations

Create sponsorkit.config.js file with:

import { defineConfig, presets } 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: presets.xs,
    },
    // Default tier
    {
      title: 'Backers',
      preset: presets.base,
    },
    {
      title: 'Sponsors',
      monthlyDollars: 10,
      preset: presets.medium,
    },
    {
      title: 'Silver Sponsors',
      monthlyDollars: 50,
      preset: presets.large,
    },
    {
      title: 'Gold Sponsors',
      monthlyDollars: 100,
      preset: presets.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({
  // 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 © 2022 Anthony Fu

0.14.4

24 days ago

0.14.3

27 days ago

0.14.2

27 days ago

0.14.1

28 days ago

0.13.2

1 month ago

0.14.0

30 days ago

0.13.1

1 month ago

0.13.0

1 month ago

0.11.0

1 month ago

0.11.2

1 month ago

0.12.0

1 month ago

0.12.1

1 month ago

0.12.2

1 month ago

0.10.1

1 month ago

0.10.0

1 month ago

0.9.3

3 months ago

0.9.1

5 months ago

0.9.0

6 months ago

0.8.9

9 months ago

0.8.8

9 months ago

0.8.5

12 months ago

0.8.4

12 months ago

0.8.7

11 months ago

0.8.6

11 months ago

0.8.3

1 year ago

0.8.2

1 year ago

0.8.1

1 year ago

0.5.4

2 years ago

0.8.0

1 year ago

0.7.1

1 year ago

0.5.3

2 years ago

0.5.6

2 years ago

0.5.5

2 years ago

0.7.0

1 year ago

0.6.1

2 years ago

0.6.0

2 years ago

0.5.0

2 years ago

0.5.2

2 years ago

0.5.1

2 years ago

0.4.3

2 years ago

0.4.2

2 years ago

0.4.1

2 years ago

0.4.0

2 years ago

0.3.0

2 years ago

0.3.2

2 years ago

0.3.1

2 years ago

0.2.2

2 years ago

0.2.0

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago