Skip to content

Commit c670d4a

Browse files
committed
Start on songs route
1 parent 7ee0af5 commit c670d4a

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { base } from '$app/paths';
2+
import config from '$lib/data/config';
3+
4+
/** @type {import('./$types').PageLoad} */
5+
export async function load({ params, fetch }) {
6+
const id = params.id;
7+
const collection = params.collection;
8+
9+
const bookCollection = config.bookCollections.find((x) => x.id === collection);
10+
const book = bookCollection.books.find((x) => x.id === id);
11+
12+
let songs;
13+
try {
14+
const response = await fetch(`${base}/collections/${collection}/songs/${id}.json`);
15+
if (!response.ok) {
16+
throw new Error('Failed to fetch songs JSON file');
17+
}
18+
19+
songs = await response.json();
20+
} catch (error) {
21+
console.error('Error fetching songs JSON file', error);
22+
}
23+
24+
return {
25+
collection,
26+
id,
27+
songs
28+
};
29+
}

src/routes/songs/[collection]/[id]/+page.svelte

Whitespace-only changes.

0 commit comments

Comments
 (0)