Skip to content

Commit ce1ba82

Browse files
authored
pin announcement blog post (#681)
1 parent 1d2e52d commit ce1ba82

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

apps/svelte.dev/content/blog/2024-10-22-svelte-5-is-alive.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ title: Svelte 5 is alive
33
description: Our biggest release yet
44
author: The Svelte team
55
authorURL: https://svelte.dev/
6+
pinnedUntil: 2024-11-15
67
---
78

89
After almost 18 months of development, comprising thousands of commits from dozens of contributors, Svelte 5 is finally stable.

apps/svelte.dev/src/lib/server/content.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ function format_date(date: string) {
2424
return `${months[+m - 1]} ${+d} ${y}`;
2525
}
2626

27+
const now = new Date();
28+
const today = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')}`;
29+
2730
export const blog_posts = index.blog.children
2831
.map((post) => {
2932
const authors: Array<{ name: string; url: string }> = [];
@@ -45,10 +48,17 @@ export const blog_posts = index.blog.children
4548
...post,
4649
date,
4750
date_formatted: format_date(date),
48-
authors
51+
authors,
52+
pinned: post.metadata.pinnedUntil ? post.metadata.pinnedUntil > today : false
4953
};
5054
})
51-
.sort((a, b) => (a.date < b.date ? 1 : -1));
55+
.sort((a, b) => {
56+
if (!!a.pinned !== !!b.pinned) {
57+
return a.pinned ? -1 : 1;
58+
}
59+
60+
return a.date < b.date ? 1 : -1;
61+
});
5262

5363
/**
5464
* Create docs index, which is basically the same structure as the original index

0 commit comments

Comments
 (0)