From d6640d515d06683c697943a6d03aef160038416c Mon Sep 17 00:00:00 2001 From: Ricardo Date: Fri, 30 Jan 2026 16:51:29 +0100 Subject: [PATCH] refactor: single h-card component with variant support - h-card.njk is now the single source of truth - sidebar.njk includes h-card with variant='full' - blog-sidebar.njk includes h-card with variant='compact' - Removed duplicate h-card code from both sidebars --- _includes/components/blog-sidebar.njk | 24 +--- _includes/components/h-card.njk | 182 ++++++++++++-------------- _includes/components/sidebar.njk | 68 +--------- 3 files changed, 92 insertions(+), 182 deletions(-) diff --git a/_includes/components/blog-sidebar.njk b/_includes/components/blog-sidebar.njk index 3f90f5d..6efa989 100644 --- a/_includes/components/blog-sidebar.njk +++ b/_includes/components/blog-sidebar.njk @@ -1,28 +1,10 @@ {# Blog Sidebar - Shown on individual post pages #} {# Contains: Author compact card, Related posts, Categories, Recent posts #} -{# Author Compact Card - h-card microformat (compact version) #} +{# Author Compact Card - includes h-card component #}
-
- - {{ site.author.name }} - -
- - {{ site.author.name }} - -

{{ site.author.title }}

- {% if site.author.locality %} -

{{ site.author.locality }}{% if site.author.country %}, {{ site.author.country }}{% endif %}

- {% endif %} -
-
- + {% set hcardVariant = "compact" %} + {% include "components/h-card.njk" %}
{# Post Navigation Widget - Previous/Next #} diff --git a/_includes/components/h-card.njk b/_includes/components/h-card.njk index 73fccaf..49ebcca 100644 --- a/_includes/components/h-card.njk +++ b/_includes/components/h-card.njk @@ -1,116 +1,106 @@ -{# h-card - IndieWeb identity microformat #} +{# h-card - Single source of truth for IndieWeb identity microformat #} {# See: https://microformats.org/wiki/h-card #} +{# + Usage: + {% include "components/h-card.njk" %} {# defaults to full #} + {% set hcardVariant = "full" %}{% include "components/h-card.njk" %} + {% set hcardVariant = "compact" %}{% include "components/h-card.njk" %} +#} + +{% set variant = hcardVariant | default("full") %}
- {# Avatar - visible for h-card validation #} - - - {# Name #} - - {{ site.author.name }} - - - {# Pronouns #} - {% if site.author.pronoun %} - ({{ site.author.pronoun }}) - {% endif %} - - {# Job title #} - {% if site.author.title %} - - {{ site.author.title }} - - {% endif %} - + {% if variant == "full" %} + {# ===== FULL VARIANT - Homepage sidebar ===== #} +
+ + {{ site.author.name }} + +
+ + {{ site.author.name }} + + {% if site.author.pronoun %} + ({{ site.author.pronoun }}) + {% endif %} +

{{ site.author.title }}

+ {# Structured address #} +

+ {% if site.author.locality %} + {{ site.author.locality }}{% if site.author.country %}, {% endif %} + {% endif %} + {% if site.author.country %} + {{ site.author.country }} + {% endif %} + {# Fallback to legacy location #} + {% if not site.author.locality and site.author.location %} + {{ site.author.location }} + {% endif %} +

+
+
+ {# Bio #} +

{{ site.author.bio }}

{# Organization #} {% if site.author.org %} - - @ {{ site.author.org }} - - {% endif %} - - {# Bio / Note #} - {% if site.author.bio %} -

- {{ site.author.bio }} +

+ {{ site.author.org }}

{% endif %} - - {# Location - structured address #} -
- {% if site.author.locality %} - {{ site.author.locality }}{% if site.author.region or site.author.country %}, {% endif %} + {# Email and PGP Key #} +
+ {% if site.author.email %} + + {{ site.author.email }} + {% endif %} - {% if site.author.region %} - {{ site.author.region }}{% if site.author.country %}, {% endif %} - {% endif %} - {% if site.author.country %} - {{ site.author.country }} - {% endif %} - {# Fallback to legacy location field if structured fields not set #} - {% if not site.author.locality and not site.author.region and not site.author.country and site.author.location %} - {{ site.author.location }} + {% if site.author.keyUrl %} + + PGP Key + {% endif %}
- - {# Email #} - {% if site.author.email %} - - {{ site.author.email }} - - {% endif %} - - {# PGP Key #} - {% if site.author.keyUrl %} - - 🔐 PGP Key - - {% endif %} - {# Categories / Skills #} {% if site.author.categories and site.author.categories.length %} -
+
{% for category in site.author.categories %} {{ category }} {% endfor %}
{% endif %} - {# Social links with rel="me" #} - +
+ + {{ site.author.name }} + +

{{ site.author.title }}

+ {% if site.author.locality %} +

+ {{ site.author.locality }}{% if site.author.country %}, {{ site.author.country }}{% endif %} +

+ {% endif %} +
+
+ {# Hidden but present for microformat completeness #} + + {% if site.author.email %}{% endif %} + {% if site.author.org %}{% endif %} + {% endif %}
diff --git a/_includes/components/sidebar.njk b/_includes/components/sidebar.njk index f0818b2..ff8b65b 100644 --- a/_includes/components/sidebar.njk +++ b/_includes/components/sidebar.njk @@ -1,72 +1,10 @@ {# Sidebar Components #} {# Contains: Author card, Bluesky feed, GitHub repos, RSS feed #} -{# Author Card Widget - Full h-card microformat #} +{# Author Card Widget - includes h-card component #}
-
-
- - {{ site.author.name }} - -
- - {{ site.author.name }} - - {% if site.author.pronoun %} - ({{ site.author.pronoun }}) - {% endif %} -

{{ site.author.title }}

- {# Structured address #} -

- {% if site.author.locality %} - {{ site.author.locality }}{% if site.author.country %}, {% endif %} - {% endif %} - {% if site.author.country %} - {{ site.author.country }} - {% endif %} - {# Fallback to legacy location #} - {% if not site.author.locality and site.author.location %} - {{ site.author.location }} - {% endif %} -

-
-
- {# Bio #} -

{{ site.author.bio }}

- {# Organization #} - {% if site.author.org %} -

- {{ site.author.org }} -

- {% endif %} - {# Email and PGP Key #} -
- {% if site.author.email %} - - ✉️ {{ site.author.email }} - - {% endif %} - {% if site.author.keyUrl %} - - 🔐 PGP Key - - {% endif %} -
- {# Categories / Skills #} - {% if site.author.categories and site.author.categories.length %} -
- {% for category in site.author.categories %} - {{ category }} - {% endfor %} -
- {% endif %} -
+ {% set hcardVariant = "full" %} + {% include "components/h-card.njk" %}
{# Social Feed Widget - Tabbed Bluesky/Mastodon #}