eleventy-plugin-excerpt
Eleventy plugin for extracting template excerpts
Install
npm install eleventy-plugin-excerpt
.eleventy.js
Add it to your const excerpt = ; module { eleventyConfig;};
Usage
This plugin adds a universal shortcode named excerpt
which takes one argument: a template object.
By default, the excerpt will be the first paragraph of the template content.
Liquid
{%- for post in collections.post -%} {% excerpt post %}{%- endfor -%}
Nunjucks
{%- for post in collections.post -%} {% excerpt post %}{%- endfor -%}
Handlebars
{{#each collections.post}} {{{ excerpt this }}}{{/each}}
JavaScript function
module { return collectionspost;};
Options
excerptSeparator
Everything in the rendered template content up to and including this string becomes the excerpt.
Optional, defaults to '</p>'
.
For example, if you configure the plugin like this
module { eleventyConfig;};
Then you can have multi paragraph excerpts
---
# ...
---
In the excerpt
Also in the excerpt
<!--more-->
Not in the excerpt
Override excerpt
If your template's front-matter or data file contains a property called "excerpt", that string will be used instead of extracting the excerpt from the template content.
---
excerpt: 'This is the excerpt'
---
Not the excerpt
License
MIT