mirror of
https://github.com/rjNemo/meal_planner
synced 2026-06-12 13:26:45 +00:00
share types and fix linter errors
This commit is contained in:
parent
6df97a0113
commit
7e9f2b0fb6
8 changed files with 21 additions and 20 deletions
2
TODO.md
2
TODO.md
|
|
@ -3,7 +3,7 @@
|
||||||
- [x] use bun package manager
|
- [x] use bun package manager
|
||||||
- [x] use nuxt framework
|
- [x] use nuxt framework
|
||||||
- [x] rewrite the random page, the current landing page
|
- [x] rewrite the random page, the current landing page
|
||||||
- [ ] rewrite the recipe page
|
- [x] rewrite the recipe page
|
||||||
- [ ] deploy
|
- [ ] deploy
|
||||||
- [ ] nuxt image
|
- [ ] nuxt image
|
||||||
- [x] prettier and eslint
|
- [x] prettier and eslint
|
||||||
|
|
|
||||||
BIN
bun.lockb
BIN
bun.lockb
Binary file not shown.
|
|
@ -1,7 +1,7 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
const props = defineProps<{
|
import type { Recipe } from "~/types/recipe";
|
||||||
recipe: Recipe;
|
|
||||||
}>();
|
defineProps<{ recipe: Recipe }>();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
|
||||||
|
|
@ -9,13 +9,13 @@ defineProps<{
|
||||||
<table class="table table-s table-pin-rows table-pin-cols">
|
<table class="table table-s table-pin-rows table-pin-cols">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th></th>
|
<th />
|
||||||
<td>Ingredient</td>
|
<td>Ingredient</td>
|
||||||
<td>Quantity</td>
|
<td>Quantity</td>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr v-for="(ingredient, i) in ingredients">
|
<tr v-for="(ingredient, i) in ingredients" :key="i">
|
||||||
<th>{{ i + 1 }}</th>
|
<th>{{ i + 1 }}</th>
|
||||||
<td>{{ ingredient.name }}</td>
|
<td>{{ ingredient.name }}</td>
|
||||||
<td>{{ ingredient.quantity }}</td>
|
<td>{{ ingredient.quantity }}</td>
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,7 @@
|
||||||
type Recipe = {
|
import type { Recipe } from "~/types/recipe";
|
||||||
title: string;
|
|
||||||
pictureUrl: string;
|
|
||||||
videoUrl: string;
|
|
||||||
category: string;
|
|
||||||
origin: string;
|
|
||||||
ingredients: { name: string; quantitiy: number };
|
|
||||||
instructions: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
type Keyword = "random" | "filter" | "lookup" | "search";
|
type Keyword = "random" | "filter" | "lookup" | "search";
|
||||||
|
|
||||||
export default async function (keyword: Keyword, param?: string) {
|
export default async function (keyword: Keyword, param?: string) {
|
||||||
const { data, pending, error } = await useAsyncData(
|
const { data, pending, error } = await useAsyncData(
|
||||||
keyword,
|
keyword,
|
||||||
|
|
@ -40,16 +33,14 @@ export default async function (keyword: Keyword, param?: string) {
|
||||||
|
|
||||||
const tmp = computed(() => data.value?.meals?.[0]);
|
const tmp = computed(() => data.value?.meals?.[0]);
|
||||||
|
|
||||||
let names = [];
|
const names: string[] = [];
|
||||||
let quantities = [];
|
const quantities: number[] = [];
|
||||||
let i = 0;
|
|
||||||
for (const [k, v] of Object.entries(tmp.value)) {
|
for (const [k, v] of Object.entries(tmp.value)) {
|
||||||
if (k.startsWith("strIngredient") && !!v) {
|
if (k.startsWith("strIngredient") && !!v) {
|
||||||
names.push(v);
|
names.push(v);
|
||||||
} else if (k.startsWith("strMeasure") && !!v) {
|
} else if (k.startsWith("strMeasure") && !!v) {
|
||||||
quantities.push(v);
|
quantities.push(v);
|
||||||
}
|
}
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const recipe = reactive<Recipe>({
|
const recipe = reactive<Recipe>({
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ export default defineNuxtConfig({
|
||||||
},
|
},
|
||||||
runtimeConfig: {
|
runtimeConfig: {
|
||||||
// The private keys which are only available server-side
|
// The private keys which are only available server-side
|
||||||
apiUrl: process.env.API_URL,
|
apiUrl: "",
|
||||||
// Keys within public are also exposed client-side
|
// Keys within public are also exposed client-side
|
||||||
public: {},
|
public: {},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@
|
||||||
"daisyui": "^4.10.2",
|
"daisyui": "^4.10.2",
|
||||||
"postcss": "^8.4.38",
|
"postcss": "^8.4.38",
|
||||||
"prettier": "3.2.5",
|
"prettier": "3.2.5",
|
||||||
|
"prettier-plugin-tailwindcss": "^0.5.14",
|
||||||
"tailwindcss": "^3.4.3"
|
"tailwindcss": "^3.4.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
9
types/recipe.ts
Normal file
9
types/recipe.ts
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
export type Recipe = {
|
||||||
|
title: string;
|
||||||
|
pictureUrl: string;
|
||||||
|
videoUrl: string;
|
||||||
|
category: string;
|
||||||
|
origin: string;
|
||||||
|
ingredients: { name: string; quantity: number }[];
|
||||||
|
instructions: string;
|
||||||
|
};
|
||||||
Loading…
Reference in a new issue