-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Expand file tree
/
Copy pathsponsorkit.config.js
More file actions
88 lines (84 loc) · 2.04 KB
/
sponsorkit.config.js
File metadata and controls
88 lines (84 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import { readFile } from 'node:fs/promises'
import { extname } from 'node:path'
import { defineConfig, tierPresets } from 'sponsorkit'
const avatarMimeTypeMap = {
'.jpg': 'image/jpeg',
'.jpeg': 'image/jpeg',
'.png': 'image/png',
'.webp': 'image/webp',
'.svg': 'image/svg+xml',
}
const kofiProvider = {
name: 'kofi',
async fetchSponsors() {
let raw = '[]'
try {
raw = await readFile('docs/content/public/assets/sponsors/kofi-supporters.json', 'utf8')
}
catch {
raw = '[]'
}
const items = JSON.parse(raw)
return Promise.all(items.map(async (item) => {
let avatarUrl = item.avatarUrl || ''
if (item.avatarPath) {
const buffer = await readFile(item.avatarPath)
const ext = extname(item.avatarPath).toLowerCase()
const mime = avatarMimeTypeMap[ext] || 'image/png'
avatarUrl = `data:${mime};base64,${buffer.toString('base64')}`
}
return {
sponsor: {
type: 'User',
login: item.login || item.name,
name: item.name,
avatarUrl,
linkUrl: item.linkUrl || '',
},
monthlyDollars: Number(item.monthlyDollars || 0),
provider: 'kofi',
privacyLevel: 'PUBLIC',
tierName: item.tierName,
createdAt: item.createdAt || new Date().toISOString(),
}
}))
},
}
export default defineConfig({
providers: ['patreon', 'opencollective', kofiProvider],
renderer: 'tiers',
width: 960,
padding: {
top: 18,
bottom: 8,
},
formats: ['svg', 'json'],
includePastSponsors: true,
svgInlineCSS: `
text {
font-weight: 400;
font-size: 14px;
fill: #8b949e;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto, 'Helvetica Neue', Arial, sans-serif;
}
.sponsorkit-link {
cursor: pointer;
}
.sponsorkit-tier-title {
font-weight: 700;
font-size: 18px;
fill: #e6edf3;
letter-spacing: 0.2px;
}
`,
tiers: [
{
title: 'Supporters',
preset: tierPresets.base,
padding: {
top: 8,
bottom: 6,
},
},
],
})