From d54b9a187711016434fb9338fa376fefd85eff0b Mon Sep 17 00:00:00 2001
From: Bradley Shellnut
Date: Mon, 11 Jul 2022 19:53:50 -0700
Subject: [PATCH] Fixing show hide to be slightly better.
---
src/routes/game/[id].svelte | 36 ++++++++++++++++++++++++++++--------
1 file changed, 28 insertions(+), 8 deletions(-)
diff --git a/src/routes/game/[id].svelte b/src/routes/game/[id].svelte
index 00b2e9d..4442bf8 100644
--- a/src/routes/game/[id].svelte
+++ b/src/routes/game/[id].svelte
@@ -8,6 +8,14 @@
export let game: GameType;
let seeMore: boolean = false;
+ console.log(game?.description?.indexOf('
'));
+ let firstParagraphEnd = 0;
+ if (game?.description?.indexOf('') > 0) {
+ firstParagraphEnd = game?.description?.indexOf('') + 4;
+ } else if (game?.description?.indexOf(' p>') > 0) {
+ firstParagraphEnd = game?.description?.indexOf(' p>') + 5;
+ }
+ console.log('firstParagraphEnd', firstParagraphEnd);
@@ -22,24 +30,32 @@
-
+
-
Price: {game?.price}
Year Published: {game?.year_published}
Players: {game.players} {game.max_players === 1 ? 'player' : 'players'}
Playtime: {game.playtime} minutes
Minimum Age: {game.min_age}
+
Price: ${game?.price}
Board Game Atlas Link
-
- {@html game?.description?.substring(0, game?.description?.indexOf('
'))}
- {#if seeMore}
- {@html game?.description?.substring(game?.description?.indexOf('
') + 12)}
+{#if firstParagraphEnd > 0}
+
+
+ {@html game?.description?.substring(0, firstParagraphEnd)}
+
+ {#if game?.description?.substring(firstParagraphEnd + 1) !== ''}
+ {#if seeMore}
+
+ {@html game?.description?.substring(firstParagraphEnd + 1)}
+
+ {/if}
+
{/if}
-
-
+
+{/if}