Created
June 13, 2020 21:13
-
-
Save webrune-tim/4cbdb3dfb63afea1d6a3195ba24a9d77 to your computer and use it in GitHub Desktop.
[slug].svelte
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <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