feat: Added featured post
All checks were successful
Deploy Blog to Folder / deploy (push) Successful in 4s

This commit is contained in:
2025-08-23 13:39:09 -04:00
parent c25f32592b
commit 509b398b6d
3 changed files with 24 additions and 5 deletions

View File

@ -7,4 +7,9 @@ export default function(eleventyConfig) {
return array[0];
});
eleventyConfig.addFilter("firstWords", function (content, numWords = 100) {
if (!content) return "";
return content.split(/\s+/).slice(0, numWords).join(" ");
});
};

View File

@ -35,15 +35,17 @@ css: home.css
</div>
<div>
<div class="container featured">
{% assign latestPost = collections.posts | last %}
<h1>Featured Posts</h1>
<div>
<div>
<img src="https://dummyimage.com/1280x720/fff/aaa" alt="Featured Post Image" />
<img class="featured-image" src="{{ latestPost.data.thumbnail }}" alt="{{ latestPost.data.title }}" />
</div>
<div>
<h2>Latest Post Title Goes Here</h2>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Alias nisi dolorem velit facere ea? Fugit dolor libero dolorem laborum sapiente labore quidem eos, ratione deleniti. Hic sunt ea aspernatur iusto!</p>
<a href="#">Read more...</a>
<div class="featured-text">
<h2>{{ latestPost.data.title }}</h2>
<span>{{ latestPost.data.date | date: "%B %-d, %Y" }}</span>
<p>{{ latestPost.templateContent | strip_html | firstWords: 25 }}</p>
<a href="{{ latestPost.url }}">Read more...</a>
</div>
</div>
</div>