Skip to content

Commit 1d1fa96

Browse files
authored
+semver: minor
2 parents d914417 + cdc3435 commit 1d1fa96

File tree

359 files changed

+18285
-8580
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

359 files changed

+18285
-8580
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).

.github/dependabot.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: nuget
4+
directory: "/"
5+
schedule:
6+
interval: "daily"
7+
time: "04:00"
8+
commit-message:
9+
prefix: "chore"
10+
include: "scope"
11+
12+
- package-ecosystem: npm
13+
directory: "/"
14+
schedule:
15+
interval: "daily"
16+
time: "04:00"
17+
commit-message:
18+
prefix: "chore"
19+
include: "scope"

.github/workflows/release.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
name: Release
22
on:
3-
pull_request:
4-
branches: "main"
5-
types: [ closed ]
63
workflow_dispatch:
74
jobs:
85
build:

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,8 @@ MigrationBackup/
353353
.ionide/
354354

355355
# Rider
356+
src/.idea
356357
*.sqlite.db*
357358
.idea/
358359
*.csproj.DotSettings
360+
**/umbraco/Data/TEMP/

docs/screenshots/backoffice.png

85.5 KB
Loading

docs/screenshots/datatype.png

62.7 KB
Loading

docs/screenshots/displaytime-2.png

64.9 KB
Loading

docs/screenshots/displaytime.png

68 KB
Loading

src/.editorconfig

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
[*]
22
max_line_length = 200
3-
indent_style = tab
3+
indent_style = space
44
indent_size = 4
55
tab_width = 4
6+
insert_final_newline = true
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
610

711
# ReSharper properties
812
resharper_braces_redundant = false

src/TestSite.10/Composer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ public class Composer : IComposer
77
public void Compose(IUmbracoBuilder builder)
88
{
99
}
10-
}
10+
}

0 commit comments

Comments
 (0)