mirror of
https://github.com/BradNut/boredgame
synced 2025-09-08 17:40:22 +00:00
Migrating to page server data.
This commit is contained in:
parent
8bc15e74a4
commit
b172ac02f4
3 changed files with 11 additions and 6 deletions
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { error } from '@sveltejs/kit';
|
||||||
import type { PageServerLoad } from './$types'
|
import type { PageServerLoad } from './$types'
|
||||||
import { boardGameApi } from '../../_api';
|
import { boardGameApi } from '../../_api';
|
||||||
|
|
||||||
|
|
@ -16,7 +17,7 @@ export const load: PageServerLoad = async ({ params }: GamePageParams) => {
|
||||||
const response = await boardGameApi('get', `search`, queryParams);
|
const response = await boardGameApi('get', `search`, queryParams);
|
||||||
if (response.status === 404) {
|
if (response.status === 404) {
|
||||||
return {
|
return {
|
||||||
games: []
|
game: []
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -24,11 +25,12 @@ export const load: PageServerLoad = async ({ params }: GamePageParams) => {
|
||||||
const gameResponse = await response.json();
|
const gameResponse = await response.json();
|
||||||
// console.log('gameResponse', gameResponse);
|
// console.log('gameResponse', gameResponse);
|
||||||
// const games = gameResponse?.games;
|
// const games = gameResponse?.games;
|
||||||
console.log('game', gameResponse?.games[0]);
|
console.log('game response', gameResponse?.games[0]);
|
||||||
return {
|
return {
|
||||||
game: gameResponse?.games[0]
|
game: gameResponse?.games[0]
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Error("@migration task: Migrate this return statement (https://github.com/sveltejs/kit/discussions/5774#discussioncomment-3292699)");
|
throw error(response.status);
|
||||||
|
// throw new Error("@migration task: Migrate this return statement (https://github.com/sveltejs/kit/discussions/5774#discussioncomment-3292699)");
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -14,10 +14,12 @@
|
||||||
import { collectionStore } from '$lib/stores/collectionStore';
|
import { collectionStore } from '$lib/stores/collectionStore';
|
||||||
import type { GameType, SavedGameType } from '$lib/types';
|
import type { GameType, SavedGameType } from '$lib/types';
|
||||||
import { addToCollection, removeFromCollection } from '$lib/util/manipulateCollection';
|
import { addToCollection, removeFromCollection } from '$lib/util/manipulateCollection';
|
||||||
|
import type { PageData } from './$types';
|
||||||
|
|
||||||
$: existsInCollection = $collectionStore.find((item: SavedGameType) => item.id === game.id);
|
$: existsInCollection = $collectionStore.find((item: SavedGameType) => item.id === game.id);
|
||||||
export let game: GameType;
|
export let data: PageData;
|
||||||
export const data;
|
export let game: GameType = data.game;
|
||||||
|
console.log('page game', game);
|
||||||
let seeMore: boolean = false;
|
let seeMore: boolean = false;
|
||||||
console.log(game?.description?.indexOf('</p>'));
|
console.log(game?.description?.indexOf('</p>'));
|
||||||
let firstParagraphEnd = 0;
|
let firstParagraphEnd = 0;
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,9 @@
|
||||||
pending_delete: boolean;
|
pending_delete: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export let data;
|
// export let data;
|
||||||
export let todos: Todo[];
|
export let todos: Todo[];
|
||||||
|
console.log('todos', todos);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue