diff --git a/src/preview.mjs b/src/preview.mjs index 1c0a77c1..ebf59a61 100644 --- a/src/preview.mjs +++ b/src/preview.mjs @@ -15,13 +15,17 @@ function h(type, props, ...children) { } } -function content(title, submitter) { - const text = `submitted by ${submitter.displayName}`; +function content(title, submitter, domain) { + const text = `submitted by `; + const submitterStyle = { + textDecoration: "underline", + color: "red", + }; return html`

${title}

-

${text}

+

+ (${domain}) +

+

***

+

+ ${text} + ${submitter} +

`; } -export async function generate(index, title, submitter) { +export async function generate(index, title, submitter, domain) { const filePath = resolve(`./src/public/previews/${index}.jpg`); - try { - await access(filePath); - return; // File exists, so we just return - } catch (err) { - // File doesn't exist, we continue with the generation - } + // try { + // await access(filePath); + // return; // File exists, so we just return + // } catch (err) { + // // File doesn't exist, we continue with the generation + // } const fontData = await readFile("./Verdana-Bold.ttf"); const arial = { name: "Verdana", data: fontData, - weight: 700, - style: "bold", + weight: 400, + style: "normal", }; - const body = content(title, submitter); + const body = content(title, submitter, domain); const svgData = await satori(body, { width: 1200, height: 630, @@ -73,3 +103,26 @@ export async function generate(index, title, submitter) { sharp(Buffer.from(svgData)).jpeg().toFile(filePath); } + +// Test function +async function test() { + // Test different titles and submitters + console.log("started generation"); + await generate( + 1, + "This is a test title that has eighty characters to see how Kiwi renders OG:Image", + "Test Submitter 1", + "testdomain1.com", + ); + await generate(2, "Short title test", "Test Submitter 2", "domain2.com"); + await generate( + 3, + "Medium length title test about 30 chars", + "Test Submitter 2 longname", + "veryverylongdomain2.com", + ); + // Add more tests as needed +} + +// Run the test function +test().catch(console.error);