Add optional reading time to single _layout

This commit is contained in:
Michael Rose 2016-03-21 21:42:55 -04:00
parent c7ebe1d4b3
commit bf4bf6ed82
10 changed files with 79 additions and 24 deletions

View file

@ -16,7 +16,7 @@ baseurl : "/minimal-mistakes" # the subpath of your site, e.g.
email : "your-email@domain.com" email : "your-email@domain.com"
logo : "site-logo.png" logo : "site-logo.png"
teaser : "500x300.png" teaser : "500x300.png"
breadcrumbs : true # true / false (default) breadcrumbs : true
breadcrumb_home_label : "Home" breadcrumb_home_label : "Home"
breadcrumb_separator : "/" breadcrumb_separator : "/"
twitter: twitter:
@ -25,7 +25,9 @@ facebook:
username : &facebook "site_facebook" username : &facebook "site_facebook"
app_id : app_id :
publisher : publisher :
share : true # false (default), true read_time : true
words_per_minute : 200
share : true
comments: comments:
provider : false # false (default), "disqus", "facebook", "google-plus", custom" provider : false # false (default), "disqus", "facebook", "google-plus", custom"
disqus: disqus:
@ -33,8 +35,8 @@ comments:
facebook: facebook:
# https://developers.facebook.com/docs/plugins/comments # https://developers.facebook.com/docs/plugins/comments
appid : appid :
num_posts : # 5 (default) num_posts : # 5
width : # 580 (default) width : # 580
colorscheme : # "light" (default), "dark" colorscheme : # "light" (default), "dark"
google_site_verification : google_site_verification :
bing_site_verification : bing_site_verification :
@ -131,6 +133,7 @@ defaults:
values: values:
layout: single layout: single
author_profile: true author_profile: true
read_time: true
comments: true comments: true
share: true share: true
related: true related: true

View file

@ -7,6 +7,9 @@ en: &DEFAULT_EN
pagination_next : "Next" pagination_next : "Next"
toc_label : "Overview" toc_label : "Overview"
ext_link_label : "Direct Link" ext_link_label : "Direct Link"
less_than : "less than"
minute_read : "minute read"
minutes_read : "minutes read"
share_on_label : "Share on" share_on_label : "Share on"
meta_label : meta_label :
tags_label : "Tags:" tags_label : "Tags:"
@ -23,4 +26,4 @@ en_UK:
<<: *DEFAULT_EN <<: *DEFAULT_EN
# Another locale # Another locale
# -------------- # --------------

9
_includes/read-time.html Normal file
View file

@ -0,0 +1,9 @@
{% assign words = page.content | strip_html | number_of_words %}
{% if words < 180 %}
{{ site.data.ui-text[site.locale].less_than }} 1 {{ site.data.ui-text[site.locale].minute_read }}
{% elsif words < 360 %}
1 {{ site.data.ui-text[site.locale].minute_read }}
{% else %}
{{ words | divided_by:site.words_per_minute }} {{ site.data.ui-text[site.locale].minutes_read }}
{% endif %}

View file

@ -12,6 +12,7 @@ layout: default
<div class="page__inner-wrap"> <div class="page__inner-wrap">
<header> <header>
<h1 class="page__title" itemprop="headline">{{ page.title | markdownify | remove: "<p>" | remove: "</p>" }}</h1> <h1 class="page__title" itemprop="headline">{{ page.title | markdownify | remove: "<p>" | remove: "</p>" }}</h1>
{% if site.read_time and page.read_time %}<p class="page__meta">{{ page.date | date: "%b %d, %Y" }} <span class="sep">·</span> {% include read-time.html %}</p>{% endif %}
</header> </header>
<section class="page__content" itemprop="text"> <section class="page__content" itemprop="text">

View file

