Working data and basic demo pages
This commit is contained in:
@@ -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,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
|
||||
};
|
||||
}
|
||||
@@ -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>
|
||||
Reference in New Issue
Block a user