deprived-main-website/src/routes/+layout.server.ts
2024-02-26 20:50:00 +01:00

20 lines
437 B
TypeScript

/*
* Provides post summaries to all pages. That means every page can access summaries
* for all posts on the website.
*/
import { type Post, posts } from './posts/posts_data';
export function load() {
let summaries : Post[] = [];
// Sort by newest news first
posts.sort((a, b) => b.creation_date - a.creation_date);
posts.forEach((post) => {
summaries.push(post);
});
return { summaries };
}