-
Notifications
You must be signed in to change notification settings - Fork 1
/
toast.js
27 lines (21 loc) · 923 Bytes
/
toast.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import * as PostSource from "./data/fetch-mdx-post-files.js";
import * as BlenderPostSource from "./data/fetch-blender-post-files.js";
import engagements from "./data/engagements.js";
export const sourceData = async ({ setDataForSlug }) => {
const postsData = await PostSource.sourceData({ setDataForSlug });
postsData.sort((b, a) => {
const da = new Date(a.date).getTime();
const db = new Date(b.date).getTime();
if (da < db) return -1;
if (da === db) return 0;
if (da > db) return 1;
});
const NUMBER_OF_POSTS = 5;
const firstPosts = postsData.slice(0, NUMBER_OF_POSTS);
await setDataForSlug("/", { data: { latestPosts: firstPosts, engagements } });
await setDataForSlug("/garden", { data: { posts: postsData } });
const blenderPostData = await BlenderPostSource.sourceData({
setDataForSlug,
});
await setDataForSlug("/blender", { data: { posts: blenderPostData } });
};