Logo = image("./Logo.png", format: :webp, versions: {
500w: { max_width: 500 },
800w: { max_width: 800 },
})
render do
<div>
<img
src={Logo.src}
srcset={Logo.srcset}
sizes={Logo.sizes}
/>
</div>
end
And Logo would be an instance of Image:
class Image < T::Struct
class Source < T::Struct
const :url, String
const :width, Integer
const :height, Integer
sig {returns(String)}
def to_s() = url
end
const :blur_data_url, String
const :content_type, String
const :sources, T::Array[Source]
sig {returns(String)}
def to_s() = sources.first.to_s
end
There should be a step while building that finds all images and processes them and saves them to some public directory, but it should be made on the fly in development mode...
The filename could just be the sha256 hash of the resulting file + extension.
Keep in mind that different types of assets should be supported in the future.
And maybe there should be some sort of condition on whether a file should be generated or if it should just return a data url (kinda like https://v4.webpack.js.org/loaders/url-loader/)
And
Logo
would be an instance of Image:There should be a step while building that finds all images and processes them and saves them to some public directory, but it should be made on the fly in development mode...
The filename could just be the sha256 hash of the resulting file + extension.
Keep in mind that different types of assets should be supported in the future.
And maybe there should be some sort of condition on whether a file should be generated or if it should just return a data url (kinda like https://v4.webpack.js.org/loaders/url-loader/)