{% spaceless %}
{% match post_count %}
{% case 1 %}1 page
{% case n %}{{ n }} pages
{% end %}
{% end %}
{# Category stats #}
{{ total_words |> format_number }} words
{% if authors | length > 0 %}
{% spaceless %}
{% match authors | length %}
{% case 1 %}1 author
{% case n %}{{ n }} authors
{% end %}
{% end %}
{% end %}
{# Recent posts in this category #}
{% if show_recent > 0 and recent_posts | length > 0 %}
{% end %}
{% end %}
{% end %}
{# Letter group for A-Z index - uses caching for expensive lookups #}
{% def letter_group(letter, categories, section_filters) %}
{{ letter }}
{% for cat in categories %}
{% let raw_posts = site.indexes.category.get(cat) |> resolve_pages %}
{% let cat_posts = raw_posts |> selectattr('_section.name', 'in', section_filters) |> list if section_filters | length > 0 else raw_posts %}
{% if cat_posts | length > 0 %}
{% end %}
{# =============================================================================
MAIN TEMPLATE
============================================================================= #}
{% block content %}
{{ breadcrumbs(page) }}
{{ page?.title ?? 'Browse by Category' }}
{% with params?.description as desc %}
{{ desc }}
{% end %}
{# Main content from markdown #}
{% with content as page_content %}
{{ page_content | safe }}
{% end %}
{% if all_categories | length > 0 %}
{# =========================================================================
SUMMARY STATS - Cached for expensive computation
========================================================================= #}
{% cache 'category-browser-stats-' ~ (section_filters |> join('-')) %}
{% let total_pages = all_categories |> map('site.indexes.category.get') |> map('resolve_pages') |> map('length') |> sum ?? 0 %}
{% spaceless %}
{{ all_categories | length }}
{% match all_categories | length %}
{% case 1 %}category
{% case _ %}categories
{% end %}
{% end %}
{{ total_pages }} total pages
{% end %}
{# =========================================================================
LAYOUT TOGGLE - Pattern matched for active state
========================================================================= #}
{% for layout_option in ['grid', 'list'] %}
{% let is_active = layout == layout_option %}
{% let label = 'Grid view' if layout_option == 'grid' else 'List view' %}
{% let emoji = '' %}
{% end %}
{# =========================================================================
CATEGORY GRID/LIST - Main content area
========================================================================= #}
{% for category in all_categories %}
{{ category_card(category, section_filters, show_recent) }}
{% end %}
{# =========================================================================
ALPHABETICAL INDEX - Grouped by first letter
========================================================================= #}
{% cache 'category-browser-index-' ~ (section_filters |> join('-')) %}
{% end %}
{% else %}
{# =========================================================================
EMPTY STATE
========================================================================= #}
No categories found.
Add categories: ["tutorial", "guide"] to page frontmatter to create categories.