Skip to content

Commit 2c3dbdc

Browse files
authored
docs: Use prerendered sponsors for README (#18988)
1 parent 17cfb68 commit 2c3dbdc

2 files changed

Lines changed: 16 additions & 102 deletions

File tree

README.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -289,23 +289,21 @@ Percy Ma
289289

290290
<!--teamend-->
291291

292-
## Sponsors
293-
294-
The following companies, organizations, and individuals support ESLint's ongoing maintenance and development. [Become a Sponsor](https://eslint.org/donate) to get your logo on our README and website.
295-
296292
<!-- NOTE: This section is autogenerated. Do not manually edit.-->
297293
<!--sponsorsstart-->
294+
## Sponsors
295+
296+
The following companies, organizations, and individuals support ESLint's ongoing maintenance and development. [Become a Sponsor](https://eslint.org/donate)
297+
to get your logo on our READMEs and [website](https://eslint.org/sponsors).
298298
<h3>Platinum Sponsors</h3>
299299
<p><a href="https://automattic.com"><img src="https://images.opencollective.com/automattic/d0ef3e1/logo.png" alt="Automattic" height="128"></a> <a href="https://www.airbnb.com/"><img src="https://images.opencollective.com/airbnb/d327d66/logo.png" alt="Airbnb" height="128"></a></p><h3>Gold Sponsors</h3>
300300
<p><a href="https://trunk.io/"><img src="https://images.opencollective.com/trunkio/fb92d60/avatar.png" alt="trunk.io" height="96"></a></p><h3>Silver Sponsors</h3>
301301
<p><a href="https://www.jetbrains.com/"><img src="https://images.opencollective.com/jetbrains/fe76f99/logo.png" alt="JetBrains" height="64"></a> <a href="https://liftoff.io/"><img src="https://images.opencollective.com/liftoff/5c4fa84/logo.png" alt="Liftoff" height="64"></a> <a href="https://americanexpress.io"><img src="https://avatars.githubusercontent.com/u/3853301?v=4" alt="American Express" height="64"></a> <a href="https://www.workleap.com"><img src="https://avatars.githubusercontent.com/u/53535748?u=d1e55d7661d724bf2281c1bfd33cb8f99fe2465f&v=4" alt="Workleap" height="64"></a></p><h3>Bronze Sponsors</h3>
302302
<p><a href="https://www.wordhint.net/"><img src="https://images.opencollective.com/wordhint/be86813/avatar.png" alt="WordHint" height="32"></a> <a href="https://www.crosswordsolver.org/anagram-solver/"><img src="https://images.opencollective.com/anagram-solver/2666271/logo.png" alt="Anagram Solver" height="32"></a> <a href="https://icons8.com/"><img src="https://images.opencollective.com/icons8/7fa1641/logo.png" alt="Icons8" height="32"></a> <a href="https://discord.com"><img src="https://images.opencollective.com/discordapp/f9645d9/logo.png" alt="Discord" height="32"></a> <a href="https://www.gitbook.com"><img src="https://avatars.githubusercontent.com/u/7111340?v=4" alt="GitBook" height="32"></a> <a href="https://nx.dev"><img src="https://avatars.githubusercontent.com/u/23692104?v=4" alt="Nx" height="32"></a> <a href="https://herocoders.com"><img src="https://avatars.githubusercontent.com/u/37549774?v=4" alt="HeroCoders" height="32"></a> <a href="https://usenextbase.com"><img src="https://avatars.githubusercontent.com/u/145838380?v=4" alt="Nextbase Starter Kit" height="32"></a></p>
303-
<!--sponsorsend-->
304-
305-
<!--techsponsorsstart-->
306-
<h2>Technology Sponsors</h2>
303+
<h3>Technology Sponsors</h3>
304+
Technology sponsors allow us to use their products and services for free as part of a contribution to the open source ecosystem and our work.
307305
<p><a href="https://netlify.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/netlify-icon.svg" alt="Netlify" height="32"></a> <a href="https://algolia.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/algolia-icon.svg" alt="Algolia" height="32"></a> <a href="https://1password.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/1password-icon.svg" alt="1Password" height="32"></a></p>
308-
<!--techsponsorsend-->
306+
<!--sponsorsend-->
309307

310308
[tidelift]: https://tidelift.com/funding/github/npm/eslint
311309
[herodevs]: https://www.herodevs.com/support/eslint-nes?utm_source=ESLintWebsite&utm_medium=ESLintWebsite&utm_campaign=ESLintNES&utm_id=ESLintNES

tools/update-readme.js

Lines changed: 9 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -23,39 +23,23 @@ const got = require("got");
2323
//-----------------------------------------------------------------------------
2424

2525
const SPONSORS_URL =
26-
"https://raw.githubusercontent.com/eslint/eslint.org/main/src/_data/sponsors.json";
26+
"https://raw.githubusercontent.com/eslint/eslint.org/main/includes/sponsors.md";
2727
const TEAM_URL =
2828
"https://raw.githubusercontent.com/eslint/eslint.org/main/src/_data/team.json";
2929
const README_FILE_PATH = "./README.md";
30-
const TECH_SPONSORS_URL =
31-
"https://raw.githubusercontent.com/eslint/eslint.org/main/src/_data/techsponsors.json";
32-
const TECH_SPONSORS_IMAGE_PATH =
33-
"https://raw.githubusercontent.com/eslint/eslint.org/main/src";
3430

3531
const readme = fs.readFileSync(README_FILE_PATH, "utf8");
3632

37-
const heights = {
38-
platinum: 128,
39-
gold: 96,
40-
silver: 64,
41-
bronze: 32
42-
};
43-
4433
//-----------------------------------------------------------------------------
4534
// Helpers
4635
//-----------------------------------------------------------------------------
4736

4837
/**
49-
* Fetches the latest sponsors data from the website.
50-
* @returns {Object} The sponsors data object.
38+
* Fetches the latest sponsors from the website.
39+
* @returns {Promise<string>}} Prerendered sponsors markdown.
5140
*/
52-
async function fetchSponsorsData() {
53-
const data = await got(SPONSORS_URL).json();
54-
55-
// remove backers from sponsors list - not shown on readme
56-
delete data.backers;
57-
58-
return data;
41+
async function fetchSponsorsMarkdown() {
42+
return got(SPONSORS_URL).text();
5943
}
6044

6145
/**
@@ -89,68 +73,6 @@ function formatTeamMembers(members) {
8973
/* eslint-enable indent -- Allow deeper template substitution indent */
9074
}
9175

92-
/**
93-
* Formats an array of sponsors into HTML for the readme.
94-
* @param {Array} sponsors The array of sponsors.
95-
* @returns {string} The HTML for the readme.
96-
*/
97-
function formatSponsors(sponsors) {
98-
const nonEmptySponsors = Object.keys(sponsors).filter(
99-
tier => sponsors[tier].length
100-
);
101-
102-
/* eslint-disable indent -- Allow deeper template substitution indent */
103-
return stripIndents`<!--sponsorsstart-->
104-
${nonEmptySponsors
105-
.map(
106-
tier => `<h3>${tier[0].toUpperCase()}${tier.slice(
107-
1
108-
)} Sponsors</h3>
109-
<p>${sponsors[tier]
110-
.map(
111-
sponsor =>
112-
`<a href="${sponsor.url || "#"}"><img src="${
113-
sponsor.image
114-
}" alt="${sponsor.name}" height="${heights[tier]}"></a>`
115-
)
116-
.join(" ")}</p>`
117-
)
118-
.join("")}
119-
<!--sponsorsend-->`;
120-
/* eslint-enable indent -- Allow deeper template substitution indent */
121-
}
122-
123-
/**
124-
* Fetches the latest tech sponsors data from the website.
125-
* @returns {Array<Object>} The tech sponsors array of data object.
126-
*/
127-
async function fetchTechSponsors() {
128-
const data = await got(TECH_SPONSORS_URL).json();
129-
130-
return data;
131-
}
132-
133-
/**
134-
* Formats an array of sponsors into HTML for the readme.
135-
* @param {Array} sponsors The array of sponsors.
136-
* @returns {string} The HTML for the readme.
137-
*/
138-
function formatTechSponsors(sponsors) {
139-
return stripIndents`<!--techsponsorsstart-->
140-
<h2>Technology Sponsors</h2>
141-
<p>${sponsors
142-
.map(
143-
sponsor =>
144-
`<a href="${sponsor.url || "#"}"><img src="${
145-
TECH_SPONSORS_IMAGE_PATH + sponsor.image
146-
}" alt="${sponsor.name}" height="${
147-
heights.bronze
148-
}"></a>`
149-
)
150-
.join(" ")}</p>
151-
<!--techsponsorsend-->`;
152-
}
153-
15476
//-----------------------------------------------------------------------------
15577
// Main
15678
//-----------------------------------------------------------------------------
@@ -195,10 +117,9 @@ const HTML_TEMPLATE = stripIndents`
195117
`;
196118

197119
(async () => {
198-
const [allSponsors, team, techSponsors] = await Promise.all([
199-
fetchSponsorsData(),
200-
fetchTeamData(),
201-
fetchTechSponsors()
120+
const [allSponsors, team] = await Promise.all([
121+
fetchSponsorsMarkdown(),
122+
fetchTeamData()
202123
]);
203124

204125
// replace all of the section
@@ -212,12 +133,7 @@ const HTML_TEMPLATE = stripIndents`
212133

213134
newReadme = newReadme.replace(
214135
/<!--sponsorsstart-->[\w\W]*?<!--sponsorsend-->/u,
215-
formatSponsors(allSponsors)
216-
);
217-
218-
newReadme = newReadme.replace(
219-
/<!--techsponsorsstart-->[\w\W]*?<!--techsponsorsend-->/u,
220-
formatTechSponsors(techSponsors)
136+
`<!--sponsorsstart-->\n${allSponsors}\n<!--sponsorsend-->`
221137
);
222138

223139
// replace multiple consecutive blank lines with just one blank line

0 commit comments

Comments
 (0)