#SSR for injecting social meta tags

17 messages · Page 1 of 1 (latest)

short pewter
#

For my web framework that does not support SSR out of the box, I'm trying to create a workers function that will dynamically render meta tags based on the given route. So far I've found this:
https://community.cloudflare.com/t/cloudflare-pages-functions-ssr-server-side-rendering/338481

Can anyone point me to more resources on this?

short pewter
patent galleon
#

@short pewter im trying this on my end (also not using SSR) but cant get it to work

#

on build im getting "Could not resolve "@cloudflare/pages-plugin-vercel-og""

short pewter
#

And is it installed in your package.json?

#

@patent galleon

patent galleon
#

Actually just fixed this and turned out to be a weird issue with the fact I had no build command (didn’t need one)

#

But the rendering isn’t working though - @short pewter can you share your plugin code? I’m assuming you also weren’t using react

#

I just have an index.html I want rendered as the preview (basically the whole body, or maybe a more specific css selector like .body.main-content

short pewter
#

@patent galleon I ended up going a pretty backwards route since I had an existing worker that did the image generation using https://github.com/kvnang/workers-og. So the role of the pages function ended up just being injecting the meta tags which I figured out how to do using the source code of @cloudflare/pages-plugin-vercel-og

patent galleon
#

Hmm, could that repo be used to render the html of the page itself as the meta card?

#

@short pewter

#

I basically want a “screenshot” of my gallery as the meta image

#

not some arbitrary html

short pewter
#

You could try. workers-og takes in a string rather than JSX. You might have some trouble with it formatting correctly to fit the bounds of the image, as well as what it's compatible with (e.g styling and elements on the page that may not be supported by the render engine backing the library).

#

You will probably be better off making something custom that resembles the page rather than just tossing in the page itself