| {{ i + 1 }} |
{{ ingredient.name }} |
{{ ingredient.quantity }} |
diff --git a/composables/useRecipe.ts b/composables/useRecipe.ts
index bf57fcc..bf2586a 100644
--- a/composables/useRecipe.ts
+++ b/composables/useRecipe.ts
@@ -1,14 +1,7 @@
-type Recipe = {
- title: string;
- pictureUrl: string;
- videoUrl: string;
- category: string;
- origin: string;
- ingredients: { name: string; quantitiy: number };
- instructions: string;
-};
+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,
@@ -40,16 +33,14 @@ export default async function (keyword: Keyword, param?: string) {
const tmp = computed(() => data.value?.meals?.[0]);
- let names = [];
- let quantities = [];
- let i = 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);
}
- i++;
}
const recipe = reactive({
diff --git a/nuxt.config.ts b/nuxt.config.ts
index 152b212..b7375bc 100644
--- a/nuxt.config.ts
+++ b/nuxt.config.ts
@@ -11,7 +11,7 @@ export default defineNuxtConfig({
},
runtimeConfig: {
// The private keys which are only available server-side
- apiUrl: process.env.API_URL,
+ apiUrl: "",
// Keys within public are also exposed client-side
public: {},
},
diff --git a/package.json b/package.json
index 642ac83..7c2c0aa 100644
--- a/package.json
+++ b/package.json
@@ -26,6 +26,7 @@
"daisyui": "^4.10.2",
"postcss": "^8.4.38",
"prettier": "3.2.5",
+ "prettier-plugin-tailwindcss": "^0.5.14",
"tailwindcss": "^3.4.3"
}
}
diff --git a/types/recipe.ts b/types/recipe.ts
new file mode 100644
index 0000000..3d6c00d
--- /dev/null
+++ b/types/recipe.ts
@@ -0,0 +1,9 @@
+export type Recipe = {
+ title: string;
+ pictureUrl: string;
+ videoUrl: string;
+ category: string;
+ origin: string;
+ ingredients: { name: string; quantity: number }[];
+ instructions: string;
+};