Skip to content

Commit

Permalink
Fixed UTM link for the sponsor's badge (#192)
Browse files Browse the repository at this point in the history
* 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;
  • Loading branch information
DigitalBrainJS committed Jul 15, 2024
1 parent 05418a2 commit e54e155
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions scripts/updateData.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,25 +82,15 @@ const pullSponsors = async (collective, {type = 'organizations'} = {}) => {
const {data} = await getWithRetry(`https://opencollective.com/${collective}/members/${type}.json`);

return data.map(({lastTransactionAt, ...entry}) => {
const {profile, website} = entry;
const {profile} = entry;

const login = new URL(profile).pathname.split('/').pop();

console.log(`Sponsor: ${login}`);

const targetLink = website || entry.twitter || entry.github || entry.profile;

const parsed = parseURL(targetLink);

const alt = parsed && parsed.origin;
console.log(`Open Collective member: ${login}`);

return {
...entry,
alt,
login,
displayName: entry.name || login,
targetLink,
utmLink: parsed && makeUTMURL(targetLink)
login
}
});
}
Expand Down Expand Up @@ -208,12 +198,9 @@ const processSponsors = async (sponsorsData, sponsorsConfig = './data/sponsors.j
// merge Open Collective sponsors
sponsorsData.forEach(sponsor => {
if (sponsor.role !== 'BACKER' && sponsor.role && sponsor.totalAmountDonated <= 0) {
console.log(`Ignore sponsor [${sponsor.displayName}]`);
return;
}

console.log(`Process sponsor [${sponsor.displayName}]`);

computedSponsors[sponsor.login] = {...sponsor};
});

Expand All @@ -227,6 +214,10 @@ const processSponsors = async (sponsorsData, sponsorsConfig = './data/sponsors.j
await Promise.all(Object.values(computedSponsors).map(async (sponsor) => {
let {login, icon, website, displayName, description, links} = sponsor;

sponsor.displayName = displayName = displayName || sponsor.name || login;

console.log(`Process sponsor [${displayName}]`);

const iconHTML = icon ? `<img class="sponsor-icon" src="${await downloadImage(icon)}" alt="${login}"/>` : '';

let tooltip = `<h2 class="caption">${iconHTML}<span>${displayName} (${sponsor.totalAmountDonated}$${sponsor.tier && sponsor.isActive ? ' <sup class="tier">' + sponsor.tier + '</sup>' : ''})</span></h2> `;
Expand Down Expand Up @@ -266,6 +257,12 @@ const processSponsors = async (sponsorsData, sponsorsConfig = './data/sponsors.j
tooltip += `<div class="social">${icons}</div>`

sponsor.tooltip = tooltip;

sponsor.targetLink = website || sponsor.twitter || sponsor.github || sponsor.profile;

const parsed = parseURL(sponsor.targetLink);

sponsor.utmLink = !sponsor.utmLink && parsed && makeUTMURL(sponsor.targetLink);
}));

const sortedSponsors = {};
Expand Down

0 comments on commit e54e155

Please sign in to comment.