Skip to content

Commit f9b7008

Browse files
committed
Merge #107: order articles in homepage by latest
2dfe91b order articles in homepage by latest (Graeme Byrne) Pull request description: * [Latest articles in homepage are not ordered #105](#105), * Fix links to articles in `Related Posts` under each blog post. ACKs for top commit: josecelano: ACK 2dfe91b Tree-SHA512: 3c65465eba531cf1af600ba5583265b7104883d0eb0bda9bbb28dc8429c6f69bc959501d36fa9f0213c91c2977b71578e8abfaa421b16286ef8d80d5bbea899d
2 parents cead851 + 2dfe91b commit f9b7008

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/routes/(home)/+page.server.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ import { fetchMarkdownPosts } from '$lib/utils/index_posts';
33

44
export async function load() {
55
const allPosts = await fetchMarkdownPosts();
6-
const posts = allPosts.slice(0, 6);
6+
7+
const posts = allPosts
8+
.sort((a, b) => new Date(b.meta.date).getTime() - new Date(a.meta.date).getTime())
9+
.slice(0, 6);
710

811
return {
912
features,

src/routes/blog/[slug]/+page.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@
5656
<h2>Related Posts:</h2>
5757
<div class="grid">
5858
{#each data.posts.slice(0, 3) as post}
59-
<BlogPreview post_data={post.meta} />
59+
<a href={post.path}>
60+
<BlogPreview post_data={post.meta} />
61+
</a>
6062
{/each}
6163
</div>
6264
</div>

0 commit comments

Comments
 (0)