diff --git a/_includes/archive-single.html b/_includes/archive-single.html index de77f696d2c3..b332ea9f6727 100644 --- a/_includes/archive-single.html +++ b/_includes/archive-single.html @@ -24,9 +24,7 @@

{{ title }} {% endif %}

- {% if post.read_time %} -

{% include read-time.html %}

- {% endif %} + {% include post__meta.html type=include.type %} {% if post.excerpt %}

{{ post.excerpt | markdownify | strip_html | truncate: 160 }}

{% endif %} diff --git a/_includes/page__hero.html b/_includes/page__hero.html index 27fcaff771bd..8e477535c9ef 100644 --- a/_includes/page__hero.html +++ b/_includes/page__hero.html @@ -31,9 +31,7 @@

{% elsif page.header.show_overlay_excerpt != false and page.excerpt %}

{{ page.excerpt | markdownify | remove: "

" | remove: "

" }}

{% endif %} - {% if page.read_time %} -

{% include read-time.html %}

- {% endif %} + {% include post__meta.html %} {% if page.header.cta_url %}

{{ page.header.cta_label | default: site.data.ui-text[site.locale].more_label | default: "Learn More" }}

{% endif %} diff --git a/_includes/post__meta.html b/_includes/post__meta.html new file mode 100644 index 000000000000..1ea81e5bbcba --- /dev/null +++ b/_includes/post__meta.html @@ -0,0 +1,35 @@ +{% assign page = post | default: page %} + +{% if page.read_time or page.show_date %} +

+ + {% if page.show_date %} + {% assign date = page.date %} + + + {% endif %} + + {% if page.read_time and page.show_date %} + {% if include.type == "grid" %} +
+ {% else %} + + {% endif %} + {% endif %} + + {% if page.read_time %} + {% assign words_per_minute = page.words_per_minute | default: site.words_per_minute | default: 200 %} + {% assign words = page.content | strip_html | number_of_words %} + + + {% if words < words_per_minute %} + {{ site.data.ui-text[site.locale].less_than | default: "less than" }} 1 {{ site.data.ui-text[site.locale].minute_read | default: "minute read" }} + {% elsif words == words_per_minute %} + 1 {{ site.data.ui-text[site.locale].minute_read | default: "minute read" }} + {% else %} + {{ words | divided_by:words_per_minute }} {{ site.data.ui-text[site.locale].minute_read | default: "minute read" }} + {% endif %} + {% endif %} + +

+{% endif %} \ No newline at end of file diff --git a/_includes/read-time.html b/_includes/read-time.html deleted file mode 100644 index 588574433c50..000000000000 --- a/_includes/read-time.html +++ /dev/null @@ -1,15 +0,0 @@ -{% assign words_per_minute = page.words_per_minute | default: site.words_per_minute | default: 200 %} - -{% if post.read_time %} - {% assign words = post.content | strip_html | number_of_words %} -{% elsif page.read_time %} - {% assign words = page.content | strip_html | number_of_words %} -{% endif %} - -{% if words < words_per_minute %} - {{ site.data.ui-text[site.locale].less_than | default: "less than" }} 1 {{ site.data.ui-text[site.locale].minute_read | default: "minute read" }} -{% elsif words == words_per_minute %} - 1 {{ site.data.ui-text[site.locale].minute_read | default: "minute read" }} -{% else %} - {{ words | divided_by:words_per_minute }} {{ site.data.ui-text[site.locale].minute_read | default: "minute read" }} -{% endif %} diff --git a/_layouts/single.html b/_layouts/single.html index d799abed0d05..808ed088e0bb 100644 --- a/_layouts/single.html +++ b/_layouts/single.html @@ -27,9 +27,7 @@ {% unless page.header.overlay_color or page.header.overlay_image %}
{% if page.title %}

{{ page.title | markdownify | remove: "

" | remove: "

" }}

{% endif %} - {% if page.read_time %} -

{% include read-time.html %}

- {% endif %} + {% include post__meta.html %}
{% endunless %} diff --git a/_sass/minimal-mistakes/_page.scss b/_sass/minimal-mistakes/_page.scss index 458733a3ae53..c4bf8ae76b73 100644 --- a/_sass/minimal-mistakes/_page.scss +++ b/_sass/minimal-mistakes/_page.scss @@ -299,6 +299,12 @@ body { text-transform: uppercase; } +.post__meta-sep::before { + content: "\2022"; + padding-left: 0.5em; + padding-right: 0.5em; +} + /* Page taxonomy ========================================================================== */ diff --git a/docs/_docs/05-configuration.md b/docs/_docs/05-configuration.md index 4ad70aaa30e8..d162dc314313 100644 --- a/docs/_docs/05-configuration.md +++ b/docs/_docs/05-configuration.md @@ -265,6 +265,26 @@ breadcrumbs: true # disabled by default Breadcrumb start link text and separator character can both be changed in the [UI Text data file]({{ "/docs/ui-text/" | relative_url }}). +### Post dates + +Enable post date snippets with `show_date: true` in YAML Front Matter. + +![post date example]({{ "/assets/images/mm-post-date-example.png" | relative_url }}) + +Instead of adding `show_date: true` to each post, apply as a default in `_config.yml` like so: + +```yaml +defaults: + # _posts + - scope: + path: "" + type: posts + values: + show_date: true +``` + +To disable post date for a post, add `show_date: false` its YAML Front Matter to override what was set in `_config.yml`. + ### Reading time Enable estimated reading time snippets with `read_time: true` in YAML Front Matter. `200` has been set as the default words per minute value --- which can be changed by adjusting `words_per_minute:` in `_config.yml`. @@ -291,6 +311,20 @@ To disable reading time for a post, add `read_time: false` its YAML Front Matter words_per_minute: 250 ``` +### Post meta separator + +To customise the separator between the post date and reading time (if both are enabled), edit ```.post__meta-sep::before``` in a [custom stylesheet]({{ "/docs/stylesheets/" | relative_url }}). + +For example, + +```css +.post__meta-sep::before { + content: "\2022"; + padding-left: 0.5em; + padding-right: 0.5em; +} +``` + ### Comments [**Disqus**](https://disqus.com/), [**Discourse**](https://www.discourse.org/), [**Facebook**](https://developers.facebook.com/docs/plugins/comments), [**utterances**](https://utteranc.es/), and static-based commenting via [**Staticman**](https://staticman.net/) are built into the theme. First set the comment provider you'd like to use: diff --git a/docs/_posts/2012-01-02-layout-post-date-disabled.md b/docs/_posts/2012-01-02-layout-post-date-disabled.md new file mode 100644 index 000000000000..77f2c3387320 --- /dev/null +++ b/docs/_posts/2012-01-02-layout-post-date-disabled.md @@ -0,0 +1,18 @@ +--- +title: "Layout: Post Date Disabled" +show_date: false +tags: + - post date +--- + +This post has reading time disabled. The estimated time that it takes to read this post should not be showing if `show_date: 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. \ No newline at end of file diff --git a/docs/_posts/2012-01-02-layout-post-date.md b/docs/_posts/2012-01-02-layout-post-date.md new file mode 100644 index 000000000000..b2fc747cfdc7 --- /dev/null +++ b/docs/_posts/2012-01-02-layout-post-date.md @@ -0,0 +1,18 @@ +--- +title: "Layout: Post Date Enabled" +show_date: true +tags: + - post date +--- + +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 `show_date: 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. \ No newline at end of file diff --git a/docs/assets/images/mm-post-date-example.png b/docs/assets/images/mm-post-date-example.png new file mode 100644 index 000000000000..a209b97dc1c0 Binary files /dev/null and b/docs/assets/images/mm-post-date-example.png differ diff --git a/test/_posts/2012-01-02-layout-post-date-disabled.md b/test/_posts/2012-01-02-layout-post-date-disabled.md new file mode 100644 index 000000000000..77f2c3387320 --- /dev/null +++ b/test/_posts/2012-01-02-layout-post-date-disabled.md @@ -0,0 +1,18 @@ +--- +title: "Layout: Post Date Disabled" +show_date: false +tags: + - post date +--- + +This post has reading time disabled. The estimated time that it takes to read this post should not be showing if `show_date: 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. \ No newline at end of file diff --git a/test/_posts/2012-01-02-layout-post-date.md b/test/_posts/2012-01-02-layout-post-date.md new file mode 100644 index 000000000000..b2fc747cfdc7 --- /dev/null +++ b/test/_posts/2012-01-02-layout-post-date.md @@ -0,0 +1,18 @@ +--- +title: "Layout: Post Date Enabled" +show_date: true +tags: + - post date +--- + +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 `show_date: 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. \ No newline at end of file