@@ -21,6 +21,12 @@ import got from "got";
21
21
const SPONSORS_URL =
22
22
"https://raw.githubusercontent.com/eslint/eslint.org/main/src/_data/sponsors.json" ;
23
23
24
+ const TECH_SPONSORS_URL =
25
+ "https://raw.githubusercontent.com/eslint/eslint.org/main/src/_data/techsponsors.json" ;
26
+
27
+ const TECH_SPONSORS_IMAGE_PATH =
28
+ "https://raw.githubusercontent.com/eslint/eslint.org/main/src" ;
29
+
24
30
const README_FILE_PATHS = [
25
31
"./README.md" ,
26
32
...readdirSync ( "./packages" ) . map ( dir => `./packages/${ dir } /README.md` ) ,
@@ -49,9 +55,19 @@ async function fetchSponsorsData() {
49
55
return data ;
50
56
}
51
57
58
+ /**
59
+ * Fetches the latest tech sponsors data from the website.
60
+ * @returns {Array<Object> } The tech sponsors array of data object.
61
+ */
62
+ async function fetchTechSponsors ( ) {
63
+ const data = await got ( TECH_SPONSORS_URL ) . json ( ) ;
64
+
65
+ return data ;
66
+ }
67
+
52
68
/**
53
69
* Formats an array of sponsors into HTML for the readme.
54
- * @param {Array } sponsors The array of sponsors.
70
+ * @param {Object } sponsors The object of sponsors.
55
71
* @returns {string } The HTML for the readme.
56
72
*/
57
73
function formatSponsors ( sponsors ) {
@@ -74,12 +90,33 @@ function formatSponsors(sponsors) {
74
90
<!--sponsorsend-->` ;
75
91
}
76
92
93
+ /**
94
+ * Formats an array of sponsors into HTML for the readme.
95
+ * @param {Array } sponsors The array of sponsors.
96
+ * @returns {string } The HTML for the readme.
97
+ */
98
+ function formatTechSponsors ( sponsors ) {
99
+ return stripIndents `<!--techsponsorsstart-->
100
+ <h2>Technology Sponsors</h2>
101
+ <p>${ sponsors
102
+ . map (
103
+ sponsor =>
104
+ `<a href="${ sponsor . url || "#" } "><img src="${ TECH_SPONSORS_IMAGE_PATH + sponsor . image } " alt="${ sponsor . name } " height="${ heights . bronze } "></a>` ,
105
+ )
106
+ . join ( " " ) }
107
+ </p>
108
+ <!--techsponsorsend-->` ;
109
+ }
110
+
77
111
//-----------------------------------------------------------------------------
78
112
// Main
79
113
//-----------------------------------------------------------------------------
80
114
81
115
( async ( ) => {
82
- const allSponsors = await fetchSponsorsData ( ) ;
116
+ const [ techSponsors , allSponsors ] = await Promise . all ( [
117
+ fetchTechSponsors ( ) ,
118
+ fetchSponsorsData ( ) ,
119
+ ] ) ;
83
120
84
121
README_FILE_PATHS . forEach ( filePath => {
85
122
// read readme file
@@ -90,6 +127,11 @@ function formatSponsors(sponsors) {
90
127
formatSponsors ( allSponsors ) ,
91
128
) ;
92
129
130
+ newReadme = newReadme . replace (
131
+ / < ! - - t e c h s p o n s o r s s t a r t - - > [ \w \W ] * ?< ! - - t e c h s p o n s o r s e n d - - > / u,
132
+ formatTechSponsors ( techSponsors ) ,
133
+ ) ;
134
+
93
135
// replace multiple consecutive blank lines with just one blank line
94
136
newReadme = newReadme . replace ( / (?< = ^ | \n ) \n { 2 , } / gu, "\n" ) ;
95
137
0 commit comments