fix post order

This commit is contained in:
Raven Scott
2024-09-25 23:05:49 -04:00
parent c0d530be27
commit 0f561b0353
2 changed files with 24 additions and 15 deletions

View File

@ -37,22 +37,30 @@
<p class="lead">Where Technology Meets Creativity: Insights from a Linux Enthusiast</p>
</div>
</header>
<section class="py-5">
<div class="container">
<h2>Recent Posts</h2>
<ul class="list-group list-group-flush">
<% blogPosts.sort((a, b) => new Date(b.date) - new Date(a.date)).forEach(post => { %>
<% blogPosts.forEach(post => { %>
<li class="list-group-item d-flex justify-content-between align-items-center py-4">
<div>
<h5 class="mb-1"><a href="/blog/<%= post.slug %>"> <%= post.title %> </a></h5>
<p class="mb-1 text-muted">Posted on <%= post.date %></p>
<p class="mb-1 text-muted">Posted on
<%= new Date(post.dateCreated).toLocaleDateString('en-US', {
year: 'numeric',
month: 'long',
day: 'numeric'
}) %>
</p>
</div>
<a href="/blog/<%= post.slug %>" class="btn btn-outline-primary">Read Article</a>
</li>
<% }) %>
</ul>
</div>
</section>
<!-- Pagination controls -->
<nav aria-label="Page navigation">
<ul class="pagination justify-content-center mt-4">