diff --git a/TODO.md b/TODO.md index 5bbe111..de9f0fc 100644 --- a/TODO.md +++ b/TODO.md @@ -4,10 +4,10 @@ - [x] use nuxt framework - [x] rewrite the random page, the current landing page - [x] rewrite the recipe page -- [ ] deploy -- [ ] nuxt image +- [x] deploy +- [x] nuxt image - [x] prettier and eslint - [ ] transition - [ ] pwa - [ ] seo, robots.txt -- [ ] update the README +- [x] update the README diff --git a/bun.lockb b/bun.lockb index 98904ee..819d8b9 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/composables/useRecipe.ts b/composables/useRecipe.ts deleted file mode 100644 index bf2586a..0000000 --- a/composables/useRecipe.ts +++ /dev/null @@ -1,61 +0,0 @@ -import type { Recipe } from "~/types/recipe"; - -type Keyword = "random" | "filter" | "lookup" | "search"; - -export default async function (keyword: Keyword, param?: string) { - const { data, pending, error } = await useAsyncData( - keyword, - async () => { - const config = useRuntimeConfig(); - - let url = ""; - - switch (keyword) { - case "random": - url = `${config.apiUrl}random.php`; - break; - case "filter": - url = ""; - break; - case "lookup": - url = `${config.apiUrl}${keyword}.php?i=${param}`; - break; - case "search": - url = ""; - break; - default: - throw Error("unexpected URI parameters"); - } - return await $fetch(url); - }, - { lazy: true }, - ); - - const tmp = computed(() => data.value?.meals?.[0]); - - const names: string[] = []; - const quantities: number[] = []; - for (const [k, v] of Object.entries(tmp.value)) { - if (k.startsWith("strIngredient") && !!v) { - names.push(v); - } else if (k.startsWith("strMeasure") && !!v) { - quantities.push(v); - } - } - - const recipe = reactive({ - title: tmp.value.strMeal, - pictureUrl: tmp.value.strMealThumb, - videoUrl: tmp.value.strYoutube, - category: tmp.value.strCategory, - origin: tmp.value.strArea, - ingredients: names.map((name, i) => ({ name, quantity: quantities[i] })), - instructions: tmp.value.strInstructions, - }); - - return { - recipe, - pending, - error, - }; -} diff --git a/nuxt.config.ts b/nuxt.config.ts index 8defe9f..c81ba69 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -16,7 +16,6 @@ export default defineNuxtConfig({ // The private keys which are only available server-side apiUrl: "", // Keys within public are also exposed client-side - public: {}, }, ssr: true, }); diff --git a/pages/index.vue b/pages/index.vue index e4df656..71e2c75 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -1,11 +1,11 @@