Add ETA time

This commit is contained in:
samaradel
2022-09-29 18:20:12 +02:00
parent f476a35789
commit 38827133fa
4 changed files with 85 additions and 78 deletions

View File

@@ -4,6 +4,19 @@ var hamburgerShown = false;
let width = screen.width; let width = screen.width;
var isMobile = width < 1024; var isMobile = width < 1024;
function readingTime() {
let articles = document.querySelectorAll(".article");
let times = document.querySelectorAll(".time");
const wpm = 225;
let words;
for (var i = 0; i < articles.length; i++) {
words = articles[i].innerText.trim().split(/\s+/).length;
let time = Math.ceil(words / wpm);
times[i].innerText = `${time} minute read`
}
}
readingTime()
function toggleMenu(button) { function toggleMenu(button) {
if (displayedMenu === button.id.split("-")[0]) { if (displayedMenu === button.id.split("-")[0]) {
button.className = button.className.replace(" text-gray-800 bg-stone-200 sm:bg-transparent", " text-gray-900"); button.className = button.className.replace(" text-gray-800 bg-stone-200 sm:bg-transparent", " text-gray-900");

View File

@@ -36,7 +36,6 @@
for (var i = 0, linksLength = links.length; i < linksLength; i++) { for (var i = 0, linksLength = links.length; i < linksLength; i++) {
if (!internal_hosts.includes(links[i].hostname)) { if (!internal_hosts.includes(links[i].hostname)) {
links[i].target = '_blank'; links[i].target = '_blank';
console.log(links[i])
} }
} }
</script> </script>

View File

@@ -2,48 +2,32 @@
{% block content %} {% block content %}
{% if page.taxonomies.people %} {% if page.taxonomies.people %}
{% set people = get_section(path="people/_index.md") %} {% set people = get_section(path="people/_index.md") %}
{% set pages_str = people.pages | json_encode() | as_str %} {% set pages_str = people.pages | json_encode() | as_str %}
{% if pages_str is containing(page.taxonomies.people[0]) %} {% if pages_str is containing(page.taxonomies.people[0]) %}
{% set author_path = 'people/' ~ page.taxonomies.people[0] ~ '/index.md' %} {% set author_path = 'people/' ~ page.taxonomies.people[0] ~ '/index.md' %}
{% set author = get_page(path=author_path) %} {% set author = get_page(path=author_path) %}
{% endif %} {% endif %}
{% endif %} {% endif %}
<!-- Default page template for blog posts and basic informative markdown files --> <!-- Default page template for blog posts and basic informative markdown files -->
{% set split = page.content | split(pat="threefold.io") %} {% set split = page.content | split(pat="threefold.io") %}
{% if split | length < 2 %} {% if split | length < 2 %} {% set content=page.content %} {% else %} {% set content="" %} {% for part in split %} {% if
{% set content = page.content %} part is starting_with("/blog") %} {% set split_part=part | split(pat='/">' ) %} {% set link=split_part[0] %} {% set
{% else %} link=link | replace(from="/blog/post" , to="/blog" ) %} {% set link=link | replace(from="_" , to="-" ) %} {% set
{% set content = "" %} rest_part=split_part | slice(start=1) | join(sep='/">' ) %} {% set part=link ~ '/">' ~ rest_part %} {% endif %} {% if
{% for part in split %} loop.first %} {% set_global content=part%} {% else %} {% set_global content=content ~ "threefold.io" ~ part%} {% endif
{% if part is starting_with("/blog") %} %} {% endfor %} {% endif %} <main>
{% set split_part = part | split(pat='/">') %}
{% set link = split_part[0] %}
{% set link = link | replace(from="/blog/post", to="/blog") %}
{% set link = link | replace(from="_", to="-") %}
{% set rest_part = split_part | slice(start=1) | join(sep='/">') %}
{% set part = link ~ '/">' ~ rest_part %}
{% endif %}
{% if loop.first %}
{% set_global content = part%}
{% else %}
{% set_global content = content ~ "threefold.io" ~ part%}
{% endif %}
{% endfor %}
{% endif %}
<main>
<div class="container mx-auto mt-10"> <div class="container mx-auto mt-10">
<div> <div>
<article id="article" class="article lg:w-4/6 mx-auto"> <article class="article lg:w-4/6 mx-auto">
<h1 class="lg:text-5xl font-medium leading-none mt-0 text-gray-700"> <h1 class="lg:text-5xl font-medium leading-none mt-0 text-gray-700">
{{ page.title }} {{ page.title }}
</h1> </h1>
<h4 class="text-2xl text-gray-600 leading-8"> <h4 class="text-2xl text-gray-600 leading-8">
{{ page.description }} {{ page.description }}
</h4> </h4>
@@ -52,9 +36,10 @@
<div class="flex justify-between items-center"> <div class="flex justify-between items-center">
<ul class="list-none flex author-list m-0"> <ul class="list-none flex author-list m-0">
<li class="author-list-item"> <li class="author-list-item">
{% if author %} {% if author %}
{% set author_img = get_url(path='/' ~ author.relative_path | replace(from='_', to='-') | replace(from='index.md', to=author.extra.imgPath)) %} {% set author_img = get_url(path='/' ~ author.relative_path | replace(from='_', to='-') |
<img src="{{author_img}}" alt="{{author.title}}" class=" replace(from='index.md', to=author.extra.imgPath)) %}
<img src="{{author_img}}" alt="{{author.title}}" class="
h-8 h-8
w-8 w-8
sm:h-10 sm:h-10
@@ -69,22 +54,22 @@
</div> </div>
<div class="pl-3 flex flex-col text-xs leading-none uppercase"> <div class="pl-3 flex flex-col text-xs leading-none uppercase">
{% if author %} {% if author %}
<a href="{{author.permalink}}" class="text-gray-700 text-xs">{{ author.title }}</a> <a href="{{author.permalink}}" class="text-gray-700 text-xs">{{ author.title }}</a>
{% endif %} {% endif %}
<p class="text-gray-700 text-xs"> <p class="text-gray-700 text-xs">
<time datetime="{{ page.date }}"> {{ page.date | date(format="%B %e, %Y", timezone="America/Chicago") }}</time> <time datetime="{{ page.date }}"> {{ page.date | date(format="%B %e, %Y", timezone="America/Chicago")
}}</time>
</p> </p>
</div> </div>
</div> </div>
<div class="my-2 sharethis-inline-share-buttons"></div> <div class="my-2 sharethis-inline-share-buttons"></div>
</section> </section>
{% set img_url = get_url(path='/' ~ page.relative_path | replace(from='_', to='-') | replace(from='index.md', to=page.extra.imgPath)) %} {% set img_url = get_url(path='/' ~ page.relative_path | replace(from='_', to='-') | replace(from='index.md',
to=page.extra.imgPath)) %}
<img class="mb-8 mx-auto" src={{img_url}} alt="{{page.title ~ 'Picture'}}"> <img class="mb-8 mx-auto" src={{img_url}} alt="{{page.title ~ 'Picture'}}">
<div id="article">{{ content | safe }}</div> <div>{{ content | safe }}</div>
<section class="post-tags container relative py-10"> <section class="post-tags container relative py-10">
{% for tag in page.taxonomies.tags %} {% for tag in page.taxonomies.tags %}
{% set fullpath = "/tags/" ~ tag | replace(from='_', to='-' ) %} {% set fullpath = "/tags/" ~ tag | replace(from='_', to='-' ) %}
@@ -109,6 +94,6 @@
</div> </div>
</main> </main>
{% endblock content %} {% endblock content %}

View File

@@ -1,17 +1,19 @@
{% if post.date %} {% if post.date %}
{% if post.taxonomies.people %} {% if post.taxonomies.people %}
{% set people = get_section(path="people/_index.md") %} {% set people = get_section(path="people/_index.md") %}
{% set pages_str = people.pages | json_encode() | as_str %} {% set pages_str = people.pages | json_encode() | as_str %}
{% if pages_str is containing(post.taxonomies.people[0]) %} {% if pages_str is containing(post.taxonomies.people[0]) %}
{% set author_path = 'people/' ~ post.taxonomies.people[0] ~ '/index.md' %} {% set author_path = 'people/' ~ post.taxonomies.people[0] ~ '/index.md' %}
{% set author = get_page(path=author_path) %} {% set author = get_page(path=author_path) %}
{% endif %} {% set content = get_page(path=author_path) %}
{% endif %}
{% endif %} {% endif %}
<div class="flex flex-col rounded-lg shadow-lg overflow-hidden"> <div class="flex flex-col rounded-lg shadow-lg overflow-hidden">
<div class="flex-1 border-b"> <div class="flex-1 border-b">
<a href="{{ post.permalink }}" class="block"> <a href="{{ post.permalink }}" class="block">
{% set img_url = get_url(path='/' ~ post.relative_path | replace(from='_', to='-') | replace(from='index.md', to=post.extra.imgPath)) %} {% set img_url = get_url(path='/' ~ post.relative_path | replace(from='_', to='-') | replace(from='index.md',
to=post.extra.imgPath)) %}
<div class="flex-shrink-0"> <div class="flex-shrink-0">
<img class="h-48 w-full mx-auto object-cover" src={{img_url}} alt="{{post.title ~ ' Picture'}}" /> <img class="h-48 w-full mx-auto object-cover" src={{img_url}} alt="{{post.title ~ ' Picture'}}" />
</div> </div>
@@ -25,39 +27,47 @@
{{ post.description }} {{ post.description }}
</p> </p>
{% endif %} {% endif %}
<div class="article hidden">{{ post.content | safe }}</div>
<div class="w-full post-card-meta py-3">
<div class="avatars">
<div class="flex">
<div class="flex">
<ul class="list-none flex author-list mr-2 pl-0">
{% if author %}
{% set author_img = get_url(path='/' ~ author.relative_path | replace(from='_', to='-') |
replace(from='index.md', to=author.extra.imgPath)) %}
<li class="author-list-item"><img alt="{{author.title}}" src="{{author_img}}"
class="w-8 h-8 rounded-full bg-gray-200 border-2 border-white"></li>
{% endif %}
</ul>
</div>
<div class="flex flex-col text-left leading-none uppercase">
{% if author %}
<p class="text-gray-700 text-xs">{{ author.title }}</p>
{% endif %}
<p class="text-gray-700 text-xs">
<time datetime="{{post.date}}">
{{ post.date | date(format="%B %e, %Y", timezone="America/Chicago") }}
</time>
</p>
<p class="flex justify-between lowercase my-2 items-center text-gray-700 text-xs"><span id="time"
class="time"></span>
</p>
</div>
<br />
</div>
</div>
</div>
</a> </a>
</div> </div>
<div class="w-full post-card-meta py-3">
<div class="avatars">
<div class="flex items-center">
<div class="flex justify-between items-center">
<ul class="list-none flex author-list mr-2">
{% if author %}
{% set author_img = get_url(path='/' ~ author.relative_path | replace(from='_', to='-') | replace(from='index.md', to=author.extra.imgPath)) %}
<li class="author-list-item"><img alt="{{author.title}}" src="{{author_img}}"
class="w-8 h-8 rounded-full bg-gray-200 border-2 border-white"></li>
{% endif %}
</ul>
</div>
<div class="flex flex-col text-left leading-none uppercase">
{% if author %}
<p class="text-gray-700 text-xs">{{ author.title }}</p>
{% endif %}
<p class="text-gray-700 text-xs">
<time datetime="{{post.date}}">
{{ post.date | date(format="%B %e, %Y", timezone="America/Chicago") }}
</time>
</p>
</div>
</div>
</div>
</div>
</div> </div>
</div> </div>
<style> <style>
.border-b { .border-b {
border-bottom-width: 1px !important; border-bottom-width: 1px !important;
} }
</style> </style>
{% endif %} {% endif %}