--- title: Categories date: 2020-01-03 01:23:45 -0800 permalink: /categories/ # trailing slash makes it an `index.html` file inside the `/categories/` directory, rather than a `categories.html` file in the root # dependencies: # site.show.authors sitewide switch to show authors or not # site.projects to show categorized projects # site.pages to show categorized pages --- {%-if site.plugins contains 'jekyll-archives'-%}{%-assign archives_available = true-%}{%-else-%}{%-assign archives_available = false-%}{%-endif-%} {%-assign sorted_categories = site.categories | sort %} {%-assign published_projects = site.projects | where: 'published', true-%} {%-assign published_pages = site.pages | where: 'published', true-%} {%-assign project_categories = published_projects | map: 'categories' | join: '-----' | split: '-----' | uniq-%} {%-assign page_categories = published_pages | map: 'categories' | join: '-----' | split: '-----' | uniq-%} {%-assign merged_categories = project_categories | concat: page_categories | uniq | sort-%}

These are the categories used on {{-site.title-}}  (number of   posts{%-if published_projects != empty or published_pages != empty %} /   projects{%-if published_pages != empty %} /   pages{%-endif-%}{%-endif-%}).

{% for category in sorted_categories-%} {%-assign projects = published_projects | where_exp: 'project', "project.categories contains category.first"-%} {%-assign pages = published_pages | where_exp: 'page', "page.categories contains category.first"-%}

{% if archives_available-%} {{-category | first | capitalize-}} {%-else-%} {{-category | first | capitalize-}} {%-endif %}  ({{-category | last | size }}{%-if projects != empty or pages != empty %} / {{ projects | size }} / {{ pages | size-}}{%-endif-%})

    {%-for post in category.last %} {% include list_item.html-%} {%-endfor %} {% if projects != empty-%} {%-for project in projects %} {% include list_item.html li_class="project" title_template="Check out ':item_title'"-%} {%-endfor %} {%-endif %} {%-if pages != empty %} {%-for pg in pages %} {% include list_item.html li_class="page" title_template="Check out ':item_title'"-%} {%-endfor %} {%-endif %}
{% endfor-%} {% if project_categories != empty-%}

  Project-specific

{% if site.show.alt_archive_links-%} {%-else-%} {% for category in project_categories-%} {% if site.categories contains category-%}{%-continue-%}{%-endif-%} {%-assign projects = published_projects | where_exp: 'project', "project.categories contains category" %}

{{-category | capitalize-}}

    {%-for project in projects %} {% include list_item.html title_template="Check out ':item_title'"-%} {%-endfor %}
{%-endfor %} {% endif-%} {%-endif %} {% if page_categories != empty-%}

  Page-specific

{% if site.show.alt_archive_links-%} {%-else-%} {% for category in page_categories-%} {% if site.categories contains category-%}{%-continue-%}{%-endif-%} {%-assign pages = published_pages | where_exp: 'page', "page.categories contains category" %}

{{-category | capitalize-}}

    {%-for pg in pages %} {% include list_item.html title_template="Check out ':item_title'"-%} {%-endfor %}
{%-endfor %} {% endif-%} {%-endif %}