Skip to content

Commit 6e000c5

Browse files
windowize variables
1 parent e720fbc commit 6e000c5

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

functions/gen-opengraph-image/gen-opengraph-image.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ exports.handler = async function(event, ctx) {
2121
</body>
2222
</html>
2323
`);
24+
await page.addScriptTag({
25+
content: `
26+
window.title = "title from script";
27+
window.tags = ["one", "two", "three"];
28+
window.author = "@chrisbiscardi";
29+
`
30+
});
2431
await page.addScriptTag({ content: script });
2532
const boundingRect = await page.evaluate(() => {
2633
const corgi = document.getElementById("corgi");

functions/gen-opengraph-image/src/image.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ function App() {
6060
lineHeight: 1
6161
}}
6262
>
63-
Some stuff
63+
{window.title}
6464
</Textfit>
6565
</h1>
6666
<div
@@ -85,11 +85,11 @@ function App() {
8585
}
8686
}}
8787
>
88-
<li>react</li>
89-
<li>serverless</li>
90-
<li>figma</li>
88+
{window.tags.map(tag => (
89+
<li key={tag}>{tag}</li>
90+
))}
9191
</ul>
92-
<span>@chrisbiscardi</span>
92+
<span>{window.author}</span>
9393
</div>
9494
</div>
9595
</div>

0 commit comments

Comments
 (0)