|
1 | 1 | import { Donation } from "@/app/types"; |
2 | | -import { Alts, getCardSvg, ProjectCount } from "../media/card2"; |
| 2 | +import { Alts, getCardSvg, ProjectCount } from "../media/card"; |
3 | 3 | import { JSDOM } from "jsdom"; |
4 | 4 | import puppeteer from "puppeteer"; |
5 | 5 | import { getEnsName } from "./ens"; |
@@ -27,7 +27,7 @@ export async function fetchImageAndEns( |
27 | 27 | } |
28 | 28 |
|
29 | 29 | setRoundAndChainDetails(document, sortedDonations); |
30 | | - setSimpleTopRoundName(document, sortedDonations); |
| 30 | + setTopRoundName(document, sortedDonations); |
31 | 31 |
|
32 | 32 | const ensName = await getEnsName(donations[0].donorAddress); |
33 | 33 | setWalletAddress(document, ensName || donations[0].donorAddress); |
@@ -74,13 +74,13 @@ function sortDonationsByAmount(donations: Donation[]): Donation[] { |
74 | 74 | } |
75 | 75 |
|
76 | 76 | function singularify(document: Document, elementId: string): void { |
77 | | - // const element = document.getElementById(elementId); |
78 | | - // const textContent = element!.textContent ?? ""; |
79 | | - // const words = textContent.split(" "); |
80 | | - // const singularWords = words.map((word) => |
81 | | - // word.endsWith("s") ? word.slice(0, -1) : word, |
82 | | - // ); |
83 | | - // element!.textContent = singularWords.join(" "); |
| 77 | + const element = document.getElementById(elementId); |
| 78 | + const textContent = element!.textContent ?? ""; |
| 79 | + const words = textContent.split(" "); |
| 80 | + const singularWords = words.map((word) => |
| 81 | + word.endsWith("s") ? word.slice(0, -1) : word, |
| 82 | + ); |
| 83 | + element!.textContent = singularWords.join(" "); |
84 | 84 | } |
85 | 85 |
|
86 | 86 | function setRoundAndChainDetails( |
@@ -167,20 +167,6 @@ function setTopRoundName(document: Document, donations: Donation[]): void { |
167 | 167 | } |
168 | 168 | } |
169 | 169 |
|
170 | | -function setSimpleTopRoundName(document: Document, donations: Donation[]): void { |
171 | | - const topRound = findTopRound(donations); |
172 | | - const roundName = donations.find( |
173 | | - (donation) => donation.roundId === topRound.roundId, |
174 | | - )?.application?.round?.roundMetadata?.name || ""; |
175 | | - |
176 | | - const maxCharacters = 26; |
177 | | - const truncatedName = roundName.length > maxCharacters |
178 | | - ? roundName.substring(0, maxCharacters - 3) + "..." |
179 | | - : roundName; |
180 | | - |
181 | | - setElementTextContent(document, "top-round-0", truncatedName); |
182 | | -} |
183 | | - |
184 | 170 | function setWalletAddress(document: Document, ensOrAddress: string): void { |
185 | 171 | setElementTextContentAndFontSize( |
186 | 172 | document, |
@@ -296,12 +282,12 @@ function renderProjectDetails( |
296 | 282 | setElementTextContent( |
297 | 283 | document, |
298 | 284 | `project${index}`, |
299 | | - trunc(30, donation.application?.project?.name) || "", |
| 285 | + trunc(23, donation.application?.project?.name) || "", |
300 | 286 | ); |
301 | 287 | setElementTextContent( |
302 | 288 | document, |
303 | 289 | `round${index}`, |
304 | | - trunc(50, donation.application?.round?.roundMetadata.name) || "", |
| 290 | + trunc(30, donation.application?.round?.roundMetadata.name) || "", |
305 | 291 | ); |
306 | 292 |
|
307 | 293 | const circle = document.getElementById(`logo${index}`); |
@@ -436,12 +422,12 @@ async function generateBase64Image(dom: JSDOM): Promise<string> { |
436 | 422 |
|
437 | 423 | const page = await browser.newPage(); |
438 | 424 | await page.setContent(dom.serialize()); |
439 | | - await page.setViewport({ width: 1200, height: 600 }); |
| 425 | + await page.setViewport({ width: 800, height: 800 }); |
440 | 426 |
|
441 | 427 | const pngBuffer = await page.screenshot({ |
442 | 428 | type: "png", |
443 | 429 | encoding: "binary", |
444 | | - clip: { x: 0, y: 0, width: 1200, height: 600 }, |
| 430 | + clip: { x: 0, y: 0, width: 800, height: 800 }, |
445 | 431 | omitBackground: true, |
446 | 432 | }); |
447 | 433 |
|
|
0 commit comments