nuxt-modules / og-image

Generate OG Images with Vue templates in Nuxt.
https://nuxtseo.com/og-image
417 stars 27 forks source link

Offload Fonts To Custom Storage Handler #155

Open harlan-zw opened 9 months ago

harlan-zw commented 9 months ago

With https://github.com/nuxt-modules/og-image/pull/151 we move fonts to Nitro's Server Assets, this solves several issues of making fetch requests at rutime.

However, this always bundles the font files, which is an issue on edge runtimes that have limited size constraints (vercel gives 2mb).

We need to offload the fonts to a custom storage driver that the end user would provide.

ptdev commented 7 months ago

Hi, I came across this as well.

We are not using dynamic og image/text generation (we have ready made images) but the bundle always includes the Inter font which increases the bundle size tremendously.

And, even if we select another font on nuxt config (as described in the docs) it then apparently includes both the selected font and also the Inter font. (see attached screenshots, one with default configuration that includes the huge Inter font, and another one where I've selected the Poppins font on nuxt config but where it still includes the Inter font in the server bundle anyway, even though the documentation states that if we select another font on nuxt config then the Inter font will be disabled)

I suggest that it should be possible to (for example) set the fonts parameter on nuxt config to false to prevent including any fonts at all for these cases where dynamic image/text generation is not required.

Cheers.

Screenshot 2024-04-02 at 09 54 48 Screenshot 2024-04-02 at 09 55 08