{%- include /authors/authors.html -%}
{% assign maxRelated = 1 %}
{% assign minCommonTags = 1 %}
{% assign maxRelatedCounter = 0 %}


{% for post in site.posts %}
{%- include /authors/authors.html -%}
{% assign sameTagCount = 0 %}
{% assign commonTags = '' %}

{% for tag in post.tags %}
{% if post.url != page.url %}
{% if page.tags contains tag %}
{% assign sameTagCount = sameTagCount | plus: 1 %}

{% capture tagmarkup %} <span class="label label-default">{{ tag }}</span> {% endcapture %}
{% assign commonTags = commonTags | append: tagmarkup %}

{% endif %}
{%- endif -%}
{% endfor %}


{% if sameTagCount >= minCommonTags %}
<div class="col-lg-4 col-md-6 mb-4 card-group">
    <div class="card h-100">
        <a href="{{ post.url }}">
            <img src="{{ post.image }}" loading="lazy" class="card-img-top" alt="">
        </a>
        <div class="card-body">
            <a class="text-decoration-none text-dark" href="{{ post.url }}" class="anchor_link">
                <h4 class="card-title mb-4 text-left">{{ post.title }}</h4>
            </a>
        </div>
        <div class="card-footer bg-white">
            <div class="wrapfooter">
                {% if post.author %}
                <span class="meta-footer-thumb">
                    <img class="author-thumb" loading="lazy" src="{{ image }}" alt="{{ authorName }}">
                </span>
                {% endif %}
                <span class="author-meta">
                    <span class="post-name">
                        <a target="_blank" href="/blog">{{authorName}}</a>
                    </span><br>
                    <span class="post-date">{{post.date | date_to_string }}</span>
                </span>
                <span class="post-read-more"><a class="text-dark" href="{{ post.url }}" title="Read Story">Read
                        More</a></span>
            </div>
        </div>
    </div>
</div>
{% assign maxRelatedCounter = maxRelatedCounter | plus: 1 %}
{% if maxRelatedCounter >= maxRelated %}
{% break %}
{% endif %}
{% endif %}
{% endfor %}