ascorbic / unpic-img

Multi-framework responsive image component
https://unpic.pics
1.4k stars 52 forks source link

Eleventy (11ty) Shortcode #624

Open TechAurelian2 opened 8 months ago

TechAurelian2 commented 8 months ago

Is your feature request related to a problem? Please describe. As an Eleventy (11ty) user, I struggle to integrate the existing WebC image component provided by unpic-img. While WebC works well for some projects, not everyone using Eleventy relies on it. Eleventy shortcodes (https://www.11ty.dev/docs/shortcodes/) are very flexible and they can be used in Nunjucks, Liquid, JavaScript, languages used by most of the people that are using Eleventy.

Describe the solution you'd like I propose adding a new Eleventy shortcode. This shortcode would allow users to easily embed responsive images using the unpic-img library within their Eleventy templates and pages, to "generates a responsive tag that follows best practices, with the correct srcset, sizes and styles; detect image URLs from most image CDNs and CMSs and can resize images with no build step." (taken from the @unpic/webc docs).

Describe alternatives you've considered Creating my own 11ty shortcode for integrating Unpic, but I think a built-in shortcode that comes with the library, or at least an "official" example of how to implement it would be great.

Additional context I guess the unpic-img.webc file should be translated to an 11ty shortcode?

Thank you

ascorbic commented 8 months ago

That sounds like a good idea. If you'd be up for implementing it I'd be happy to add it. I'd make it a new package, @unpic/11ty