--- title: Post Archive date: 2020-01-04 01:23:45 -0800 permalink: /archives/ # trailing slash makes it an `index.html` file inside the `/archives/` directory, rather than an `archives.html` file in the root excerpt: "" # NOTE: this empty excerpt fixes liquid "'if' tag was never closed included" error: https://jekyllrb.com/docs/troubleshooting/#excerpts # dependencies: # site.plugins to test whether jekyll-archives is activated or not # site.url used in the header message # site.title used in the header message # site.archives_root the root path of the archives (e.g., '', '/posts', '/blog', '/archives', etc.) to build url links # site.posts posts for the archive # site.jekyll-archives.enabled - array for the type(s) of archives desired: [day, month, year] # local: # firsts, seconds, thirds - arrays for ordinalizing days in dates # NOTE: ordinalization inspired by http://alanwsmith.com/jekyll-liquid-date-formatting-examples # TODO: add other collections (_projects, _pages) to the archives --- {%-assign archived = site.jekyll-archives.enabled-%} {%-if site.plugins contains 'jekyll-archives'-%}{%-assign archives_available = true-%}{%-else-%}{%-assign archives_available = false-%}{%-endif-%} {%-if archived contains 'year'-%}{%-unless archived contains 'month'-%}{%-unless archived contains 'day'-%}{%-assign is_year_archive = true-%}{%-endunless-%}{%-endunless-%}{%-endif-%} {%-if site.posts-%} {%-assign archives_root = site.archives_root | default: ''-%} {%-assign posts_by_year = site.posts | group_by_exp: 'post', "post.date | date: '%Y'"-%} {%-comment-%} {%-assign published_projects = site.projects | where: 'published', true-%} {%-assign published_pages = site.pages | where: 'published', true-%} {%-assign projects_by_year = published_projects | group_by_exp: 'project',"project.date | date: '%Y'"-%} {%-assign pages_by_year = published_pages | group_by_exp: 'pg', "pg.date | date: '%Y'"-%} {%-endcomment-%} {%-assign firsts = "1,21,31" | split: ','-%} {%-assign seconds = "2,22" | split: ','-%} {%-assign thirds = "3,23" | split: ','-%}

This is the archive of posts for {{-site.title-}}  (number of   posts{%-comment-%}{%-if published_projects or published_pages %} /   projects{%-if published_pages %} /   pages{%-endif-%}{%-endif-%}{%-endcomment-%}).

{%-if archived contains 'year' or archived contains 'month' or archived contains 'day'-%} {%-for year in posts_by_year %} {%-assign year_url = site.jekyll-archives.permalinks.year | replace: ':year', year.name-%} {%-comment-%} {%-assign year_projects = projects_by_year | find: 'name', year.name-%} {%-assign year_pages = pages_by_year | find: 'name', year.name-%} {%-endcomment-%} {% if archives_available and archived contains 'year'-%} {{-year.name-}} {%-else-%} {{-year.name-}} {%-endif %} {%-if year.items.size > 3 %}  ({{-year.items | size }}{%-comment-%}{%-if year_projects.items or year_pages.items %} / {{ year_projects.items | size }} / {{ year_pages.items | size-}}{%-endif-%}{%-endcomment-%}){% endif-%} {%-if archived contains 'month' or archived contains 'day'-%} {%-assign posts_by_month = year.items | sort: 'date' | group_by_exp: "post", "post.date | date: '%B'"-%} {%-comment-%} {%-assign projects_by_month = year_projects.items | sort: 'date' | group_by_exp: "project", "project.date | date: '%B'"-%} {%-assign pages_by_month = year_pages.items | sort: 'date' | group_by_exp: "pg", "pg.date | date: '%B'"-%} {%-endcomment-%} {%-for month in posts_by_month %} {%-assign month_name = month.name | date: '%m'-%} {%-assign month_url = site.jekyll-archives.permalinks.month | replace: ':year', year.name | replace: ':month', month_name-%} {%-comment-%} {%-assign month_projects = projects_by_month | find: 'name', month.name-%} {%-assign month_pages = pages_by_month | find: 'name', month.name-%} {%-endcomment-%}

{% if archives_available and archived contains 'month'-%} {{-month.name }} {{ year.name-}} {%-else-%} {{-month.name }} {{ year.name-}} {%-endif %} {%-if month.items.size > 3 %}  ({{-month.items | size }}{%-comment-%}{%-if month_projects.items or month_pages.items %} / {{ month_projects.items | size }} / {{ month_pages.items | size-}}{%-endif-%}{%-endcomment-%}){% endif-%}

{%-if archived contains 'day'-%} {%-assign posts_by_day = month.items | sort: 'date' | group_by_exp: "post", "post.date | date: '%-d'"-%} {%-for day in posts_by_day %} {%-if firsts contains day.name-%}{%-assign suffix='st'-%}{%-elsif seconds contains day.name-%}{%-assign suffix='nd'-%}{%-elsif thirds contains day.name-%}{%-assign suffix='rd'-%}{%-else-%}{%-assign suffix='th'-%}{%-endif-%} {%-assign day_name = day.name | plus: 0-%} {%-capture day_url-%}{{-month_url-}}/{%-if day_name < 10-%}0{%-endif-%}{{-day.name-}}{%-endcapture-%}

{{-month.name | date: '%b' }} {{ day.name-}}, {{ year.name }} {%-if day.items.size > 3 %}  ({{-day.items | size }}{%-comment-%}{%-if day_projects.items or day_pages.items %} / {{ day_projects.items | size }} / {{ day_pages.items | size-}}{%-endif-%}{%-endcomment-%}){% endif-%}

{%-endfor %} {%-else %}
    {%-for post in month.items %} {% include list_item.html-%} {%-endfor %} {%-comment-%} {%-for project in month_projects.items %} {% include list_item.html li_class="project"-%} {%-endfor %} {%-for pg in month_pages.items %} {% include list_item.html li_class="page"-%} {%-endfor %} {%-endcomment-%}
{%-endif %} {%-endfor %} {%-else %}
    {%-for post in year.items %} {% include list_item.html-%} {%-endfor %} {%-comment-%} {%-for project in year_projects.items %} {% include list_item.html li_class="project"-%} {%-endfor %} {%-for pg in year_pages.items %} {% include list_item.html li_class="page"-%} {%-endfor %} {%-endcomment-%}
{%-endif %} {%-comment-%}
    {%-for project in year_projects.items %} {% include list_item.html li_class="project"-%} - {{ project.date }} {%-endfor %}
    {%-for pg in year_pages.items %} {% include list_item.html li_class="page"-%} - {{ pg.date }} {%-endfor %}
{%-endcomment-%} {%-endfor %} {%-endif %} {%-endif %}