Skip to content

Latest commit

 

History

History
89 lines (78 loc) · 2.8 KB

doc-date-sorted.md

File metadata and controls

89 lines (78 loc) · 2.8 KB
layout
default

{%- assign this_name = page.name | split: "." -%} {%- assign this_category = this_name[0] | replace: '-date-sorted', '' -%} {%- assign this_pagetitle = this_category | capitalize | replace: '_', ' ' -%}

{{ this_pagetitle }}

{%- comment -%}

  • collecting the pages {%- endcomment -%}

{%- assign cat_posts = site.emptyArray -%} {%- for post in site.documents -%} {%- if post.categories contains this_category -%} {%- assign cat_posts = cat_posts | push: post -%} {%- endif -%} {%- endfor -%}

{%- assign cat_posts = cat_posts | sort: 'date' | reverse -%}

{%- comment -%}

  • special posts for prepending content to the listing pages
  • they are processed first, so separate loops are needed
    {%- endcomment -%}

{%- for post in cat_posts -%} {%- if post.tags contains '.prepend' -%}

{{ post.content | markdownify }}
{%- endif -%} {%- endfor -%}

{%- comment -%}

  • no separate treatment of featured posts {%- endcomment -%}

{%- assign today = site.time | date: '%Y%m%d' -%} {%- assign page_tag = this_category | downcase -%}

{%- for post in cat_posts -%} {% unless post.tags contains '.prepend' or post.tags contains '.append' %} {%- assign post_author = post.author | downcase -%} {%- assign excerpt_link = post.url | relative_url -%} {%- if post.excerpt_link contains '/' -%} {%- assign excerpt_link = post.excerpt_link -%} {%- endif -%} {%- assign post_day = post.date | date: '%Y%m%d' -%} {%- assign post_year = post.date | date: '%Y' -%} {%- if post_day > today -%} {%- assign post_year = 'Upcoming' -%} {%- endif %} {%- if current_year != post_year -%} {% assign current_year = post_year %}

{{ current_year }}

{% endif %}
{%- if post_day > today -%}

{{ post.date | date: "%Y-%m-%d" }}

{%- endif -%} {{ post.excerpt }}

{%- if post.author -%}{{ post.author | join: " | " }} {%- endif -%} {%- if post.date -%}{{ post.date | date: "%Y-%m-%d" }}: {% endif %} more ...

{% endunless %} {%- endfor -%}

{%- for post in cat_posts -%} {%- if post.tags contains '.append' -%}

{{ post.content | markdownify }}
{%- endif -%} {%- endfor -%}