From a0106369c953fcd021480bc1a2f231a38ccda0fd Mon Sep 17 00:00:00 2001 From: Sveske_Juice Date: Tue, 20 Feb 2024 00:23:00 +0100 Subject: [PATCH] Load post data/summary into /post --- src/routes/post/+layout.svelte | 5 +++++ src/routes/post/+page.server.js | 1 - src/routes/post/+page.server.ts | 20 ++++++++++++++++++++ src/routes/post/+page.svelte | 10 ++++++++++ src/routes/post/Post.svelte | 10 ++++++++++ src/routes/post/data.ts | 30 ++++++++++++++++++++++++++++++ 6 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 src/routes/post/+layout.svelte delete mode 100644 src/routes/post/+page.server.js create mode 100644 src/routes/post/+page.server.ts create mode 100644 src/routes/post/Post.svelte create mode 100644 src/routes/post/data.ts diff --git a/src/routes/post/+layout.svelte b/src/routes/post/+layout.svelte new file mode 100644 index 0000000..8df028d --- /dev/null +++ b/src/routes/post/+layout.svelte @@ -0,0 +1,5 @@ + + + + + diff --git a/src/routes/post/+page.server.js b/src/routes/post/+page.server.js deleted file mode 100644 index 8b13789..0000000 --- a/src/routes/post/+page.server.js +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/routes/post/+page.server.ts b/src/routes/post/+page.server.ts new file mode 100644 index 0000000..4b01c83 --- /dev/null +++ b/src/routes/post/+page.server.ts @@ -0,0 +1,20 @@ +import { posts } from './data.js'; + +// Basically the same as Post but might contain less infomation - save storage +// type Summary = { +// url : string, +// title : string, +// description : string, +// creation_date : number, +// modification_date: number, +// }; + +export function load() { + return { + summaries: posts.map((post) => ({ + url: post.url, + title: post.title, + description: post.description + })) + }; +} diff --git a/src/routes/post/+page.svelte b/src/routes/post/+page.svelte index e69de29..81764a3 100644 --- a/src/routes/post/+page.svelte +++ b/src/routes/post/+page.svelte @@ -0,0 +1,10 @@ + + +

hello

+ diff --git a/src/routes/post/Post.svelte b/src/routes/post/Post.svelte new file mode 100644 index 0000000..e84b8ce --- /dev/null +++ b/src/routes/post/Post.svelte @@ -0,0 +1,10 @@ +
+
+ + + + + + +
+
diff --git a/src/routes/post/data.ts b/src/routes/post/data.ts new file mode 100644 index 0000000..b5e8e23 --- /dev/null +++ b/src/routes/post/data.ts @@ -0,0 +1,30 @@ +// TODO: document members +type Post = { + // Required + url : string, + title: string, + description : string, + creation_date : number + modification_date: number, + + // Optional + // TODO: author? + // TODO: image cover +} + +export const posts : Post[] = [ + { + url: 'folder-icons', + title: 'Amazing Icons for Folders in Unity!', + description: 'See how you can use Zhen\'s folder icons for Unity to boost your developer experience', + creation_date: 1708382491, + modification_date: 1708382491, + }, + { + url: 'lorem', + title: 'Lorem Ipsum !!', + description: 'This is a nice exploanation on lorem ipsum latin', + creation_date: 1708382491, + modification_date: 1708382491, + }, +];