Skip to content

Commit

Permalink
Start on songs route
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisvire committed Dec 5, 2024
1 parent 7ee0af5 commit c670d4a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/routes/songs/[collection]/[id]/+page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { base } from '$app/paths';
import config from '$lib/data/config';

/** @type {import('./$types').PageLoad} */
export async function load({ params, fetch }) {
const id = params.id;
const collection = params.collection;

const bookCollection = config.bookCollections.find((x) => x.id === collection);
const book = bookCollection.books.find((x) => x.id === id);

let songs;
try {
const response = await fetch(`${base}/collections/${collection}/songs/${id}.json`);
if (!response.ok) {
throw new Error('Failed to fetch songs JSON file');
}

songs = await response.json();
} catch (error) {
console.error('Error fetching songs JSON file', error);
}

return {
collection,
id,
songs
};
}
Empty file.

0 comments on commit c670d4a

Please sign in to comment.