{% extends "base.html" %} {# Author Archive Template Displays all posts/pages by a specific author with stats and bio. Uses query indexes for O(1) author lookups. URL Pattern: /authors/jane-smith/ Required page metadata: - author_name: "Jane Smith" (the author key to look up) Optional metadata: - avatar: "/images/jane.jpg" - bio: "Author bio text" - social: {twitter: "@jane", github: "janesmith"} - section_filter: "blog" (only show posts from specific section) Usage: Create content/authors/jane-smith.md: --- title: "Jane Smith" author_name: "Jane Smith" avatar: "/images/jane.jpg" bio: "Senior developer and technical writer" template: author.html social: twitter: "@janesmith" github: "janesmith" email: "jane@example.com" --- Context variables: - page: Current author page - params.author_name: The author to query - site.indexes.author: Author index #} {% from 'partials/navigation-components.html' import breadcrumbs %} {% from 'partials/components/tags.html' import tag_list %} {% set author_key = params.author_name | default(page.title) %} {% set authors_registry = site?.data?.authors ?? {} %} {% set author_from_registry = authors_registry.get(author_key, {}) if author_key else {} %} {% set author_name = author_from_registry.name | default(author_key) %} {% set author_avatar = author_from_registry.avatar | default(params.avatar) %} {% set author_bio = author_from_registry.bio | default(params.bio) %} {% set author_social = author_from_registry.social | default(params.social) %} {% set section_filter = params.section_filter %} {% block content %} {{ breadcrumbs(page) }}
{% if author_avatar %} {{ author_name }} {% else %}
{{ author_name[0] | upper }}
{% end %}

{{ author_name }}

{% if author_bio %}

{{ author_bio }}

{% end %} {# Social links #} {% if author_social %}
{% set social = author_social %} {% if social.twitter %} {% end %} {% if social.github %} {% end %} {% if social.linkedin %} {% end %} {% if social.website %} {% end %} {% if social.email %} {% end %}
{% end %}
{# O(1) lookup of all posts by this author (index keyed by slug) #} {% set author_posts = site.indexes.author.get(author_key) | resolve_pages %} {# Filter by section if specified #} {% if section_filter %} {% set author_posts = author_posts | selectattr('_section.name', 'equalto', section_filter) | list %} {% end %} {% if author_posts %} {# Statistics Section #}

Author Statistics

{{ author_posts | length }} Post{{ 's' if author_posts | length != 1 }}
{{ author_posts | map(attribute='content') | join('') | wordcount | format_number }} Words
{% set all_tags = author_posts | map(attribute='tags') | flatten | unique | list %}
{{ all_tags | length }} Topic{{ 's' if all_tags | length != 1 }}
{% set years = author_posts | map(attribute='date.year') | select('defined') | unique | sort %} {% if years %}
{{ years | first }} Member Since
{% end %}
{# Main content from markdown #} {% if content %}
{{ content | safe }}
{% end %} {# Posts Section #}

Posts by {{ author_name }}

{# Group toggle: All / By Year / By Category #}
{% if all_tags %} {% end %}
{# All Posts View (default) #}
{% for post in author_posts | sort_by('date', reverse=true) %}

{{ post.title }}

{% if post.metadata.description %}

{{ post.metadata.description }}

{% end %} {% if post.tags %} {% end %}
{% end %}
{# By Year View #} {# By Topic View #} {% if all_tags %} {% end %}
{% else %} {# Empty State #}

No posts found by {{ author_name }}.

{% end %}
{% end %}