Skip to content

Commit 5e58d5a

Browse files
chore(sponsors): upgrade Route4me sponsor card & improve sponsor processing algorithm (#256)
* feat: add sponsor list generator; * feat: added deploy action; * fix: fixed layout; * fix: use utm links inside tooltips; * fix(CI): set engine version; * chore: reverted the start button title change; * fix: add the ability to retry the request to get a list of sponsors; * chore: change sponsors config & fix sponsor card layout; * chore: hide 'incognito' sponsor from the list of sponsors; * chore: add Route4Me sponsor; * chore: fixed resolution of utm link for manually added sponsors; * chore: fixed sponsors' tiers resolving; * chore: draft; * chore(sponsors): disable utm links generation for `slotozilla-deutschland`; * chore(draft): Improve sponsors list generator; * chore(draft): fix origin preset; * chore(draft): delete generated icon; * chore(draft): add check to ensure dir exists; * chore(draft): add check to ensure dir exists; * chore(draft): activate GitHub data pulling; * chore(draft): fix crown chevron styling; * chore(draft): reduce logo min-width; * chore(draft): add missed `route4me` light logo; * chore(draft): add a title for readme sponsor block; * chore(draft): fix description resolving; * chore(draft): add utm links for sponsors rendered to markdown; * chore(draft): respect autoUTMLinks for utm links generation; * chore(draft): set user theme timeout to 24 hours; * chore(draft): set utm link for markdown output; * chore(draft): add sponsors' logos; * chore(draft): fix sponsor.json; * chore(draft): fix sponsor.json; * chore(draft): add principal logo; * chore(draft): add a hotfix for svg logos; * chore(draft): use image metadata instead of file extension to determine image format; * chore(draft): add Stytch & Descope links; * chore(draft): fix utm link generator to respect sponsor's params; * chore(draft): add page active link rendering; * chore(draft): notes block refactoring; * chore(draft): remove graphql packages; * chore(sponsors): add website link for buzzoid.com; * chore(sponsors): remove Route4me from the list; * chore(sponsors): Fixed relative URLs for dark theme logos in the Readme sponsor generator; * chore(sponsors): activate route4me sponsor card; * chore(sponsors): upgrade Route4me sponsor card & improve sponsor processing algorithm --------- Co-authored-by: Jay <[email protected]>
1 parent b30a0c9 commit 5e58d5a

File tree

2 files changed

+33
-4
lines changed

2 files changed

+33
-4
lines changed

data/sponsors.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,23 @@
8383
"image": "/assets/sponsors/route4me.png",
8484
"image_dark": "/assets/sponsors/route4me_white.png",
8585
"website": "https://route4me.com/",
86+
"github": "https://github.com/route4me",
8687
"displayName": "Route4Me",
8788
"alt": "Route Planner and Route Optimizer",
8889
"description": "Best Route Planning And Route Optimization Software",
8990
"isActive": true,
90-
"totalAmountDonated": 600,
9191
"createdAt": "2024-07-12 00:00",
92-
"boostEnd": "2025-07-31",
92+
"boostEnd": "2025-08-22",
9393
"icon": "./assets/sponsors/route4me_icon.png",
9494
"links": {
9595
"Explore": "https://route4me.com/platform/route-optimization-software",
9696
"Free Trial": "https://route4me.com/platform/marketplace/pricing",
9797
"Contact": "https://route4me.com/contact"
98+
},
99+
"tiers": {
100+
"gold": {
101+
"price": 99
102+
}
98103
}
99104
},
100105
"slotozilla-deutschland" : {

scripts/updateData.js

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,23 @@ const PERIOD = 30;
119119

120120
const days = (from, to = Date.now()) => (new Date(to) - new Date(from)) / DAY / 1000;
121121

122+
const months = (startDate, endDate = new Date()) => {
123+
if (startDate > endDate) {
124+
[startDate, endDate] = [endDate, startDate];
125+
}
126+
127+
const startYear = startDate.getFullYear();
128+
const startMonth = startDate.getMonth();
129+
130+
const endYear = endDate.getFullYear();
131+
const endMonth = endDate.getMonth();
132+
133+
let months = (endYear - startYear) * 12;
134+
months += endMonth - startMonth;
135+
136+
return months;
137+
}
138+
122139
const readJSON = async (fileName) => JSON.parse(String(await fs.readFile(fileName)));
123140
const writeJSON = async (fileName, data) => await fs.writeFile(fileName, JSON.stringify(data, null, 2));
124141

@@ -438,13 +455,13 @@ const processGithub = async (sponsor, repo = 'axios-sponsor', file = 'sponsor.js
438455

439456

440457
const renderTooltip = async (sponsor) => {
441-
let {icon, isActive, displayName, tier, tierId, lastTransactionAmount, price, description, website, benefits, video, autoUTMLinks, links} = sponsor;
458+
let {icon, isActive, displayName, tier, tierId, lastTransactionAmount, tierPrice, description, website, benefits, video, autoUTMLinks, links} = sponsor;
442459

443460
const iconSrc = icon && (await downloadImage(icon));
444461

445462
const iconHTML = iconSrc ? `<img class="sponsor-icon" src="/${iconSrc}" alt="${html.escape(displayName)}"/>` : '';
446463

447-
const renderedTier = isActive && (tierId === 'backer' || sponsor.tierPrice < sponsor.originalTierPrice) ? `${price || lastTransactionAmount || 0}$ a month` : tier;
464+
const renderedTier = isActive && (tierId === 'backer' || sponsor.tierPrice < sponsor.originalTierPrice) ? `${tierPrice || lastTransactionAmount || 0}$ a month` : tier;
448465

449466
let tooltip = `<h2 class="caption">${iconHTML}<span>${html.escape(displayName)} (${sponsor.totalAmountDonated || 0}$${' <sup class="tier">' + renderedTier + '</sup>'})</span></h2> `;
450467

@@ -572,6 +589,13 @@ const processSponsors = async (collectiveSponsors, sponsorsConfig = './data/spon
572589

573590
const sponsorTiers = merge({}, tiers, sponsor.tiers);
574591

592+
if (sponsor.totalAmountDonated == null && sponsor.isActive) {
593+
const passedMonths = sponsor.createdAt ? months(new Date(sponsor.createdAt)) : null;
594+
const tierPrice = sponsor.tier && sponsorTiers[sponsor.tier]?.price;
595+
596+
sponsor.totalAmountDonated = passedMonths != null && tierPrice ? passedMonths * tierPrice : 0;
597+
}
598+
575599
if (lastTransactionAmount) {
576600
sponsor.tier = findTier(lastTransactionAmount, sponsorTiers);
577601

0 commit comments

Comments
 (0)