{"id":18434669,"url":"https://github.com/assemble/grunt-assemble-wordcount","last_synced_at":"2025-04-07T19:31:50.427Z","repository":{"id":11916842,"uuid":"14482553","full_name":"assemble/grunt-assemble-wordcount","owner":"assemble","description":"Assemble middleware for displaying a word-count, and estimated reading time on blog posts or pages. ","archived":false,"fork":false,"pushed_at":"2017-03-17T23:09:25.000Z","size":52,"stargazers_count":10,"open_issues_count":0,"forks_count":2,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-03-23T00:01:41.109Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/assemble.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-11-18T04:20:49.000Z","updated_at":"2020-07-22T06:40:28.000Z","dependencies_parsed_at":"2022-09-18T03:41:51.930Z","dependency_job_id":null,"html_url":"https://github.com/assemble/grunt-assemble-wordcount","commit_stats":null,"previous_names":["assemble/assemble-contrib-wordcount","assemble/assemble-middleware-wordcount"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/assemble%2Fgrunt-assemble-wordcount","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/assemble%2Fgrunt-assemble-wordcount/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/assemble%2Fgrunt-assemble-wordcount/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/assemble%2Fgrunt-assemble-wordcount/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/assemble","download_url":"https://codeload.github.com/assemble/grunt-assemble-wordcount/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247716337,"owners_count":20984223,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T06:04:51.704Z","updated_at":"2025-04-07T19:31:50.133Z","avatar_url":"https://github.com/assemble.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# grunt-assemble-wordcount [![NPM version](https://badge.fury.io/js/grunt-assemble-wordcount.svg)](http://badge.fury.io/js/grunt-assemble-wordcount)\n\n\u003e Assemble plugin for displaying wordcount and average reading time to blog posts or pages.\n\n## Quickstart\n\nIn the command line, run:\n\n```bash\nnpm install grunt-assemble-wordcount --save\n```\n\nNext, register the plugin with Assemble:\n\n```js\nassemble: {\n  options: {\n    plugins: ['grunt-assemble-wordcount', 'other/plugins/*']\n  }\n}\n```\n\nVisit the [plugins docs](http://assemble.io/plugins/) for more info or for help getting started.\n\n## Options\n\n### speed\n\nType: `Number`\nDefault: `300`\n\nAverage \"words per minute\" to use for calculating reading time. This plugin uses 300 as the default based on the averages listed in [this Forbes article](http://onforb.es/1crk3KF).\n\n### seconds\n\nType: `Boolean`\nDefault: `undefined`\n\nDefine `seconds: true` in the option to display seconds and minutes. Example: `7 min, 47 sec`. (by default time is rendered in 1 minute increments, e.g. `8 min`).\n\n### placement\n\nType: `String`\nDefault: `prepend`\n\nDetermines whether the wordcount and reading time will be prepended or appended. Example:\n\n### selector\n\nType: `String`\nDefault: `.wordcount`\n\nThe selector to target for the element that wraps the content that contains the words to count.\n\n### countSelector\n\nType: `String`\nDefault: `.label-wordcount`\n\nThe selector to use for the element that will render the wordcount.\n\n### timeSelector\n\nType: `String`\nDefault: `.label-reading-time`\n\nThe selector to use for the element that will render the estimated reading time.\n\n## Usage Examples\n\n### Basic example\n\n**In your templates**\n\n* `class=\"wordcount\"` must wrap the content that the plugin should run against\n* `class=\"label-wordcount\"` on the element that should render the wordcount.\n* `class=\"label-reading-time\"` on the element that should render the reading time.\n\n```html\n\u003c!-- Blog Posts --\u003e\n\u003cdiv class=\"wordcount\"\u003e\n  \u003cspan class=\"label-wordcount\"\u003e words\u003c/span\u003e\n  \u003cspan class=\"label-reading-time\"\u003e read\u003c/span\u003e\n  {{\u003e body }}\n\u003c/div\u003e\n```\n\n**Rendered HTML**\n\n```html\n\u003c!-- Blog Posts --\u003e\n\u003cdiv class=\"wordcount\"\u003e\n  \u003cspan class=\"label-wordcount\" data-wordcount=\"1561\"\u003e1561 words\u003c/span\u003e\n  \u003cspan class=\"label-reading-time\" data-reading-time=\"7 min\"\u003e7 min read\u003c/span\u003e\n  \u003cp\u003eIn deserunt venison doner velit cow pastrami magna dolore ut jerky proident\n  esse laborum. Fatback strip steak biltong tri-tip beef pork belly spare ribs\n  in ut capicola. Sunt qui t-bone jerky est culpa. Deserunt duis adipisicing\n  ullamco ex, eiusmod beef salami labore non chuck occaecat tenderloin shank\n  cillum. Quis t-bone hamburger pancetta aliqua dolor. Magna eu ground round\n  aliqua...\n\u003c/div\u003e\n```\n\n### Change selectors\n\nThe default selector is `.wordcount`. You can change this in the options as follows:\n\n```js\noptions: {\n  plugins: ['grunt-assemble-wordcount'],\n  wordcount: {\n    selector: '.foo',\n    countSelector: '.bar'\n    timeSelector: '.baz'\n  }\n}\n```\n\nAnd in your templates:\n\n```html\n\u003c!-- Blog Posts --\u003e\n\u003cdiv class=\"foo\"\u003e\n  {{\u003e post }}\n\u003c/div\u003e\n```\n\nThen in `post.hbs`:\n\n```html\n\u003c!-- Post --\u003e\n\u003carticle class=\"post\"\u003e\n  \u003ch1\u003eBreaking News\u003c/h1\u003e\n  \u003cspan class=\"bar\"\u003e words\u003c/span\u003e\n  \u003cspan class=\"baz\"\u003e read\u003c/span\u003e\n\u003c/article\u003e\n```\n\n### Display seconds\n\nIn the plugin's options, define `seconds: true`:\n\n```js\noptions: {\n  plugins: ['grunt-assemble-wordcount'],\n  wordcount: {\n    seconds: true\n  }\n}\n```\n\nThe result will look something like this:\n\n```html\n\u003cspan class=\"label-wordcount\" data-wordcount=\"1561\"\u003e1561 words\u003c/span\u003e\n\u003cspan class=\"label-reading-time\" data-reading-time=\"7 minutes, 48 seconds\"\u003e7 minutes, 48 seconds read\u003c/span\u003e\n```\n\nIf less than 1 minute, the results will look something like this:\n\n```html\n\u003cspan class=\"label-wordcount\" data-wordcount=\"12\"\u003e12 words\u003c/span\u003e\n\u003cspan class=\"label-reading-time\" data-reading-time=\"2 seconds\"\u003e2 seconds read\u003c/span\u003e\n```\n\n### Placement\n\nBy default, wordcount and reading time are prepended to the text node of the specified element. Example:\n\n```html\n\u003cspan class=\"label-wordcount\" data-wordcount=\"1561\"\u003e1561 words\u003c/span\u003e\n\u003cspan class=\"label-reading-time\" data-reading-time=\"7 minutes, 48 seconds\"\u003e7 minutes, 48 seconds read\u003c/span\u003e\n```\n\nYou can change this to `append` in the options:\n\n```js\noptions: {\n  wordcount: {\n    placement: 'append'\n  }\n}\n```\n\nAnd this template:\n\n```html\n\u003cspan class=\"label-wordcount\"\u003eWords: \u003c/span\u003e\n\u003cspan class=\"label-reading-time\"\u003eEstimated reading time: \u003c/span\u003e\n```\n\nWould result in:\n\n```html\n\u003cspan class=\"label-wordcount\" data-wordcount=\"1561\"\u003eWords: 1561\u003c/span\u003e\n\u003cspan class=\"label-reading-time\" data-reading-time=\"7 minutes, 48 seconds\"\u003eEstimated reading time: 8 minutes\u003c/span\u003e\n```\n\n***\n\n## Contributing\n\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/assemble/grunt-assemble-wordcount/issues/new).\n\n## Authors\n\n**Jon Schlinkert**\n\n+ [github/jonschlinkert](https://github.com/jonschlinkert)\n+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)\n\n## Other grunt-assemble plugins\n\n* [grunt-assemble](https://www.npmjs.com/package/grunt-assemble): Static site generator for Grunt.js, Yeoman and Node.js. Used by Zurb Foundation, Zurb Ink, H5BP/Effeckt,… [more](https://www.npmjs.com/package/grunt-assemble) | [homepage](http://assemble.io)\n* [grunt-assemble-anchors](https://www.npmjs.com/package/grunt-assemble-anchors): Assemble plugin for creating anchor tags from headings in generated html using Cheerio.js. | [homepage](https://github.com/assemble/grunt-assemble-anchors)\n* [grunt-assemble-contextual](https://www.npmjs.com/package/grunt-assemble-contextual): Generates a JSON file with the context of each page. Basic plugin to help see… [more](https://www.npmjs.com/package/grunt-assemble-contextual) | [homepage](https://github.com/assemble/grunt-assemble-contextual)\n* [grunt-assemble-decompress](https://www.npmjs.com/package/grunt-assemble-decompress): Assemble plugin for extracting zip, tar and tar.gz archives. | [homepage](https://github.com/assemble/grunt-assemble-decompress)\n* [grunt-assemble-download](https://www.npmjs.com/package/grunt-assemble-download): Assemble plugin for downloading files from GitHub. | [homepage](https://github.com/assemble/grunt-assemble-download)\n* [grunt-assemble-i18n](https://www.npmjs.com/package/grunt-assemble-i18n): Plugin for adding i18n support to Assemble projects. | [homepage](https://github.com/assemble/grunt-assemble-i18n)\n* [grunt-assemble-lunr](https://www.npmjs.com/package/grunt-assemble-lunr): Assemble plugin for adding search capabilities to your static site, with lunr.js. | [homepage](http://assemble.io)\n* [grunt-assemble-navigation](https://www.npmjs.com/package/grunt-assemble-navigation): Assemble navigation plugin. Automatically generate Bootstrap-style, multi-level side nav. See the sidenav on assemble.io for… [more](https://www.npmjs.com/package/grunt-assemble-navigation) | [homepage](https://github.com/assemble/grunt-assemble-navigation)\n* [grunt-assemble-permalinks](https://www.npmjs.com/package/grunt-assemble-permalinks): Permalinks plugin for Assemble, the static site generator for Grunt.js, Yeoman and Node.js. This plugin… [more](https://www.npmjs.com/package/grunt-assemble-permalinks) | [homepage](https://github.com/assemble/grunt-assemble-permalinks)\n* [grunt-assemble-sitemap](https://www.npmjs.com/package/grunt-assemble-sitemap): Sitemap plugin for Assemble | [homepage](http://assemble.io/plugins)\n* [grunt-assemble-toc](https://www.npmjs.com/package/grunt-assemble-toc): Assemble middleware for adding a Table of Contents (TOC) to any HTML page. | [homepage](http://assemble.io)\n\n## License\n\nCopyright © 2015 Jon Schlinkert\nReleased under the MIT license.\n\n***\n\n_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on September 25, 2015._","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fassemble%2Fgrunt-assemble-wordcount","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fassemble%2Fgrunt-assemble-wordcount","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fassemble%2Fgrunt-assemble-wordcount/lists"}