# mkdocs-timetoread-zh

mkdocs-timetoread-zh is a fork of @ntt4's [mkdocs-timetoread-plugin](https://github.com/ntt4/mkdocs-timetoread-plugin) with multiple language support.

## Setup

Install the plugin using pip:

`pip install mkdocs-timetoread-zh`

Activate the plugin in `mkdocs.yml`:

```yaml
plugins:
  - search
  - timetoread-zh
```

> **Note:** If you have no `plugins` entry in your config file yet, you'll likely also want to add the `search` plugin. MkDocs enables it by default if there is no `plugins` entry set, but now you have to enable it explicitly.

## mkdocs.yml Configuration

* `wpm` - Sets the 'words per minute' value for calculating estimated read time.
  * Default value is `255`
  * Possible value range: `1` - `999`

* `language` - Sets the language for the reading time message.
  * Default value is `en`
  * Possible values: `en`, `zh`

* `textColor` - Sets the CSS color for styling the 'Estimated read time:' text.
  * Default value is `bdbdbd`
  * Possible value range: `000000` - `ffffff`

* `template` - Sets the template for the reading time message.
  * Default value is `Estimated read time: {minutes} minutes`
  * Possible values: `Estimated read time: {minutes} minutes`, `预计阅读时长: {minutes} 分钟`

* `min_time` - Sets the minimum time for the reading time message to be displayed.
  * Default value is `1`
  * Possible value range: `1` - `999` (minutes)

* `round_method` - Sets the method for rounding the reading time.
  * Default value is `ceil`
  * Possible values: `ceil`, `floor`, `round`

* `allPages` - Sets all markdown files to have their read times' calculated unless explicitly disabled in the files' Front Matter.
  * Default value is `True`
  * Possible values: `True` or `False`

### Example Configuration

```yaml
plugins:
  - timetoread-zh:
      wpm: 300
      language: "zh"
      textColor: "666666"
      template: "阅读时间：{minutes}分钟"
      min_time: 1
      round_method: "ceil"
```

## Front Matter

Other configuration options are available by defining the following in a YAML front matter block in each markdown file.

```yaml
# Disable timetoread on a per file basis if `allPages` is set to True
timetoread: False
```

```yaml
# Enable timetoread on a per file basis if `allPages` is set to False
timetoread: True
```

## Usage

Once activated `mkdocs-timetoread-zh` will automatically add a new line, with the estimated time to read the document, after the `</h1>` tag in the HTML output generated by MkDocs.
