-
Notifications
You must be signed in to change notification settings - Fork 0
/
sponsorkit.config.ts
140 lines (134 loc) · 3.02 KB
/
sponsorkit.config.ts
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
import { defineConfig, tierPresets, type BadgePreset } from "@mooncellwiki/sponsorkit";
import fs from "fs";
function toBase64(filePath) {
const img = fs.readFileSync(filePath);
return Buffer.from(img).toString("base64");
}
const SKLAND_LOGO = (width: number, y: number) => `
<a xlink:href="https://www.skland.com" class="sponsorkit-link" target="_blank" id="SKLand">
<svg x="${
(width - 361) / 2
}" y="${y}" width="361" height="86" viewBox="0 0 361 86" fill="none" xmlns="http://www.w3.org/2000/svg">
<image x="0" y="0" width="361" height="86" xlink:href="${
"data:image/png;base64," + toBase64("assets/skland.png")
}"/>
</svg>
</a>
`;
const year = new Date().getFullYear();
const month = new Date().getMonth() + 1;
const date = `${year}-${month.toString().padStart(2, "0")}`;
const past: BadgePreset = {
avatar: {
size: 20,
},
boxWidth: 22,
boxHeight: 22,
container: {
sidePadding: 35,
},
};
export default defineConfig({
outputDir: ".",
formats: ["svg", "png"],
tiers: [
{
title: "过去赞助者",
monthlyDollars: -1,
preset: past,
},
{
title: "赞助者",
preset: tierPresets.small,
},
{
title: "铜牌赞助者",
monthlyDollars: 5,
preset: {
avatar: {
size: 42,
},
boxWidth: 52,
boxHeight: 52,
container: {
sidePadding: 30,
},
},
},
{
title: "银牌赞助者",
monthlyDollars: 10,
preset: tierPresets.medium,
},
{
title: "金牌赞助者",
monthlyDollars: 25,
preset: tierPresets.large,
},
{
title: "铂金赞助者",
monthlyDollars: 50,
preset: tierPresets.xl,
},
{
title: "特别赞助",
monthlyDollars: Infinity,
composeAfter(compose, _, config) {
if (
config.filter?.({ monthlyDollars: Infinity } as any, []) !== false
) {
compose
.addSpan(20)
.addText("特别赞助", "sponsorkit-tier-title")
.addSpan(10)
.addRaw(SKLAND_LOGO(config.width!, compose.height))
.addSpan(130);
}
},
},
],
renders: [
{
name: `sponsors.${date}`,
width: 1000,
includePastSponsors: false,
renderer: "circles",
},
{
name: "sponsors.all",
width: 1000,
includePastSponsors: true,
renderer: "circles",
},
{
name: "sponsors",
width: 800,
includePastSponsors: true,
renderer: "tiers",
},
{
name: "sponsors.wide",
width: 1800,
includePastSponsors: true,
renderer: "tiers",
},
{
name: "sponsors.part1",
width: 800,
includePastSponsors: true,
renderer: "tiers",
filter(sponsor) {
return sponsor.monthlyDollars >= 9.9;
},
},
{
name: "sponsors.part2",
width: 800,
includePastSponsors: true,
renderer: "tiers",
filter(sponsor) {
return sponsor.monthlyDollars < 9.9;
},
},
],
});