Skip to content

Commit e0b389f

Browse files
committed
Updated SvelteKit variable names
1 parent 6e510f2 commit e0b389f

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

src/routes/[slug]/__layout.reset.svelte

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<script context="module">
2-
export async function load({ page, fetch }) {
3-
const slug = page.path.split('/').slice(-1)[0]; // last part of url path
4-
const url = `/${slug}.json`;
5-
const res = await fetch(url);
2+
export async function load({ fetch, url }) {
3+
const jsonUrl = url.pathname + '.json';
4+
const res = await fetch(jsonUrl);
65
76
if (res.ok) {
87
return {
@@ -14,7 +13,7 @@
1413
1514
return {
1615
status: res.status,
17-
error: new Error(`Could not load ${url}`)
16+
error: new Error(`Could not load ${jsonUrl}`)
1817
};
1918
}
2019
</script>

src/routes/[slug]/index.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
posts.push(p);
1212
}
1313
14-
export function load({ page }) {
15-
const { slug } = page.params;
14+
export function load({ params }) {
15+
const { slug } = params;
1616
1717
// Find the post with the slug
1818
const filteredPost = posts.find((p) => {

svelte.config.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ const config = {
3535
extensions: extensions,
3636

3737
kit: {
38-
// hydrate the <div id="svelte-root"> element in src/app.html
39-
target: '#svelte-root',
4038
adapter: adapter()
4139
}
4240
};

0 commit comments

Comments
 (0)