Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save webrune-tim/4cbdb3dfb63afea1d6a3195ba24a9d77 to your computer and use it in GitHub Desktop.

Select an option

Save webrune-tim/4cbdb3dfb63afea1d6a3195ba24a9d77 to your computer and use it in GitHub Desktop.
[slug].svelte
<script>
import client from "./sanityClient.js";
import groq from "groq";
import {parse, evaluate} from 'groq-js'
import { onMount } from "svelte";
const query = groq`
*[_type == "cms"]{
name,
slug,
heading,
description,
url,
billing,
creditCardNeeded
}
`;
onMount(async () => {
let dataset = [{_type: "cms", name: "sanity"}]
// let dataset = "*"
// ^ neither of these are
let tree = parse(query)
console.log({tree});
let value = await evaluate(tree, {dataset})
console.log({value});
let data = await value.get()
console.log(data);
});
const index = ".";
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment