add readtime for posts (#622)
This commit is contained in:
parent
3f4910fde1
commit
a8332c40fd
@ -4,6 +4,8 @@ This file lists all non-trivial changes to Beautiful Jekyll.
|
|||||||
|
|
||||||
I often make small changes to documentation, to the demo site, or to the general look-and-feel. These changes will not be listed here. Any other minor changes will also not be listed here.
|
I often make small changes to documentation, to the demo site, or to the general look-and-feel. These changes will not be listed here. Any other minor changes will also not be listed here.
|
||||||
|
|
||||||
|
**2020-04-24** Adding readtime support for the post header (#622) (thanks @MutMatt and @rubyreads)
|
||||||
|
|
||||||
**2020-04-22** Add support for configuring lang attribute on <html> tag (#608) (thanks @skalee)
|
**2020-04-22** Add support for configuring lang attribute on <html> tag (#608) (thanks @skalee)
|
||||||
|
|
||||||
**2020-04-18** Add ability to disable round logo (thanks @gpotter2)
|
**2020-04-18** Add ability to disable round logo (thanks @gpotter2)
|
||||||
|
@ -189,6 +189,7 @@ defaults:
|
|||||||
layout: "post"
|
layout: "post"
|
||||||
comments: true # add comments to all blog posts
|
comments: true # add comments to all blog posts
|
||||||
social-share: true # add social media sharing buttons to all blog posts
|
social-share: true # add social media sharing buttons to all blog posts
|
||||||
|
readtime: false # add estimated reading time on all blog posts
|
||||||
-
|
-
|
||||||
scope:
|
scope:
|
||||||
path: "" # all files
|
path: "" # all files
|
||||||
|
@ -39,6 +39,9 @@
|
|||||||
|
|
||||||
{% if include.type == "post" %}
|
{% if include.type == "post" %}
|
||||||
<span class="post-meta">Posted on {{ page.date | date: date_format }}</span>
|
<span class="post-meta">Posted on {{ page.date | date: date_format }}</span>
|
||||||
|
{% if page.readtime %}
|
||||||
|
{% include readtime.html %}
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -64,6 +67,9 @@
|
|||||||
|
|
||||||
{% if include.type == "post" %}
|
{% if include.type == "post" %}
|
||||||
<span class="post-meta">Posted on {{ page.date | date: date_format }}</span>
|
<span class="post-meta">Posted on {{ page.date | date: date_format }}</span>
|
||||||
|
{% if page.readtime %}
|
||||||
|
{% include readtime.html %}
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
16
_includes/readtime.html
Normal file
16
_includes/readtime.html
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<!--- "ReadTime on GitHub Jekyll" (c) 2020 Ruby Griffith Ramirez, MIT License -->
|
||||||
|
|
||||||
|
{% assign ReadTime = page.content | strip_html | number_of_words %}
|
||||||
|
{% assign calcReadTime = ReadTime | float %}
|
||||||
|
{% assign finalReadTime = calcReadTime | divided_by:200 | round: 2 %}
|
||||||
|
{% assign number = finalReadTime | round %}
|
||||||
|
{% if number >= 1 %}
|
||||||
|
{% assign yesReadTime = number | append: " minute read" %}
|
||||||
|
<span class="reader-time post-meta"><span class="hidden-xs middot">·</span> {{ yesReadTime }}</span>
|
||||||
|
{% elsif number < 1 %}
|
||||||
|
{% assign minReadTime = '< 1 minute read' %}
|
||||||
|
<span class="reader-time post-meta"><span class="hidden-xs middot">·</span> {{ minReadTime }}</span>
|
||||||
|
{% else %}
|
||||||
|
{% assign nilReadTime = number | replace:'0',' ' %}
|
||||||
|
{{ nilReadTime }}
|
||||||
|
{% endif %}
|
12
css/main.css
12
css/main.css
@ -593,6 +593,18 @@ footer .theme-by {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.reader-time {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
@media (max-width: 767px) {
|
||||||
|
.reader-time {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.reader-time .middot {
|
||||||
|
margin: 0 10px;
|
||||||
|
}
|
||||||
|
|
||||||
/* --- Pager --- */
|
/* --- Pager --- */
|
||||||
|
|
||||||
.pager li a {
|
.pager li a {
|
||||||
|
Loading…
Reference in New Issue
Block a user