{% extends "base.html" %} {# ================================================================================ Author List Template (Kida-Native) ================================================================================ Displays all authors with their profiles and post counts. KIDA FEATURES USED: - {% let %} for template-scoped variables - Optional chaining (?.) for null-safe access - Null coalescing (??) for smart defaults - {% def %} for reusable card component - Pipeline operator (|>) for filter chains URL Pattern: /authors/ Context variables: - page: Current list page (_index.md) - site.data.authors: Author registry (from data/authors.yaml) - site.indexes.author: Author index for post counts ================================================================================ #} {% from 'partials/navigation-components.html' import breadcrumbs %} {# ============================================================================= AUTHOR CARD COMPONENT ============================================================================= #} {% def author_card(author) %} {% let author_name = author?.name ?? 'Unknown Author' %} {% let author_href = author?.href ?? '#' %} {% let author_avatar = author?.avatar ?? '' %} {% let author_company = author?.company ?? '' %} {% let author_location = author?.location ?? '' %} {% let author_bio = author?.bio ?? '' %} {% let author_github = author?.github ?? '' %} {% let post_count = author?.post_count ?? 0 %}
{% if author_avatar %} {{ author_name }} {% else %}
{{ author_name[0] | upper }}
{% end %}

{{ author_name }}

{% if author_company or author_location %}

{% if author_company %}{{ author_company }}{% end %} {% if author_company and author_location %} ยท {% end %} {% if author_location %}{{ author_location }}{% end %}

{% end %} {% if author_bio %}

{{ author_bio | truncate(120) }}

{% end %}
{{ post_count }} post{{ 's' if post_count != 1 else '' }} {% if author_github %} {{ author_github }} {% end %}
{% end %} {# ============================================================================= MAIN TEMPLATE ============================================================================= #} {% block content %} {# Template-scoped variables #} {% let page_title = page?.title ?? 'Authors' %} {% let page_desc = page?.description ?? '' %} {% let authors_data = site?.data?.authors ?? {} %} {% let author_index = site?.indexes?.author ?? {} %} {% let page_children = page?.children ?? [] %} {% let home_url = '/' | absolute_url %} {{ breadcrumbs(page) }}
{# Main content from markdown #} {% if content %}
{{ content | safe }}
{% end %} {# Build author list from data registry and/or child pages #} {% let authors_list = [] %} {# Add authors from data/authors.yaml #} {% for author_key, author_data in authors_data | items %} {% let author_posts = author_index.get(author_key) ?? [] %} {% let post_count = author_posts | length %} {% let _name = author_data?.name ?? author_key %} {% set _ = authors_list.append({ 'key': author_key, 'name': _name, 'bio': author_data?.bio ?? '', 'avatar': author_data?.avatar ?? '', 'company': author_data?.company ?? '', 'location': author_data?.location ?? '', 'github': author_data?.github ?? '', 'post_count': post_count, 'href': '/authors/' ~ author_key ~ '/' }) %} {% end %} {# Add authors from child pages (if not already in registry) #} {% for child in page_children %} {% let child_title = child?.title ?? 'unknown' %} {% let author_key = child?.params?.author_name ?? child_title %} {% let existing = authors_list |> selectattr('key', 'eq', author_key) |> list %} {% if existing | length == 0 %} {% let author_posts = author_index.get(author_key) ?? [] %} {% let post_count = author_posts | length %} {% let child_params = child?.params ?? {} %} {% let child_social = child_params?.social ?? {} %} {% set _ = authors_list.append({ 'key': author_key, 'name': child_title, 'bio': child_params?.bio ?? '', 'avatar': child_params?.avatar ?? '', 'company': child_params?.company ?? '', 'location': child_params?.location ?? '', 'github': child_social?.github ?? '', 'post_count': post_count, 'href': child?.href ?? '#' }) %} {% end %} {% end %} {% if authors_list | length > 0 %}
{% for author in authors_list | sort(attribute='name') %} {{ author_card(author) }} {% end %}
{% else %} {% from "partials/empty-state.html" import empty_state %} {{ empty_state( title="No authors found", message="Add authors to data/authors.yaml or create pages in content/authors/.", icon_name="users", actions=[{'href': home_url, 'label': 'Go Home', 'icon': 'house'}] ) }} {% end %}
{% end %}