From e4e153fe1b9852b839f9cb08d377e14c24254668 Mon Sep 17 00:00:00 2001 From: AlexBocken Date: Mon, 3 Jul 2023 12:39:34 +0200 Subject: [PATCH] Icon route added --- src/lib/components/Card.svelte | 2 +- src/lib/components/IconLayout.svelte | 74 +++++++++++++++++++ src/routes/api/items/icon/[icon]/+server.ts | 2 +- src/routes/rezepte/+layout.svelte | 3 +- src/routes/rezepte/+page.svelte | 28 ++++--- src/routes/rezepte/[name]/+page.svelte | 3 +- .../rezepte/[name]/MultiImgWrapper.svelte | 10 --- src/routes/rezepte/icon/+page.svelte | 69 +++++++++++++++++ src/routes/rezepte/icon/+page.ts | 10 +++ .../rezepte/icon/.jukit/.jukit_info.json | 1 + src/routes/rezepte/icon/[icon]/+page.svelte | 17 +++++ src/routes/rezepte/icon/[icon]/+page.ts | 13 ++++ 12 files changed, 205 insertions(+), 27 deletions(-) create mode 100644 src/lib/components/IconLayout.svelte delete mode 100644 src/routes/rezepte/[name]/MultiImgWrapper.svelte create mode 100644 src/routes/rezepte/icon/+page.svelte create mode 100644 src/routes/rezepte/icon/+page.ts create mode 100644 src/routes/rezepte/icon/.jukit/.jukit_info.json create mode 100644 src/routes/rezepte/icon/[icon]/+page.svelte create mode 100644 src/routes/rezepte/icon/[icon]/+page.ts diff --git a/src/lib/components/Card.svelte b/src/lib/components/Card.svelte index 5155ff3..51e7d7c 100644 --- a/src/lib/components/Card.svelte +++ b/src/lib/components/Card.svelte @@ -191,7 +191,7 @@ if(icon_override){ {#if icon_override || recipe.season.includes(current_month)} - {recipe.icon} + {recipe.icon} {/if} {recipe.alt}
diff --git a/src/lib/components/IconLayout.svelte b/src/lib/components/IconLayout.svelte new file mode 100644 index 0000000..439bcaf --- /dev/null +++ b/src/lib/components/IconLayout.svelte @@ -0,0 +1,74 @@ + + + + + +
+{#each icons as icon} + {icon} +{/each} +
+
+ +
+
+ +
diff --git a/src/routes/api/items/icon/[icon]/+server.ts b/src/routes/api/items/icon/[icon]/+server.ts index 60be55d..9a50c55 100644 --- a/src/routes/api/items/icon/[icon]/+server.ts +++ b/src/routes/api/items/icon/[icon]/+server.ts @@ -5,7 +5,7 @@ import type {BriefRecipeType} from '../../../../../types/types'; export const GET: RequestHandler = async ({params}) => { await dbConnect(); - let recipes = (await Recipe.find({tags: params.icon}, 'name short_name images tags category icon description season').lean()) as BriefRecipeType[]; + let recipes = (await Recipe.find({icon: params.icon}, 'name short_name images tags category icon description season').lean()) as BriefRecipeType[]; await dbDisconnect(); recipes = JSON.parse(JSON.stringify(recipes)); diff --git a/src/routes/rezepte/+layout.svelte b/src/routes/rezepte/+layout.svelte index 990cc3a..f610ab5 100644 --- a/src/routes/rezepte/+layout.svelte +++ b/src/routes/rezepte/+layout.svelte @@ -8,7 +8,8 @@ import Header from '$lib/components/Header.svelte'
  • Home
  • Alle Rezepte
  • In Saison
  • -
  • Nach Kategorie
  • +
  • Kategorie
  • +
  • Icon
  • Stichwörter
  • diff --git a/src/routes/rezepte/+page.svelte b/src/routes/rezepte/+page.svelte index 0c846b0..20450b6 100644 --- a/src/routes/rezepte/+page.svelte +++ b/src/routes/rezepte/+page.svelte @@ -1,12 +1,12 @@ +
    +{#each data.icons as icon} + {icon} +{/each} +
    diff --git a/src/routes/rezepte/icon/+page.ts b/src/routes/rezepte/icon/+page.ts new file mode 100644 index 0000000..f788408 --- /dev/null +++ b/src/routes/rezepte/icon/+page.ts @@ -0,0 +1,10 @@ +import type { PageLoad } from "./$types"; + +export async function load({ fetch }) { + let current_month = new Date().getMonth() + 1 + const res_icons = await fetch(`/api/items/icon`); + const item = await res_icons.json(); + return { + icons: item, + }; +}; diff --git a/src/routes/rezepte/icon/.jukit/.jukit_info.json b/src/routes/rezepte/icon/.jukit/.jukit_info.json new file mode 100644 index 0000000..92c7342 --- /dev/null +++ b/src/routes/rezepte/icon/.jukit/.jukit_info.json @@ -0,0 +1 @@ +{"terminal": "nvimterm"} \ No newline at end of file diff --git a/src/routes/rezepte/icon/[icon]/+page.svelte b/src/routes/rezepte/icon/[icon]/+page.svelte new file mode 100644 index 0000000..bfd17fa --- /dev/null +++ b/src/routes/rezepte/icon/[icon]/+page.svelte @@ -0,0 +1,17 @@ + + +

    Rezepte mit {data.icon}

    + + {#each data.season as recipe} + + {/each} + +
    diff --git a/src/routes/rezepte/icon/[icon]/+page.ts b/src/routes/rezepte/icon/[icon]/+page.ts new file mode 100644 index 0000000..064261f --- /dev/null +++ b/src/routes/rezepte/icon/[icon]/+page.ts @@ -0,0 +1,13 @@ +import type { PageLoad } from "./$types"; + +export async function load({ fetch, params }) { + const res_season = await fetch(`/api/items/icon/` + params.icon); + const res_icons = await fetch(`/api/items/icon`); + const icons = await res_icons.json(); + const item_season = await res_season.json(); + return { + icons: icons, + icon: params.icon, + season: item_season, + }; +};