@contentpilot/read-more
v2.0.2
Published
Find and convert the WordPress <!--more--> read more tag to toggle all content below
Readme
Content Pilot Read More
Find and convert <!--more--> tag in the WordPress Editor into a button that allows visitor to toggle content visibility.
Installation
npm install @contentpilot/read-more --save-dev
Require JS file in task runner
./node_modules/@contentpilot/read-more/index.js
Usage
With jQuery (legacy)
$(".entry-content").cpReadMore();
// With options
$(".entry-content").cpReadMore({
target: '[id^="more-"]',
unwrap: true,
replace: true,
moreLabel: "More",
moreCSS: "button clean",
lessLabel: "Less",
lessCSS: "button clean",
hideClass: "display-none",
});Without jQuery (ES6)
Include index.js in your site's build/task-runner pipeline — it's a plain
browser script, not a module to import/require.
// Auto-initializes on elements with class "entry-content".
// Or manually:
const element = document.querySelector(".custom-entry-content");
new ReadMore(element, {
target: '[id^="more-"]',
moreLabel: "Read More",
lessLabel: "Read Less",
});Publish to NPM
To update this repository on NPM using the GitHub action,
- Bump the version number in
package.json - Commit with message pattern of
Release x.x.x - Push to
masterbranch toorigin
