Skip to content

Commit

Permalink
fix: 🐛 fix breaking changes with page params
Browse files Browse the repository at this point in the history
See sveltejs/kit#3126 for more details
  • Loading branch information
spences10 committed Jan 27, 2022
1 parent 9005853 commit 6319d60
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 42 deletions.
2 changes: 1 addition & 1 deletion with-sveltekit-and-urql/src/routes/products/[slug].svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script context="module">
export const load = async ({ page: { params } }) => {
export const load = async ({ params }) => {
const { slug } = params;
return {
props: { slug },
Expand Down
82 changes: 41 additions & 41 deletions with-sveltekit/src/routes/product/[slug].svelte
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>

0 comments on commit 6319d60

Please sign in to comment.