metalsmith-srcset-auto
v1.0.0
Published
Metalsmith plugin to automatically set srcset attribute for images.
Downloads
1
Readme
metalsmith-srcset-auto
Patch HTML files to include detected srcset images.
Usage
Put your srcset-eligible images besides main image:
$ ls src/assets/
image.png
[email protected]
[email protected]
Inside input HTML file:
<img src="/assets/image.png">
Output:
<img src="/assets/image.png" srcset="/assets/[email protected] 2x,/assets/[email protected] 3x">
Javascript API
const metalsmith = require('metalsmith');
const srcsetAuto = require('metalsmith-srcset-auto');
metalsmith(__dirname)
.use(srcsetAuto())
.build();