36 lines
889 B
TypeScript
36 lines
889 B
TypeScript
/*
|
|
* Provides post summaries to all pages. That means every page can access summaries
|
|
* for all posts on the website.
|
|
*/
|
|
|
|
import { posts } from './post/posts_data';
|
|
|
|
// Basically the same as Post but might contain less infomation - save storage
|
|
type Summary = {
|
|
url : string,
|
|
title : string,
|
|
summary : string,
|
|
creation_date : number,
|
|
modification_date: number,
|
|
};
|
|
|
|
export function load() {
|
|
let summaries : Summary[] = [];
|
|
|
|
// Sort by newest news first
|
|
posts.sort((a, b) => b.creation_date - a.creation_date);
|
|
|
|
posts.map((post) => {
|
|
let summary : Summary = {
|
|
url: post.url,
|
|
title : post.title,
|
|
summary : post.summary,
|
|
creation_date : post.creation_date,
|
|
modification_date : post.modification_date
|
|
};
|
|
summaries.push(summary);
|
|
});
|
|
|
|
return { summaries };
|
|
}
|