{% extends "base.html" %} {% from "chirpui/avatar.html" import avatar %} {% from "chirpui/layout.html" import container, stack %} {% from "chirpui/profile_header.html" import profile_header %} {% from "chirpui/rendered_content.html" import rendered_content %} {% from "partials/taxonomy-pages.html" import count_label, social_links, taxonomy_post_feed %} {% block content %} {% let author_key = params?.author_name ?? page?.author_name ?? page?.slug ?? page?.title ?? "Author" %} {# Bengal's site.data returns "" (empty str) for missing data files, which is non-none so ?? {} won't replace it. Only treat it as a registry when it is a mapping (has a callable .get), otherwise fall back to an empty dict. #} {% let authors_raw = site?.data?.authors %} {% let authors_registry = authors_raw if authors_raw is mapping else {} %} {% let author_data = authors_registry.get(author_key, {}) if author_key else {} %} {% let author_name = author_data?.name ?? page?.title ?? author_key %} {% let author_bio = author_data?.bio ?? params?.bio ?? page?.description ?? none %} {% let author_social = author_data?.social ?? params?.social ?? {} %} {% let author_index_raw = site?.indexes?.author %} {% let author_index = author_index_raw if author_index_raw is mapping else {} %} {# Feed the author's real authored content by matching `metadata.author` across site.pages (the same proven pattern tracks/list.html uses for track_id). `author` is not a registered taxonomy here, so site.indexes.author is empty; and the page-context `posts` resolves to the profile page itself (a self-referential card + misleading count). Exclude the profile page and the author section index. #} {% let author_posts = [] %} {% for p in (site?.pages ?? []) %} {% if (p?.metadata?.author ?? none) == author_key and (p?.href ?? '') != (page?.href ?? '') %} {% set _ = author_posts.append(p) %} {% end %} {% end %} {# Initials for the avatar: first letter of the first two name words. #} {% let _name_words = (author_name | string).split(" ") %} {% let _initials = ((_name_words[0][0] if (_name_words and _name_words[0]) else "") ~ (_name_words[1][0] if (_name_words | length > 1 and _name_words[1]) else "")) | upper %}
{{ author_bio }}
{% end %} {% end %} {% slot stats %} {{ count_label(author_posts | length, "published page") }} {% end %} {% slot actions %} {{ social_links(author_social) }} {% end %} {% end %} {% if content %} {% call rendered_content(compact=true, cls="chirp-theme-learning-content") %}{{ content | safe }}{% end %} {% end %} {{ taxonomy_post_feed(author_posts, "No content has been published by this author yet.", variant="compact") }} {% end %} {% end %}