Skip to content

Commit

Permalink
update load args for sveltejs/kit#3126
Browse files Browse the repository at this point in the history
  • Loading branch information
giokara-work committed Apr 18, 2022
1 parent a8a8713 commit 398dbb8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
7 changes: 3 additions & 4 deletions src/routes/[slug]/__layout.svelte
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<script context="module">
export async function load({ page, fetch }) {
const slug = page.path.split('/').slice(-1)[0]; // last part of url path
const url = `/${slug}.json`;
const res = await fetch(url);
export async function load({ url, fetch }) {
const urn = `${url.pathname}.json`;
const res = await fetch(urn);
if (res.ok) {
return {
props: {
Expand Down
4 changes: 2 additions & 2 deletions src/routes/[slug]/index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
posts.push(p);
}
export function load({ page }) {
const { slug } = page.params;
export function load({ params }) {
const { slug } = params;
// Find the post with the slug
const filteredPost = posts.find((p) => {
Expand Down
2 changes: 1 addition & 1 deletion src/routes/index.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script context="module">
import { zip } from 'lodash';
import { segmentProperties, SegmentStateEnum } from '../types';
import { segmentProperties } from '../types';
import {
getSegmentState,
aggregateTrafficSnapshotData,
Expand Down

0 comments on commit 398dbb8

Please sign in to comment.