From 50e027b8fc4fd84c243bdbb6eae96f2f735ffdec Mon Sep 17 00:00:00 2001 From: yyasha Date: Wed, 15 Nov 2023 12:52:43 +0300 Subject: [PATCH] add last recipe on main page --- src/routes/+page.svelte | 36 ++++++++++++++++++++++++++++++++++-- src/routes/Header.svelte | 3 +++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 4ec491b..ea3ca56 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -8,10 +8,15 @@ let serverurl = 'http://192.168.0.105:3000'; let last_page = 1; let recipes_list = []; + let last_recipe; // First loading let recipes_p = axios.get(serverurl+"/recipes?page=" + last_page); recipes_p.then(function (response) { + axios.get(serverurl+"/recipe?r_id="+response.data.recipes[0].id).then(function (response) { + last_recipe = response.data.recipe; + console.log(last_recipe); + }) recipes_list = response.data.recipes; }) .catch(function (error) { @@ -41,13 +46,27 @@ {#await recipes_p} {:then} +
+ {#if last_recipe != undefined} + +
+
+

{last_recipe.title}

+

{last_recipe.desc}

+
+
+ {last_recipe.title} +
+
+ {/if} +
{#each recipes_list as recipe}
{recipe.title}
-

{recipe.ctime} / {recipe.cal}

+

{recipe.ctime} / {recipe.cal}

{recipe.title}

{/each} @@ -57,4 +76,17 @@ {/await}
- \ No newline at end of file + + + \ No newline at end of file diff --git a/src/routes/Header.svelte b/src/routes/Header.svelte index f353808..c0c2bdd 100644 --- a/src/routes/Header.svelte +++ b/src/routes/Header.svelte @@ -65,9 +65,12 @@ \ No newline at end of file