Files
indiekit-blog/_includes/components/sections/recent-posts.njk
Ricardo d9e99fa9cc feat: add homepage builder components for Phase 3
- homepage-builder.njk: master section renderer for configured sections
- sections/hero.njk: hero section with avatar, name, title, bio, social
- sections/recent-posts.njk: configurable recent posts section
- sections/custom-html.njk: freeform HTML content block
- Wire home.njk Tier 1 to include homepage-builder when config exists

Part of indiekit-endpoint-homepage plugin integration.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-08 15:55:08 +01:00

55 lines
2.2 KiB
Plaintext

{#
Recent Posts Section - displays latest posts from any collection
Rendered by homepage-builder when recent-posts section is configured
#}
{% set sectionConfig = section.config or {} %}
{% set maxItems = sectionConfig.maxItems or 5 %}
{% set showSummary = sectionConfig.showSummary if sectionConfig.showSummary is defined else true %}
{% if collections.posts and collections.posts.length %}
<section class="mb-8 sm:mb-12">
<h2 class="text-xl sm:text-2xl font-bold text-surface-900 dark:text-surface-100 mb-4 sm:mb-6">
{{ sectionConfig.title or "Recent Posts" }}
</h2>
<div class="space-y-4">
{% for post in collections.posts | head(maxItems) %}
<article class="p-4 bg-white dark:bg-surface-800 rounded-lg border border-surface-200 dark:border-surface-700 hover:border-primary-400 dark:hover:border-primary-600 transition-colors">
<h3 class="font-semibold text-surface-900 dark:text-surface-100 mb-1">
<a href="{{ post.url }}" class="hover:text-primary-600 dark:hover:text-primary-400">
{{ post.data.title or post.data.name or "Untitled" }}
</a>
</h3>
{% if showSummary and post.data.summary %}
<p class="text-sm text-surface-600 dark:text-surface-400 mb-2 line-clamp-2">
{{ post.data.summary }}
</p>
{% endif %}
<div class="flex items-center gap-3 text-xs text-surface-500">
<time datetime="{{ post.data.published or post.date }}">
{{ (post.data.published or post.date) | date("MMM d, yyyy") }}
</time>
{% if post.data.postType %}
<span class="px-2 py-0.5 bg-surface-100 dark:bg-surface-700 rounded">
{{ post.data.postType }}
</span>
{% endif %}
</div>
</article>
{% endfor %}
</div>
{% if sectionConfig.showViewAll != false %}
<a href="{{ sectionConfig.viewAllUrl or '/blog/' }}" class="text-sm text-primary-600 dark:text-primary-400 hover:underline mt-4 inline-flex items-center gap-1">
{{ sectionConfig.viewAllText or "View all posts" }}
<svg class="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"/>
</svg>
</a>
{% endif %}
</section>
{% endif %}