Load post data/summary into /post

This commit is contained in:
Sveske_Juice 2024-02-20 00:23:00 +01:00
parent 8457f32dd5
commit a0106369c9
6 changed files with 75 additions and 1 deletions

View File

@ -0,0 +1,5 @@
<!-- Layout for posts -->
<slot />

View File

@ -1 +0,0 @@

View File

@ -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
}))
};
}

View File

@ -0,0 +1,10 @@
<script>
export let data;
</script>
<p>hello</p>
<ul>
{#each data.summaries as summary}
<li><a href="/post/{summary.url}">{summary.title}</a></li>
{/each}
</ul>

View File

@ -0,0 +1,10 @@
<div class="post-container">
<div class="post-header">
<slot name="title" />
<slot name="creation-date" />
<slot name="modification-date" />
<!-- the post content goes in this slot -->
<slot />
</div>
</div>

30
src/routes/post/data.ts Normal file
View File

@ -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,
},
];