mirror of
https://github.com/BradNut/boredgame
synced 2025-09-08 17:40:22 +00:00
Fixing url on link with icon and fixing nulls on playtime/players.
This commit is contained in:
parent
18dd5640de
commit
103690fbbc
5 changed files with 1133 additions and 10 deletions
|
|
@ -1,6 +1,4 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { SvelteComponentTyped } from 'svelte';
|
|
||||||
|
|
||||||
export let url: string;
|
export let url: string;
|
||||||
export let ariaLabel = `Link to ${url}`;
|
export let ariaLabel = `Link to ${url}`;
|
||||||
export let external = false;
|
export let external = false;
|
||||||
|
|
|
||||||
|
|
@ -40,13 +40,21 @@ export type ToastData = {
|
||||||
message: string;
|
message: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type GameMechanic = {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
boardGameAtlasLink: string;
|
||||||
|
};
|
||||||
|
|
||||||
export type SavedGameType = {
|
export type SavedGameType = {
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
thumb_url: string;
|
thumb_url: string;
|
||||||
players: string;
|
players: string;
|
||||||
playtime: string;
|
playtime: string;
|
||||||
|
mechanics: GameMechanic[];
|
||||||
searchTerms: string;
|
searchTerms: string;
|
||||||
|
includeInRandom: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type GameType = {
|
export type GameType = {
|
||||||
|
|
|
||||||
1114
src/lib/util/boardGameAtlasMechanics.json
Normal file
1114
src/lib/util/boardGameAtlasMechanics.json
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -6,7 +6,7 @@ export const load: PageServerLoad = async ({ params, setHeaders }) => {
|
||||||
const queryParams = {
|
const queryParams = {
|
||||||
ids: `${params?.id}`,
|
ids: `${params?.id}`,
|
||||||
fields:
|
fields:
|
||||||
'id,name,price,min_age,min_players,max_players,thumb_url,playtime,min_playtime,max_playtime,min_age,description,year_published,image_url'
|
'id,name,price,min_age,min_players,max_players,thumb_url,playtime,min_playtime,max_playtime,min_age,description,year_published,url,image_url'
|
||||||
};
|
};
|
||||||
|
|
||||||
const response = await boardGameApi('get', `search`, queryParams);
|
const response = await boardGameApi('get', `search`, queryParams);
|
||||||
|
|
@ -19,8 +19,13 @@ export const load: PageServerLoad = async ({ params, setHeaders }) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const game = gameResponse?.games[0];
|
const game = gameResponse?.games[0];
|
||||||
game.players = `${game.min_players}-${game.max_players}`;
|
if (game.min_players) {
|
||||||
game.playtime = `${game.min_playtime}-${game.max_playtime}`;
|
game.players = `${game.min_players}-${game.max_players}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (game.min_playtime) {
|
||||||
|
game.playtime = `${game.min_playtime}-${game.max_playtime}`;
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
game
|
game
|
||||||
|
|
|
||||||
|
|
@ -82,11 +82,9 @@
|
||||||
{#if +game?.price !== 0.0}
|
{#if +game?.price !== 0.0}
|
||||||
<p>Price: ${game?.price}</p>
|
<p>Price: ${game?.price}</p>
|
||||||
{/if}
|
{/if}
|
||||||
<p>
|
<LinkWithIcon external ariaLabel={`Board Game Atlas Link for ${game.name}`} url={game.url}>
|
||||||
<LinkWithIcon external ariaLabel={`Board Game Atlas Link for ${game.name}`} url={game.url}>
|
Board Game Atlas <ExternalLinkIcon width="24" height="24" />
|
||||||
Board Game Atlas <ExternalLinkIcon width="24" height="24" />
|
</LinkWithIcon>
|
||||||
</LinkWithIcon>
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
<div style="display: grid; gap: 1.5rem; place-content: center;">
|
<div style="display: grid; gap: 1.5rem; place-content: center;">
|
||||||
{#if existsInCollection}
|
{#if existsInCollection}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue