Open jbergstroem opened 1 month ago
Thanks for the issue! Yes, I noticed this too recently. As a workaround it is possible to set the getSlug()
function manually and use .webp
(here’s an example), but it would indeed be nice to make this work automatically!
Thanks for the issue! Yes, I noticed this too recently. As a workaround it is possible to set the
getSlug()
function manually and use.webp
(here’s an example), but it would indeed be nice to make this work automatically!
Since Work Must Go On thats what I ended up carrying with a pnpm patch approach, but yeah. I can do a PR if you want, lmk if you have input on how you want the abi to look/change.
Oh, you shouldn’t need a pnpm patch! In the example I linked, getSlug()
is passed as an option to astro-og-canvas
, which overrides the default one:
import { OGImageRoute } from 'astro-og-canvas';
export const { getStaticPaths, GET } = OGImageRoute({
// ...
getSlug: getSlugThatReturnsWebPExtensions,
// ...
})
IIRC the issue currently is that slugs need to be determined before image options are known, so getSlug()
doesn’t actually know yet what format
will be set. We probably need to make a choice to do something like move format
up to the top level and not support setting format
differently for every image (which in any case seems like a pretty unusual requirement).
In the example I linked, getSlug() is passed as an option to astro-og-canvas, which overrides the default one:
Ah, I didn't look long enough to realize I can pass my own slug function. Will switch to this instead. Thank you.
Using a config that looks something like:
..you will notice that the output files are still written as a
.png
:..due to slug not using the format input