Closed jkarsrud closed 3 years ago
I think the excerpt
variable that the plugin creates should be an object and return excerpt.text
, excerpt.html
(with <p></p>
stripped but all other HTML preserved). I tend to need a text version for the description meta tag and the HTML version for overview or archive pages.
Returning an object might help, but this is a good use case for metalsmith-keymaster. (hope it's o.k. to plug my own plugin). e.g.
.use(excerpts())
.use(keymaster({ // remove trailing </p> from excerpt and replace with ...
from: function(fileData) {
var ex = fileData.excerpt || "";
return ex.substring(0, ex.length - 4) + " ...";
},
to: "excerpt"
}))
Such a feature would be great for Atom feed summaries.
PR would be welcome.
This can be done with #32
Sometimes it's a use-case to want to present the excerpt in a different way than the rest of the content — for instance with a different class name on that element without having to wrap it in a different element.
I'd be happy to do a PR on this if you think it's a good idea?