Custom Data Type for calculating reading time. With full variant support!
The following editors are currently supported:
- Rich Text
- Markdown
- Block Grid
- Block List
- Nested Content
- Textstring
- Textarea
- Install the NuGet package in your Umbraco CMS website project.
dotnet add package jcdcdev.Umbraco.ReadingTime - Add the Reading Time data type to a document type. You can configure:
Words per minute(default is 200)Min Unit(default is Minute)Max Unit(default is Minute)
- Save and publish content.
- Reading Time will display in the backoffice
In your template, you can accessing the Reading Time property value like any other property:
@Model.ReadingTime.DisplayTime()You can change the average words per minute in the data type settings.
When creating a new data type, the default will be 200 words per minute.
The DisplayTime method will format the reading time as a string using Humanizer. This supports variants, meaning the reading time will be displayed based on the pluralisation rules of the current culture (e.g. "1 minute", "2 minutes", "0 minuter").
Min and max TimeUnit values are derived from the Data Type settings. The below example shows how you can ensure only seconds are displayed.
Model.ReadingTime.DisplayTime(minUnit: TimeUnit.Second, maxUnit: TimeUnit.Second)Contributions to this package are most welcome! Please visit the Contributing page.
- LottePitcher - opinionated-package-starter