Skip to content

Commit

Permalink
Add estimated reading time to post metadata
Browse files Browse the repository at this point in the history
- Set `reading_time = false` under `[params]` config to disable
  • Loading branch information
gcushen committed Sep 30, 2017
1 parent 34b9cf5 commit 6270d6e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions exampleSite/config.toml
Expand Up @@ -53,6 +53,9 @@ defaultContentLanguageInSubdir = false
# Examples: "Mon, Jan 2, 2006" or "2006-01-02"
date_format = "Jan 2, 2006"

# Show estimated reading time for posts?
reading_time = true

# Enable global LaTeX math rendering?
# If false, you can enable it locally on a per page basis.
math = false
Expand Down
3 changes: 3 additions & 0 deletions i18n/en.yaml
Expand Up @@ -11,6 +11,9 @@
- id: related
translation: Related

- id: minute_read
translation: min read

# Buttons

- id: btn_details
Expand Down
6 changes: 6 additions & 0 deletions layouts/partials/article_metadata.html
Expand Up @@ -11,6 +11,12 @@
</time>
</span>

{{ if ne $.Site.Params.reading_time false }}
<span class="article-reading-time">
{{ $.ReadingTime }} {{ i18n "minute_read" }}
</span>
{{ end }}

{{ if isset $.Params "categories" }}
{{ $categoriesLen := len $.Params.categories }}
{{ if gt $categoriesLen 0 }}
Expand Down
1 change: 1 addition & 0 deletions layouts/partials/css/academic.css
Expand Up @@ -465,6 +465,7 @@ article {
}

.article-metadata .article-date,
.article-metadata .article-reading-time,
.article-metadata .article-categories,
.article-metadata .article-tags {
margin-right: 10px;
Expand Down

0 comments on commit 6270d6e

Please sign in to comment.