Next.js Discord

Discord Forum

Hello, I need some help with Vercel/OG

Unanswered
Grand Basset Griffon Vendéen posted this in #help-forum
Open in Discord
Grand Basset Griffon VendéenOP
I'm struggling to create a simple colored text with Vercel/OG

For example, if I want to reacreate the text from this tweet, I would do a p tag with some span tags insinde.
But that doesn't actaully work, as Yoga (the engine) only uses flex

37 Replies

Grand Basset Griffon VendéenOP
Grand Basset Griffon VendéenOP
No one?
Grand Basset Griffon VendéenOP
you are a legend
holy sh*t
thank you
it's not a nice solution because you have to manually parse the text and insert elements word by word, but yeah that's about the best we can do given the limitations
Grand Basset Griffon VendéenOP
Oh yeah it's dirty lol. But I need to do this at scale, basically I want to make images of posts on Twitter, and I need to do this for links, hashtags and mentions
yeah not gonna be easy. i can see twitter bold text is going to be a problem here.

frankly speaking i think i would just use puppeteer or something like that and take a screenshot from a headless browser. managing twitter bold text, non-standard space character, etc. is a nightmare especially if you want to support cjk languages.
Grand Basset Griffon VendéenOP
That might be a better idea. I'll try to look at how that works
since we are doing this at scale, i assume you at least have a vps right? if so, doing this is very easy.

without a vps, you can still send an old version of headless chrome to vercel.
Grand Basset Griffon VendéenOP
I do have a vps
I'm not exactly sure how to do this with puppiteer, but I guess I'll have to figure it out
might solve a lot of the sizing issues too
essentially the idea is:
1. launch a headless browser. could use puppeteer for this but i think there are other libraries as well.
2. render some html on it
3. take a screenshot programmatically
thats what we did before vercel/og days
Grand Basset Griffon VendéenOP
So basically I would just render the post, but I'm thinking about the size. How do I know the size of what I need to ss
just make a page where the meaningful content to screenshot is 1200 pixels wide and 630 pixels high, then take a screenshot of that exact portion
Grand Basset Griffon VendéenOP
Well, posts could really be any size
At least the height could differ a lot
@Grand Basset Griffon Vendéen Well, posts could really be any size
well, you need to handle your own logic to resize the post accordingly
vercel/og or not you still have to resize your post correctly
Grand Basset Griffon VendéenOP
True
with vercel/og I basically had to know the size of the post before, so I programatically calculated everything.

Does it have a reply, does it have a quote, does it have images
Would be great if there was a way to just render, and then take a screenshot of what was rendered, not caring about the height
Grand Basset Griffon VendéenOP
Yep
I mean, I have a lot of it already
if you want to capture the entire page content (not height-limited), [yes it's still possible](https://www.npmjs.com/package/capture-website#fullpage)
Grand Basset Griffon VendéenOP