{% comment %} # ----------------------------------------------------------------------------- # ~/_includes/themes/j1/procedures/posts/collate_simple.proc # Liquid PROCEDURE to collate posts as a simple list ordered # by year and month. # # http://jekyll.one # # Copyright (C) 2023, 2024 Juergen Adams # # J1 Template is licensed under the MIT License. # See: https://github.com/jekyll-one-org/j1-template/blob/main/LICENSE # # ----------------------------------------------------------------------------- # NOTE: # # Collate posts procedure. Collate posts as a simple list ordered # by year and month. # # Usage: # # 1) assign the 'posts_collate' variable to a valid array of posts # 2) include the 'collate_simple' procedure # # Example: # # {% assign posts_collate = site.posts %} # {% include themes/{{site.template.name}}/procedures/posts/collate_simple.proc items=posts_collate %} # # Ordering: # Posts are displayed in reverse chronological order. # For normal chronological order: # # 1) Change the for loop to this: # => 'for post in posts_collate reversed' # 2) Next make sure to change 'post.previous.date' to: # => 'post.next.date' # # ----------------------------------------------------------------------------- # Test data: # liquid_var: {{ liquid_var | debug }} # # ----------------------------------------------------------------------------- {% endcomment %} {% comment %} Variables ----------------------------------------------------------------------------- {% endcomment %} {% assign posts_collate = include.items %} {% comment %} Liquid procedures ----------------------------------------------------------------------------- {% endcomment % {% comment %} Main ----------------------------------------------------------------------------- {% endcomment %} {% if site.data.j1_config.posts_collate.provider == 'custom' %} {% include themes/{{site.template.name}}/procedures/custom/collate_simple %} {% else %} {% for post in posts_collate %} {% capture this_year %}{{ post.date | date: "%Y" }}{% endcapture %} {% capture this_month %}{{ post.date | date: "%B" }}{% endcapture %} {% capture next_year %}{{ post.previous.date | date: "%Y" }}{% endcapture %} {% capture next_month %}{{ post.previous.date | date: "%B" }}{% endcapture %} {% if forloop.first %}

{{this_year}}

{{this_month}}

{% else %} {% if this_year != next_year %}

{{next_year}}

{{next_month}}

{{next_month}}