28 lines
631 B
Svelte
28 lines
631 B
Svelte
<script>
|
|
import { client } from '/src/utils/sanity/client.js'
|
|
|
|
// Fetch content with GROQ
|
|
async function getContent() {
|
|
const CONTENT_QUERY = `*[_type == "project"] {
|
|
...,
|
|
coverImage {
|
|
...,
|
|
asset->
|
|
},
|
|
duration {
|
|
...
|
|
},
|
|
tags[],
|
|
body
|
|
}
|
|
`
|
|
const content = await client.fetch(CONTENT_QUERY)
|
|
return content
|
|
}
|
|
const posts = getContent();
|
|
// Log content to console
|
|
getContent().then(content => console.log(content))
|
|
|
|
// Insert the return component calling `getContent()` below
|
|
</script>
|
|
<p>{posts.title}</p> |