learnings loader is working-ish. It's server side now

This commit is contained in:
christian 2024-04-28 00:19:55 +02:00
parent ec0e91fcfa
commit 77f65c1287
3 changed files with 9 additions and 5 deletions

View File

@ -3,7 +3,7 @@
* As your schema evolves, this pattern will be useful to keep your data in sync across all surfaces. * As your schema evolves, this pattern will be useful to keep your data in sync across all surfaces.
*/ */
export function getPostsQuery(extraFilter) { export function getPostsQuery(extraFilter) {
return `*[_type == "project"] { return `*[_type == "post"] {
_id, _id,
_type, _type,
_createdAt, _createdAt,

View File

@ -5,9 +5,6 @@ import { POST_CARD_FRAGMENT, getPostsQuery } from '$lib/queries.js'
export async function load() { export async function load() {
const data = await client.fetch(/* groq */ `{ const data = await client.fetch(/* groq */ `{
"posts": ${getPostsQuery()}, "posts": ${getPostsQuery()},
"post": *[_type == "post"] {
${POST_CARD_FRAGMENT}
}
}`) }`)
if (data) { if (data) {

View File

@ -1,4 +1,11 @@
<script> <script>
import { getAllContexts } from "svelte";
export let data; export let data;
</script> </script>
<p>{data.posts}</p>
{#each data.body.posts as post }
<h2>{post.title}</h2>
<p>{post.body}</p>
<img src="{post.coverImage.url}" alt="yes">
{/each}