Working data and basic demo pages

This commit is contained in:
2024-05-10 00:28:23 +03:00
parent e2d2599a95
commit 9983720bd1
21 changed files with 415 additions and 91 deletions
+2 -4
View File
@@ -1,12 +1,10 @@
import { getPosts } from '$lib/db/post';
import { env } from '$lib/env';
import { getPosts } from '$lib/server/db/post';
/** @type {import('./$types').PageServerLoad} */
export async function load({ locals }) {
let result = await getPosts(locals.sql);
// console.log();
console.log(result);
return {
+1 -1
View File
@@ -1,5 +1,5 @@
<script>
import Postlist from "$comp/postlist.svelte";
import Postlist from "$comp/postlist.svelte";
/**
* @type {{posts: import("$types/base").Post[]}}
@@ -0,0 +1,11 @@
import { getPost } from "$lib/server/db/post";
/** @type {import("@sveltejs/kit").ServerLoad} */
export async function load({ params, locals }) {
/** @type {import("$types/base").Post | import("$types/error").Error} */
const post = await getPost(locals.sql, Number(params.id));
return {
post: post
};
}
+12
View File
@@ -0,0 +1,12 @@
<script>
/**
* @type {{post: import("$types/base").Post}}
*/
export let data;
console.log(data);
</script>
<h1>{data.post.name}</h1>
<a href="#">{data.post.author?.name}</a>
<p>{data.post.content}</p>