@ -0,0 +1,18 @@
---
title: "Template: Read Time Disabled"
read_time: false
tags:
- read time
---
This post has reading time disabled. The estimated time that it takes to read this post should not be showing if `read_time: false` is set in `_config.yml` or in this post's YAML Front Matter.
If you could keep awake (but of course you can't) you would see your own mother doing this, and you would find it very interesting to watch her. It is quite like tidying up drawers. You would see her on her knees, I expect, lingering humorously over some of your contents, wondering where on earth you had picked this thing up, making discoveries sweet and not so sweet, pressing this to her cheek as if it were as nice as a kitten, and hurriedly stowing that out of sight. When you wake in the morning, the naughtiness and evil passions with which you went to bed have been folded up small and placed at the bottom of your mind and on the top, beautifully aired, are spread out your prettier thoughts, ready for you to put on.
I don't know whether you have ever seen a map of a person's mind. Doctors sometimes draw maps of other parts of you, and your own map can become intensely interesting, but catch them trying to draw a map of a child's mind, which is not only confused, but keeps going round all the time. There are zigzag lines on it, just like your temperature on a card, and these are probably roads in the island, for the Neverland is always more or less an island, with astonishing splashes of colour here and there, and coral reefs and rakish-looking craft in the offing, and savages and lonely lairs, and gnomes who are mostly tailors, and caves through which a river runs, and princes with six elder brothers, and a hut fast going to decay, and one very small old lady with a hooked nose. It would be an easy map if that were all, but there is also first day at school, religion, fathers, the round pond, needle-work, murders, hangings, verbs that take the dative, chocolate pudding day, getting into braces, say ninety-nine, three-pence for pulling out your tooth yourself, and so on, and either these are part of the island or they are another map showing through, and it is all rather confusing, especially as nothing will stand still.
Of course the Neverlands vary a good deal. John's, for instance, had a lagoon with flamingoes flying over it at which John was shooting, while Michael, who was very small, had a flamingo with lagoons flying over it. John lived in a boat turned upside down on the sands, Michael in a wigwam, Wendy in a house of leaves deftly sewn together. John had no friends, Michael had friends at night, Wendy had a pet wolf forsaken by its parents, but on the whole the Neverlands have a family resemblance, and if they stood still in a row you could say of them that they have each other's nose, and so forth. On these magic shores children at play are for ever beaching their coracles [simple boat]. We too have been there; we can still hear the sound of the surf, though we shall land no more.
Of all delectable islands the Neverland is the snuggest and most compact, not large and sprawly, you know, with tedious distances between one adventure and another, but nicely crammed. When you play at it by day with the chairs and table-cloth, it is not in the least alarming, but in the two minutes before you go to sleep it becomes very real. That is why there are night-lights.
Occasionally in her travels through her children's minds Mrs. Darling found things she could not understand, and of these quite the most perplexing was the word Peter. She knew of no Peter, and yet he was here and there in John and Michael's minds, while Wendy's began to be scrawled all over with him. The name stood out in bolder letters than any of the other words, and as Mrs. Darling gazed she felt that it had an oddly cocky appearance.

View file

@ -0,0 +1,18 @@
---
title: "Template: Read Time Enabled"
read_time: true
tags:
- read time
---
This post has reading time enabled. The estimated time that it takes to read this post should show if also enabled in `_config.yml` with `read_time: true`.
If you could keep awake (but of course you can't) you would see your own mother doing this, and you would find it very interesting to watch her. It is quite like tidying up drawers. You would see her on her knees, I expect, lingering humorously over some of your contents, wondering where on earth you had picked this thing up, making discoveries sweet and not so sweet, pressing this to her cheek as if it were as nice as a kitten, and hurriedly stowing that out of sight. When you wake in the morning, the naughtiness and evil passions with which you went to bed have been folded up small and placed at the bottom of your mind and on the top, beautifully aired, are spread out your prettier thoughts, ready for you to put on.
I don't know whether you have ever seen a map of a person's mind. Doctors sometimes draw maps of other parts of you, and your own map can become intensely interesting, but catch them trying to draw a map of a child's mind, which is not only confused, but keeps going round all the time. There are zigzag lines on it, just like your temperature on a card, and these are probably roads in the island, for the Neverland is always more or less an island, with astonishing splashes of colour here and there, and coral reefs and rakish-looking craft in the offing, and savages and lonely lairs, and gnomes who are mostly tailors, and caves through which a river runs, and princes with six elder brothers, and a hut fast going to decay, and one very small old lady with a hooked nose. It would be an easy map if that were all, but there is also first day at school, religion, fathers, the round pond, needle-work, murders, hangings, verbs that take the dative, chocolate pudding day, getting into braces, say ninety-nine, three-pence for pulling out your tooth yourself, and so on, and either these are part of the island or they are another map showing through, and it is all rather confusing, especially as nothing will stand still.
Of course the Neverlands vary a good deal. John's, for instance, had a lagoon with flamingoes flying over it at which John was shooting, while Michael, who was very small, had a flamingo with lagoons flying over it. John lived in a boat turned upside down on the sands, Michael in a wigwam, Wendy in a house of leaves deftly sewn together. John had no friends, Michael had friends at night, Wendy had a pet wolf forsaken by its parents, but on the whole the Neverlands have a family resemblance, and if they stood still in a row you could say of them that they have each other's nose, and so forth. On these magic shores children at play are for ever beaching their coracles [simple boat]. We too have been there; we can still hear the sound of the surf, though we shall land no more.
Of all delectable islands the Neverland is the snuggest and most compact, not large and sprawly, you know, with tedious distances between one adventure and another, but nicely crammed. When you play at it by day with the chairs and table-cloth, it is not in the least alarming, but in the two minutes before you go to sleep it becomes very real. That is why there are night-lights.
Occasionally in her travels through her children's minds Mrs. Darling found things she could not understand, and of these quite the most perplexing was the word Peter. She knew of no Peter, and yet he was here and there in John and Michael's minds, while Wendy's began to be scrawled all over with him. The name stood out in bolder letters than any of the other words, and as Mrs. Darling gazed she felt that it had an oddly cocky appearance.

View file

@ -1,18 +0,0 @@
---
title: "Template: Comments, Social Sharing Links, and Related Posts Disabled"
comments: false
share: false
related: false
categories:
- Template
- Uncategorized
tags:
- related posts
- social
- comments
- template
---
This post has comments, social sharing links, and related posts disabled.
Comments, social sharing and related post links should not appear.

View file

@ -0,0 +1,18 @@
---
title: "Template: Reading Time, Comments, Social Sharing Links, and Related Posts Disabled"
comments: false
share: false
related: false
categories:
- Template
- Uncategorized
tags:
- related posts
- social
- comments
- template
---
This post has reading time, comments, social sharing links, and related posts disabled.
Reading time, comments, social sharing and related post links should not appear.

View file

@ -40,6 +40,9 @@
.page__title { .page__title {
margin-top: 0; margin-top: 0;
font-family: $serif; font-family: $serif;
& + .page__meta {
margin-top: -1.5em;
}
} }
.page__content { .page__content {

File diff suppressed because one or more lines are too long