-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: 🐛 fix breaking changes with page params
See sveltejs/kit#3126 for more details
- Loading branch information
Showing
2 changed files
with
42 additions
and
42 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,65 @@ | ||
<script context="module"> | ||
import { GraphQLClient } from 'graphql-request'; | ||
import { GraphQLClient } from 'graphql-request'; | ||
export async function load(ctx) { | ||
const graphcms = new GraphQLClient( | ||
'https://api-eu-central-1.graphcms.com/v2/ck8sn5tnf01gc01z89dbc7s0o/master', | ||
{ | ||
headers: {} | ||
} | ||
); | ||
export async function load({ params }) { | ||
const graphcms = new GraphQLClient( | ||
'https://api-eu-central-1.graphcms.com/v2/ck8sn5tnf01gc01z89dbc7s0o/master', | ||
{ | ||
headers: {}, | ||
} | ||
); | ||
const { product } = await graphcms.request( | ||
`query ProductPageQuery($slug: String!) { | ||
const { product } = await graphcms.request( | ||
`query ProductPageQuery($slug: String!) { | ||
product(where: { slug: $slug }) { | ||
name | ||
description | ||
price | ||
} | ||
}`, | ||
{ | ||
slug: ctx.page.params.slug | ||
} | ||
); | ||
{ | ||
slug: params.slug, | ||
} | ||
); | ||
return { | ||
props: { | ||
product | ||
} | ||
}; | ||
} | ||
return { | ||
props: { | ||
product, | ||
}, | ||
}; | ||
} | ||
</script> | ||
|
||
<script> | ||
export let product; | ||
export let product; | ||
</script> | ||
|
||
<svelte:head> | ||
<title>{product.name}</title> | ||
<title>{product.name}</title> | ||
</svelte:head> | ||
|
||
<h1>{product.name}</h1> | ||
<p>{product.description}</p> | ||
<p>${product.price / 100}</p> | ||
|
||
<style> | ||
h1, | ||
p { | ||
text-align: center; | ||
margin: 0 auto; | ||
} | ||
h1 { | ||
font-size: 2.8em; | ||
text-transform: uppercase; | ||
font-weight: 700; | ||
margin: 0 0 0.5em 0; | ||
} | ||
p { | ||
margin: 1em auto; | ||
} | ||
@media (min-width: 480px) { | ||
h1 { | ||
font-size: 4em; | ||
} | ||
} | ||
h1, | ||
p { | ||
text-align: center; | ||
margin: 0 auto; | ||
} | ||
h1 { | ||
font-size: 2.8em; | ||
text-transform: uppercase; | ||
font-weight: 700; | ||
margin: 0 0 0.5em 0; | ||
} | ||
p { | ||
margin: 1em auto; | ||
} | ||
@media (min-width: 480px) { | ||
h1 { | ||
font-size: 4em; | ||
} | ||
} | ||
</style> |