Skip to content

Latest commit

 

History

History

reading-time

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

@renovamen/vuepress-plugin-reading-time@next

npm docs license

Plugin @renovamen/vuepress-plugin-reading-time@next for counting words and estimating reading time in VuePress 2. 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

Demo (see the number beside the clock icon)

 

Install

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

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

const { readingTimePlugin } = require("@renovamen/vuepress-plugin-reading-time");

module.exports = {
  plugins: [
    readingTimePlugin()
  ]
}

 

Usage

The readingTime data can be accessed by:

import { pageData } from "@vuepress/client";
console.log(pageData.value.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. Will be ignored if includes is specified.

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

Example:

plugins: [
  readingTimePlugin({
    excludes: ["/docs/.*", "/posts/hello-word.html"]
  })
]

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.

If includes is specified, excludes will be ignored.

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

Example:

plugins: [
  readingTimePlugin({
    includes: ["/docs/.*"]
  })
]

wordsPerMinuteCN

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

  • Type: int
  • Default: 300

Example:

plugins: [
  readingTimePlugin({
    wordsPerMinuteCN: 500
  })
]

wordsPerMinuteEN

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

  • Type: int
  • Default: 160

Example:

plugins: [
  readingTimePlugin({
    wordsPerMinuteEN: 200
  })
]

excludeCodeBlock

Exclude all content inside code blocks or not.

  • Type: boolean
  • Default: false

Example:

plugins: [
  readingTimePlugin({
    excludeCodeBlock: true
  })
]

excludeTexBlock

Exclude all content inside tex blocks or not.

  • Type: boolean
  • Default: false

Example:

plugins: [
  readingTimePlugin({
    excludeTexBlock: true
  })
]

 

License

MIT