A plugin that provides shortcodes and filters for displaying read more links
npm install eleventy-plugin-read-moreA plugin that provides shortcodes and filters for easily displaying post summaries and read-more links.
- Installation
- Usage
- readMore
- excerpt
- hasMoretag
- Options
- License
``shnpm
npm i eleventy-plugin-read-more
Usage
Register the plugin in you
.eleventy.js file:`js
const eleventyReadMorePlugin = require("eleventy-plugin-read-more");module.exports = (eleventyConfig) => {
eleventyConfig.addPlugin(eleventyReadMorePlugin);
});
`In your post content, insert a
readMoreTag break point using .For example:
`md
Post content to be shown in summary and full viewThe rest of the post
`In your template (nunjucks example):
`nunjucks
{% readMore content %}
{% endreadMore %}
`This will output:
`html
Post content to be shown in summary and full view
`$3
A paired eleventy shortcode (see Usage). It will only show before the
readMoreTag and, if found, will append the provided read more link.Nunjucks example:
`nunjucks
{% readMore __CONTENT__ %} __READ_MORE_LINK__ {% endreadMore %}
`$3
An eleventy filter. Will return all the supplied content before the
readMoreTag.Nunjucks example:
`nunjucks
{{ "A post summary The full content" | excerpt }}
`Outputs
"A post summary".$3
An eleventy filter. Will return true or false if the supplied content contains the
readMoreTag. This can be used in conditional statements.Nunjucks example:
`nunjucks
{{ "A post summary The full content" | hasMoretag }}
`Outputs
true.Options
`js
var options = {
readMoreTag: "",
};eleventyConfig.addPlugin(eleventyNavigationPlugin, options);
`-
readMoreTag (string, default `) - a text string to use to break content and insert a read-more link.This software is released under the MIT License.