A Metalsmith plugin to assign each page with an image cover.
$ npm install metalsmith-imagecover
Install via npm and then add the metalsmith-imagecover
key to your metalsmith.json
plugin, like so:
{
"plugins": {
"metalsmith-imagecover": true
}
}
var imagecover = require('metalsmith-imagecover');
metalsmith.use(imagecover());
{
"property": "cover",
"attributes": ["src", "alt", "title"]
}
property: is the name of the property that this plugin will create in metadata. attributes: the list of attributes to extract
Place in your template something like:
{% if post.cover %}
<img src="{{post.cover.src}}" alt="{{post.cover.alt}}" title="{{post.cover.src}}"/>
{% endif %}
MIT