Skip to content

Commit 79235b6

Browse files
committed
doc: improve README
1 parent dc75d63 commit 79235b6

File tree

1 file changed

+30
-8
lines changed

1 file changed

+30
-8
lines changed

.github/README.md

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[![GitHub license](https://img.shields.io/github/license/jcdcdev/jcdcdev.Umbraco.ReadingTime?color=8AB803)](../LICENSE)
66
[![Downloads](https://img.shields.io/nuget/dt/jcdcdev.Umbraco.ReadingTime?color=cc9900)](https://www.nuget.org/packages/jcdcdev.Umbraco.ReadingTime/)
77

8-
Custom Data Type for calculating reading time.
8+
Custom Data Type for calculating reading time. With full variant support!
99

1010
The following editors are currently supported:
1111

@@ -20,23 +20,40 @@ The following editors are currently supported:
2020
## Quick Start
2121

2222
1. Install the [NuGet package](https://www.nuget.org/packages/jcdcdev.Umbraco.ReadingTime) in your Umbraco CMS website project.
23-
2. Add the Reading Time data type to a document type.
24-
- Note: You can configure the words per minute in the data type settings.
23+
```
24+
dotnet add package jcdcdev.Umbraco.ReadingTime
25+
```
26+
2. Add the Reading Time data type to a document type. You can configure:
27+
- `Words per minute` (default is 200)
28+
- `Min Unit` (default is Minute)
29+
- `Max Unit` (default is Minute)
30+
![A screenshot of the BackOffice showing Reading Time data type](https://raw.githubusercontent.com/jcdcdev/jcdcdev.Umbraco.ReadingTime/main/docs/screenshots/datatype.png)
2531
3. Save and publish content.
2632
4. Reading Time will display in the backoffice
2733

28-
![A screenshot of the BackOffice showing Reading Time](https://raw.githubusercontent.com/jcdcdev/jcdcdev.Umbraco.ReadingTime/main/docs/screenshots/backoffice.png)
34+
![A screenshot of the BackOffice showing Reading Time](https://raw.githubusercontent.com/jcdcdev/jcdcdev.Umbraco.ReadingTime/main/docs/screenshots/backoffice.png)
2935

3036
## Using the value in your templates
3137

32-
In your template, you can accessing the Reading Time property.
38+
In your template, you can accessing the Reading Time property value like any other property:
39+
40+
```html
41+
@Model.ReadingTime.DisplayTime()
42+
```
43+
44+
![A screenshot of page showing Reading Time](https://raw.githubusercontent.com/jcdcdev/jcdcdev.Umbraco.ReadingTime/main/docs/screenshots/displaytime.png)
45+
46+
### Overriding the default display
47+
The `DisplayTime` method will format the reading time as a string using [Humanizer](https://github.com/Humanizr/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").
48+
49+
Min and max `TimeUnit` values are derived from the Data Type settings. The below example shows how you can ensure only seconds are displayed.
3350

3451
```csharp
35-
<div class="alert alert-info">
36-
Read in @Model.ReadingTime.DisplayTime()
37-
</div>
52+
Model.ReadingTime.DisplayTime(minUnit: TimeUnit.Second, maxUnit: TimeUnit.Second)
3853
```
3954

55+
56+
4057
## Configuration
4158

4259
You can change the average words per minute in the data type settings.
@@ -57,6 +74,10 @@ When creating a new data type, the default will be 200 words per minute. To chan
5774

5875
Draft content is _not_ included in the calculation.
5976

77+
**Words per minute applies to all variants.**
78+
79+
It is not currently possible to configure words per minute per culture.
80+
6081
## Extending
6182

6283
You can extend the data type to support additional editors by implementing the `IReadingTimeValueProvider` interface.
@@ -93,6 +114,7 @@ public class Composer : IComposer
93114
}
94115
}
95116
```
117+
96118
## Contributing
97119

98120
Contributions to this package are most welcome! Please read the [Contributing Guidelines](CONTRIBUTING.md).

0 commit comments

Comments
 (0)