feat: update interests templates for category-based data model

Interests are now grouped by category (matching skills pattern).
Updated cv-interests.njk to iterate categories, cv.js fallback to {},
and cv.njk hasCvData check to include interests.
This commit is contained in:
Ricardo
2026-02-25 14:56:11 +01:00
parent 116ac63f5f
commit ab31e080bb
3 changed files with 20 additions and 11 deletions

View File

@@ -30,7 +30,7 @@ export default function () {
skillTypes: {}, skillTypes: {},
languages: [], languages: [],
education: [], education: [],
interests: [], interests: {},
interestTypes: {}, interestTypes: {},
}; };
} }

View File

@@ -1,21 +1,29 @@
{# {#
CV Interests Section - interest tags CV Interests Section - interests grouped by category
Data fetched from /cv/data.json via homepage plugin Data fetched from /cv/data.json via homepage plugin
#} #}
{% if cv and cv.interests and cv.interests.length %} {% if cv and cv.interests and (cv.interests | dictsort | length) %}
<section class="mb-8 sm:mb-12" id="interests"> <section class="mb-8 sm:mb-12" id="interests">
<h2 class="text-xl sm:text-2xl font-bold text-surface-900 dark:text-surface-100 mb-4 sm:mb-6"> <h2 class="text-xl sm:text-2xl font-bold text-surface-900 dark:text-surface-100 mb-4 sm:mb-6">
{{ section.config.title or "Interests" }} {{ section.config.title or "Interests" }}
</h2> </h2>
{% set hasTypeData = cv.interestTypes and (cv.interestTypes | dictsort | length > 0) %} <div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
<div class="flex flex-wrap gap-2"> {% for category, items in cv.interests | dictsort %}
{% for interest in cv.interests %} {% if not filterType or (cv.interestTypes and cv.interestTypes[category] == filterType) or not cv.interestTypes or not cv.interestTypes[category] %}
{% if not filterType or (hasTypeData and cv.interestTypes[interest] == filterType) or not hasTypeData %} <div class="p-4 bg-white dark:bg-surface-800 rounded-lg border border-surface-200 dark:border-surface-700">
<span class="px-3 py-1.5 bg-white dark:bg-surface-800 border border-surface-200 dark:border-surface-700 rounded-full text-sm text-surface-700 dark:text-surface-300 hover:border-primary-400 dark:hover:border-primary-600 transition-colors"> <h3 class="font-semibold text-sm uppercase tracking-wide text-surface-600 dark:text-surface-400 mb-2">
{{ category }}
</h3>
<div class="flex flex-wrap gap-1.5">
{% for interest in items %}
<span class="text-xs px-2 py-1 bg-primary-50 dark:bg-primary-900/30 text-primary-700 dark:text-primary-300 rounded-full">
{{ interest }} {{ interest }}
</span> </span>
{% endfor %}
</div>
</div>
{% endif %} {% endif %}
{% endfor %} {% endfor %}
</div> </div>

3
cv.njk
View File

@@ -10,7 +10,8 @@ pagefindIgnore: true
{% set hasCvData = (cv.experience and cv.experience.length) or {% set hasCvData = (cv.experience and cv.experience.length) or
(cv.projects and cv.projects.length) or (cv.projects and cv.projects.length) or
(cv.skills and ((cv.skills or {}) | dictsort | length)) %} (cv.skills and ((cv.skills or {}) | dictsort | length)) or
(cv.interests and ((cv.interests or {}) | dictsort | length)) %}
{% if hasCvData %} {% if hasCvData %}