Skip to content

Commit

Permalink
fix applause-button counting and add reading time
Browse files Browse the repository at this point in the history
  • Loading branch information
SamMed05 committed Dec 9, 2023
1 parent c15b6c5 commit d9a6d08
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 7 deletions.
6 changes: 6 additions & 0 deletions _includes/post-meta.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,11 @@
{% assign date_format = site.date_format | default: "%d %b %Y" %}

{{ categories | append: "&middot;&nbsp;" }}<time datetime="{{ page.date | date_to_xmlschema }}" class="time">{{ page.date | date: date_format }}</time>

<!-- https://jekyllrb.com/docs/variables/ -->
<!-- page.title contains "Samuel's blog" -->
{%- if page.layout == "post" -%}
{% include reading-time.html %}
{% endif %}

</small>
2 changes: 1 addition & 1 deletion _includes/post-related.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ <h1 class="no-print">Other posts:</h1>
<article class="article article--post typeset">

<h4><a href="{{ site.baseurl }}{{ page.url }}">{{ page.title }}</a></h4>
{% include post-meta.html %}

{{ page.excerpt | markdownify | truncatewords: 30 }}

</article>
Expand Down
12 changes: 9 additions & 3 deletions _includes/reading-time.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,23 @@
2. may have to add the words "Reading Time". Currently it uses an icon from https://github.com/danklammer/bytesize-icons
-->

<span class="read-time" title="Estimated read time">
<span class="read-time" title="Estimated read time" style="display: block;">
<!-- &middot; -->
<br>
<svg id="i-clock" viewBox="0 0 32 32" width="20" height="20" fill="none" stroke="currentcolor" stroke-linecap="round"
stroke-linejoin="round" stroke-width="2"><circle cx="16" cy="16" r="14" /><path d="M16 8 L16 16 20 20" /></svg>

{% assign words = content | number_of_words %}
{% if words < 360 %}
1 min read.
1 min read
{% else %}
{{ words | divided_by:180 }} mins read.
{{ words | divided_by:180 }} mins read
{% endif %}
</span>
<style>
span {
font-size: inherit;
font-style: inherit;
}
svg#i-clock {vertical-align: middle;}
</style>
3 changes: 3 additions & 0 deletions _includes/site-before-end.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{%- if page.layout == "post" or page.title == "Useful links" -%}
<applause-button multiclap="true" url="{{ page.url }}" color="#0072d6" style="line-height: 20px; width: 55px; height: 55px; left:2.5rem; bottom:2.5rem; position: fixed; display: block; background-color: rgb(255, 255, 255, 0.9); border-radius: 50%;"/>
{% endif %}
6 changes: 6 additions & 0 deletions _layouts/blog.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ <h1>{{ page.title }}</h1>
</article>

{% include post-list.html %}

<style>
.read-time {
display: none !important;
}
</style>


</div>
Expand Down
6 changes: 6 additions & 0 deletions _layouts/categories.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ <h1>{{ page.title }}</h1>

{% include post-categories.html %}

<style>
.read-time {
display: none !important;
}
</style>

</div>

{% if page.aside == true %}{% include site-aside.html align="left" %}{% endif %}
Expand Down
6 changes: 4 additions & 2 deletions _layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
<link rel="stylesheet" href="{{ "/assets/styles.css" | relative_url }}">
{% endif %}

{% include applause-button.html %}
{%- if page.layout == "post" or page.title == "Useful links" -%}
{% include applause-button.html %}
{% endif %}

<!-- {% if site.favicons or site.avatarurl %}{% include site-favicons.html %}{% endif %} -->

Expand All @@ -52,8 +54,8 @@

{% if site.service_worker != false %}{% include site-sw.html %}{% endif %}

{% include site-before-end.html %}
{% include topButton.html %}
{% include site-before-end.html %}
{% include cookie-consent.html %}
</body>

Expand Down
1 change: 0 additions & 1 deletion _layouts/post.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ <h1>{{ page.title }}</h1>

{% include post-related.html %}

<applause-button multiclap="true" color="#2696ff" style="line-height:20px; width: 55px; height: 55px; left:2.5rem; bottom:2.5rem; position: fixed; display: block; background-color: rgb(255, 255, 255, 0.9); border-radius: 50%;"/>
</article>

{% if page.aside == true %}{% include site-aside.html %}{% endif %}
Expand Down

0 comments on commit d9a6d08

Please sign in to comment.