<commit_before>{# ==========================================================================

   related_posts.render()

   ==========================================================================

   Description:

   Creates related posts markup when given:

   is_half_width:    A Boolean indicating whether the posts should be at half
                     width. Defaults to False.

   hide_header_slug: A Boolean indicating whether the header should be hidden.
                     Defaults to False.

   ========================================================================== #}

{% macro render(block, is_half_width=false, hide_header_slug=false) %}
    {% import 'macros/category-icon.html' as category_icon %}
    {% set related_post_types = page.related_posts(block, request.site.hostname) %}
    {% if related_post_types %}
        <div class="m-related-posts
                    {{'m-related-posts__half-width'
                      if is_half_width else ''}}">
            {% if not hide_header_slug %}
                <h2 class="header-slug">
                    <span class="header-slug_inner">
                        Related Posts
                    </span>
                </h2>
            {% endif %}
            {% for post_type, post_type_list in related_post_types.iteritems() %}
                {% set title, icon = (post_type, category_icon.render(post_type)) or ("Blog", "cf-icon-speech-bubble") %}
                <div class="m-related-posts_list-container">
                    {% if block.value.show_heading %}
                        <h3 class="h4">
                            {{ icon }} {{ title }}
                        </h3>
                    {% endif %}
                    {{ _related_posts_list(post_type_list, block.value.limit) }}
                </div>
            {% endfor %}
            {% for block in page.sidefoot %}
                {% if 'related_posts' in block.block_type %}
                    {% if block.value.view_more %}
                        {{ _view_more( block.value.view_more ) }}
                    {% endif %}
                {% endif %}
            {% endfor %}
        </div>
    {% endif %}
{% endmacro %}


{# ==========================================================================

   _related_posts_list()

   ==========================================================================

   Description:

   Creates related posts markup when given:

   posts: A list of dictionaries containing related posts.

   ========================================================================== #}

{% macro _related_posts_list(posts, limit) %}
    {% import 'macros/time.html' as time %}
    {% set limit = limit|int if posts|length >= limit|int else posts|length %}
    <ul class="m-related-posts_list
               list list__unstyled
               list__spaced">
        {% for i in range(limit) %}
            {% set post_url = slugurl(posts[i].slug) or '' %}
            <li class="list_item">
                <h3 class="h4 u-mb5">
                    <a class="list_link"
                       href="{{ post_url or posts[i].permalink }}">
                        {{ posts[i].title | safe }}
                    </a>
                </h3>
                {% if posts[i].text %}
                <p>
                    {{ posts[i].text | safe }}
                </p>
                {% endif %}
                <p class="date">
                    {% set date = posts[i].latest_revision_created_at or  posts[i].date %}
                    {{ time.render(date, {'date':true}) }}
                </p>
            </li>
        {% endfor %}
    </ul>

{% endmacro %}

{# ==========================================================================

   _view_more()

   ==========================================================================

   Description:

   Creates view more markup when given:
<commit_msg>Fix related posts dates<commit_after>{# ==========================================================================

   related_posts.render()

   ==========================================================================

   Description:

   Creates related posts markup when given:

   is_half_width:    A Boolean indicating whether the posts should be at half
                     width. Defaults to False.

   hide_header_slug: A Boolean indicating whether the header should be hidden.
                     Defaults to False.

   ========================================================================== #}

{% macro render(block, is_half_width=false, hide_header_slug=false) %}
    {% import 'macros/category-icon.html' as category_icon %}
    {% set related_post_types = page.related_posts(block, request.site.hostname) %}
    {% if related_post_types %}
        <div class="m-related-posts
                    {{'m-related-posts__half-width'
                      if is_half_width else ''}}">
            {% if not hide_header_slug %}
                <h2 class="header-slug">
                    <span class="header-slug_inner">
                        Related Posts
                    </span>
                </h2>
            {% endif %}
            {% for post_type, post_type_list in related_post_types.iteritems() %}
                {% set title, icon = (post_type, category_icon.render(post_type)) or ("Blog", "cf-icon-speech-bubble") %}
                <div class="m-related-posts_list-container">
                    {% if block.value.show_heading %}
                        <h3 class="h4">
                            {{ icon }} {{ title }}
                        </h3>
                    {% endif %}
                    {{ _related_posts_list(post_type_list, block.value.limit) }}
                </div>
            {% endfor %}
            {% for block in page.sidefoot %}
                {% if 'related_posts' in block.block_type %}
                    {% if block.value.view_more %}
                        {{ _view_more( block.value.view_more ) }}
                    {% endif %}
                {% endif %}
            {% endfor %}
        </div>
    {% endif %}
{% endmacro %}


{# ==========================================================================

   _related_posts_list()

   ==========================================================================

   Description:

   Creates related posts markup when given:

   posts: A list of dictionaries containing related posts.

   ========================================================================== #}

{% macro _related_posts_list(posts, limit) %}
    {% import 'macros/time.html' as time %}
    {% set limit = limit|int if posts|length >= limit|int else posts|length %}
    <ul class="m-related-posts_list
               list list__unstyled
               list__spaced">
        {% for i in range(limit) %}
            {% set post_url = slugurl(posts[i].slug) or '' %}
            <li class="list_item">
                <h3 class="h4 u-mb5">
                    <a class="list_link"
                       href="{{ post_url or posts[i].permalink }}">
                        {{ posts[i].title | safe }}
                    </a>
                </h3>
                {% if posts[i].text %}
                <p>
                    {{ posts[i].text | safe }}
                </p>
                {% endif %}
                <p class="date">
                    {% set date = posts[i].start_dt
                                  or posts[i].date_published
                                  or posts[i].latest_revision_created_at
                                  or posts[i].date %}
                    {{ time.render(date, {'date':true}) }}
                </p>
            </li>
        {% endfor %}
    </ul>

{% endmacro %}

{# ==========================================================================

   _view_more()

   ==========================================================================

   Description:

   Creates view more markup when given:

{'fraction_non_alphanumeric': 0.25122842383772204, 'fraction_numerical': 0.0022678593927176515, 'mean_word_length': 1.776495278069255, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4819317', 'n_tokens_mistral': 2139, 'n_tokens_neox': 1815, 'n_words': 411}