npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

hexo-word-counter

v0.2.0

Published

Symbols count and time to read for articles.

Downloads

2,006

Readme

Hexo Word Counter

Build Status npm-image hexo-image lic-image

Word count and time to read for articles in Hexo blog.

The word count is based on Unicode® Standard Annex #29. Thus, when multiple languages are present in the post content, the total word count can be accurately counted.

With the power of Rust, this plugin is faster than almost all other Hexo plugins that offer similar functionality. See the benchmark below.

Installation

size-image dm-image dt-image

$ npm install hexo-word-counter
$ hexo clean

Usage

You can set options of hexo-word-counter in the Hexo's _config.yml (which locates in the root dir of your blog):

symbols_count_time:
  symbols: true
  time: true
  total_symbols: true
  total_time: true
  exclude_codeblock: false
  wpm: 275
  suffix: "mins."

If symbols_count_time option is not specified, the default parameters will be used.

Parameters

  • wpm – Words Per Minute. Default: 275. You can check this here.
    • Slow ≈ 200
    • Normal ≈ 275
    • Fast ≈ 350
  • suffix – If time to read less then 60 minutes, added suffix as string parameter.
    If not defined, mins. will be used as default.
  • exclude_codeblock – Allow to exclude all content inside code blocks for more accurate words counting.
    If not defined, false will be used as default.

Note for Chinese users: if you write posts in Chinese at most cases (without mixed English), recommended to set wpm to 300.
But if you usually mix your posts with English, set wpm to 275 will be nice.

For NexT Theme

This plugin integrated in «NexT» and after plugin enabled in main Hexo config, you may adjust options in NexT config:

post_meta:
  item_text: true

symbols_count_time:
  separated_meta: true
  item_text_total: false

Development

You have to prepare both Node.js and rust toolchain to develop this plugin.

$ git clone https://github.com/next-theme/hexo-word-counter.git
$ cd hexo-word-counter
$ npm install

You can run tests with or without coverage feedback:

$ npm test
$ npm run test-cov

And you can install the development version in your blog:

$ cd blog
$ npm i ../path/to/hexo-word-counter

Theme Integration

If you're a theme developer, you can use the following code to integrate this plugin.

Word Count

The syntax is different depending on the templating engine of the theme.

For Nunjucks / Swig:

{{ symbolsCount(post) }}

For Ejs:

<%- symbolsCount(post) %>

For Pug / Jade:

span=symbolsCount(post)

In the latter part, we use Nunjucks syntax as an example.

Post Reading Time

{{ symbolsTime(post) }}

Or with predefined parameters:

{{ symbolsTime(post, awl, wpm, suffix) }}

Total Word Count

{{ symbolsCountTotal(site) }}

Total Post Reading Time

{{ symbolsTimeTotal(site) }}

Or with predefined parameters:

{{ symbolsTimeTotal(site, awl, wpm, suffix) }}

Benchmark

See GitHub actions.

| Plugin installed | Time of hexo g | | - | - | | Baseline | 19.48s | | hexo-word-counter | 19.63s (+0.78%) | | hexo-symbols-count-time | 19.86s (+1.99%) | | hexo-wordcount | 21.44s (+10.08%) | | hexo-reading-time | 23.81s (+22.26%) |