Hacker News new | ask | show | jobs
by lot3oo 1645 days ago
Hi Derek, thanks for trying it out! I think adding a download button would be a good idea indeed, but maybe it's not clear enough how to "use" your template. The point of having it hosted by this external service was that it can dynamically generate all your pictures, for all your content, based on your content's data.

In JavaScript, for example, on a theoretical blog site, you could configure it like this:

const article = await fetchArticle(router.query.id);

const queryString = new URLSearchParams(article).toString();

const url = `https://cdn.ogimg.io/v1/u/your-name/blog?${queryString}`;

// add this in the <head> where appropriate...

<meta property="og:image" content="${url}" />

This will add nice pictures for all your articles at once based on your template.

I think I need to make this more clear!

1 comments

I understand; I was thinking from your angle. Rendering and hosting images is a big effort, what if someone change the query string slightly and you would lose the caching opportunity?

With a static site generator I can make the og:image generation part of the build process and host the result myself. Less burden for you, more security for me.

Ah I see what you mean. This would be an easily supported use case actually (you can already do it by using the same URL and downloading the picture, but it's not documented). I need to add more documentation regarding this!

Thanks for sharing!