Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I actually use a locally defined provider without contributing it to unpic? #169

Open
yacoob opened this issue Feb 7, 2025 · 1 comment

Comments

@yacoob
Copy link

yacoob commented Feb 7, 2025

I'm about 80% sure this is not an actual bug, but rather the fact that my knowledge of typescript is very patchy. Please bear with me :)

context: I wanted to add my own local provider to unpic. I have an endpoint that produces thumbnails on the fly, accepting just width and height from the url and rescaling the image. In prod, my images live on imagekit; this provider would handle things in the dev environment.

I've followed the instructions and made my own subclass of Operations, Options, generator and parser for Operations. I'm struggling with defining an URLExtractor<"local">, as the parametrized type is the ImageCdn union defined in unpic itself. I can't seem to be able to modify it via typescript module augmentation - I'm either using it incorrectly or there's something missing.

Would you please be able to add a minimal example of this to the documentation? Or add it here, and I'll happily update the docs :)

Thanks!

@yacoob
Copy link
Author

yacoob commented Feb 8, 2025

Judging by this documentation I can't add to a type alias via module augmentation. Which means I can't add to ImageCdn. Am I reading things correctly?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant