@renovamen/vuepress-plugin-reading-time

0.2.1 • Public • Published

@renovamen/vuepress-plugin-reading-time

A plugin for counting words and estimating reading time in VuePress. Compare to other similar VuePress plugins, this plugin supports:

  • Setting reading speed for English and Chinese separately
  • Excluding all content inside code blocks or tex blocks

 

Install

yarn add @renovamen/vuepress-plugin-reading-time
# or
npm install @renovamen/vuepress-plugin-reading-time

Then add it to your .vuepress/config.js:

module.exports = {
  plugins: ['@renovamen/vuepress-plugin-reading-time']
}

 

Usage

The readingTime data can be accessed by:

$page.readingTime

An example readingTime data:

{
  minutes: 12,
  words: 3500
}

You can override by specifying readingTime data in frontmatter

title: Hello Word
readingTime: { minutes: 3, words: 1500 }

 

Options

excludes

Exclude pages by their path via a regular expression. This tests for both path and regularPath. Will be ignored if includes is specified.

  • Type: Array<string>
  • Default: []

Example:

plugins: [
  [
    "@renovamen/vuepress-plugin-reading-time", {
      excludes: ["/tags/.*", "/links/"]
    }
  ]
]

 

includes

An allowlist of all pages that should be computed word count and reading time for. Includes pages by their path via a regular expression, tests for both path and regularPath.

If includes is specified, excludes will be ignored.

  • Type: Array<string>
  • Default: []

Example:

plugins: [
  [
    "@renovamen/vuepress-plugin-reading-time", {
      includes: ["/docs/.*"]
    }
  ]
]

 

wordsPerMinuteCN

The number of Chinese words per minute a user can read.

  • Type: int
  • Default: 300

Example:

plugins: [
  [
    '@renovamen/vuepress-plugin-reading-time', {
      wordsPerMinuteCN: 500
    }
  ]
]

 

wordsPerMinuteEN

The number of English words per minute a user can read.

  • Type: int
  • Default: 160

Example:

plugins: [
  [
    '@renovamen/vuepress-plugin-reading-time', {
      wordsPerMinuteEN: 200
    }
  ]
]

 

excludeCodeBlock

Exclude all content inside code blocks or not.

  • Type: boolean
  • Default: false

Example:

plugins: [
  [
    '@renovamen/vuepress-plugin-reading-time', {
      excludeCodeBlock: true
    }
  ]
]

 

excludeTexBlock

Exclude all content inside tex blocks or not.

  • Type: boolean
  • Default: false

Example:

plugins: [
  [
    '@renovamen/vuepress-plugin-reading-time', {
      excludeTexBlock: true
    }
  ]
]

 

License

MIT

Package Sidebar

Install

npm i @renovamen/vuepress-plugin-reading-time

Weekly Downloads

2

Version

0.2.1

License

MIT

Unpacked Size

61.8 kB

Total Files

18

Last publish

Collaborators

  • renovamen