diff --git a/src/App.svelte b/src/App.svelte index 96296ed..cf1e64f 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -15,9 +15,13 @@ import { SearchIcon } from "@rgossiaux/svelte-heroicons/outline"; let currentView = "/topics"; + let randomItemId; - function handleTabChanged(event) { - currentView = event.detail.tab; + function getRandomItemId(){ + fetch('/learn.json?_shape=array&sql=select+rowid+from+items+order+by+random()+limit+1').then(r => r.json()) + .then(data => { + randomItemId = data[0].rowid; + }); } async function hashchange() { @@ -32,8 +36,11 @@ } } + onMount(getRandomItemId); onMount(hashchange); + + @@ -57,6 +64,8 @@ {:else if currentView.startsWith("/item/")} + {:else if currentView == "/random"} + {#if randomItemId}{/if} {:else if currentView === "/search"} {:else if currentView === "/wanttolearn"} @@ -75,7 +84,7 @@ Formats - + Random Item diff --git a/src/ItemDetail.svelte b/src/ItemDetail.svelte index ac88c34..6cf2a2e 100644 --- a/src/ItemDetail.svelte +++ b/src/ItemDetail.svelte @@ -5,12 +5,19 @@ export let itemid; let item; + let reviews = []; $: fetch(`/learn/items/${itemid}.json?_shape=object`) .then(r => r.json()) .then(data => { item = data[itemid]; }); + + $: fetch(`/learn/reviews.json?_shape=array&item_id__exact=${itemid}`) + .then(r => r.json()) + .then(data => { + reviews = data; + }); function saveStatusToLocalStorage(event){ // console.log($bookmarks) @@ -184,28 +191,18 @@

Reviews

-
- {#each reviews as review} -
-
-

{review.heading}

-

{review.details}

-
-
-
- user avatar -
-

By {review.by}

- {review.date} -
-
-
- -
- -
-
- {/each} +
+ {#each reviews as review} +
+

{review.blurb.toString().slice(0,10)}...

+

{review.blurb}

+
+ + ...{review.by} +
+
+ {/each} +
diff --git a/src/VideoCard.svelte b/src/VideoCard.svelte index b5f13fa..78d9b25 100644 --- a/src/VideoCard.svelte +++ b/src/VideoCard.svelte @@ -11,8 +11,6 @@ let ytid = youtubeurl && youtube_parser(youtubeurl); let thumbnail_image_url = ytid && `https://img.youtube.com/vi/${ytid}/mqdefault.jpg` - - let vimeo = GET https://vimeo.com/api/oembed.json?url={video_url}