Skip to main content

Plugin for Pelican that computes average read time.

Project description

https://travis-ci.com/JenkinsDev/pelican-readtime.svg?branch=master

Plugin for Pelican that computes a piece of content’s read time.

It adds a readtime and readtime_string attributes to every article and/or page, with the time estimation for reading the article.

Setting Up

Adding ‘ReadTime’ to the list of plugins:

In pelicanconf.py:

PLUGINS = [
    ... ,
    'readtime'
]

1. Words Per Minute Only

In your settings you would use assign the READTIME_WPM variable to an integer like so:

In pelicanconf.py:

READTIME_WPM = 180

Every article’s read time would be calculated using this average words per minute count. (See the Usage section for how to use the calculated read times in templates). This is the simplest read time method.

2. Words Per Minute per language

This is the preferred method if you are dealing with multiple languages. Take a look at the following settings

In pelicanconf.py:

READTIME_WPM = {
    'default': {
        'wpm': 200,
        'min_singular': 'minute',
        'min_plural': 'minutes',
        'sec_singular': 'second',
        'sec_plural': 'seconds'
    },
    'es': {
        'wpm': 220,
        'min_singular': 'minuto',
        'min_plural': 'minutos',
        'sec_singular': 'segundo',
        'sec_plural': 'segundos'
    }
}

In this example the default reading time for all articles is 200 words per minute. Any articles in spanish will be calculated at 220 wpm. This is useful for information dense languages where the read time varies rapidly.

Chances are the average reading time will not vary rapidly from language to language, however using this method also allows you to set plurals which make templating easier in the long run.

Usage

Four variables are accessible through the read time plugin: readtime, readtime_string, readtime_with_seconds, and readtime_string_with_seconds

{% if article.readtime %} This article takes {{article.readtime}} minute(s) to read.{% endif %}
// This article takes 4 minute(s) to read.
{% if article.readtime_string %} This article takes {{article.readtime_string}} to read.{% endif %}
// This article takes 4 minutes to read.
{% if article.readtime_with_seconds %}
  This article takes {{article.read_with_seconds[0]}} minutes(s) and {{article.read_with_seconds[1]}} second(s) to read.
{% endif %}
// This article takes 4 minutes and 21 second(s) to read.
{% if article.readtime_string_with_seconds %} This article takes {{article.readtime_string_with_seconds}} to read.{% endif %}
// This article takes 4 minutes, 1 second to read.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pelican_readtime-0.2.1.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

pelican_readtime-0.2.1-py2.py3-none-any.whl (7.2 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pelican_readtime-0.2.1.tar.gz.

File metadata

  • Download URL: pelican_readtime-0.2.1.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for pelican_readtime-0.2.1.tar.gz
Algorithm Hash digest
SHA256 d83fda594e05ba53ade767d1d702b79f2b1074a2f09eda69380b1ea32b71598a
MD5 79963e74db9e9edc19bea5ee1d94f6be
BLAKE2b-256 d8fca8384503aae7ac947ccf3a8fbe612a2d24ab1099e08ede64ae43ba3864eb

See more details on using hashes here.

File details

Details for the file pelican_readtime-0.2.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for pelican_readtime-0.2.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 22497c9dc83554f188d13af6a362d023b2c6e811af703553d99dfc404c52feec
MD5 5a3ac8074c061261737f1442ee54ba21
BLAKE2b-256 9586b8ad83fd38d6ac6736f5082e18b17d40c2f5c801e14ae4b05d3ff8a86e0f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page