This commit is contained in:
Ruidy 2024-12-13 21:19:19 +01:00
parent df158d3ff4
commit 3c4d4db1be
No known key found for this signature in database
GPG key ID: E00F51288CB857CC
8 changed files with 50 additions and 14 deletions

BIN
bun.lockb

Binary file not shown.

View file

@ -23,12 +23,12 @@ defineProps<{ recipe: Recipe }>();
<RecipeIngredients :ingredients="recipe.ingredients" /> <RecipeIngredients :ingredients="recipe.ingredients" />
</div> </div>
</div> </div>
<div class="flex flex-col items-center py-6"> <div class="flex flex-col items-center py-6">
<h2 class="text-2xl lg:text-3xl font-semibold mb-4">Instructions</h2> <h2 class="text-2xl lg:text-3xl font-semibold mb-4">Instructions</h2>
<div class="prose prose-lg max-w-none w-full"> <p class="prose prose-lg max-w-none w-full">
{{ recipe.instructions }} {{ recipe.instructions }}
</div> </p>
</div> </div>
</div> </div>
</template> </template>

View file

@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
defineProps<{ defineProps<{
ingredients: { name: string; quantity: number }[]; ingredients: { name: string; quantity: string }[];
}>(); }>();
</script> </script>

View file

@ -1,24 +1,38 @@
// https://nuxt.com/docs/api/configuration/nuxt-config // https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({ export default defineNuxtConfig({
devtools: { enabled: true }, devtools: { enabled: true },
modules: ["@nuxt/eslint", "@nuxt/image", "nuxt-icon", "nuxt-delay-hydration"],
build: { build: {
transpile: ["trpc-nuxt"], transpile: ["trpc-nuxt"],
}, },
css: ["~/assets/css/main.css"], css: ["~/assets/css/main.css"],
image: { image: {
domains: ["www.themealdb.com"], domains: ["www.themealdb.com"],
}, },
modules: ["@nuxt/eslint", "@nuxt/image", "nuxt-icon"],
delayHydration: {
mode: "init",
// enables nuxt-delay-hydration in dev mode for testing
debug: process.env.NODE_ENV === "development",
},
postcss: { postcss: {
plugins: { plugins: {
tailwindcss: {}, tailwindcss: {},
autoprefixer: {}, autoprefixer: {},
}, },
}, },
runtimeConfig: { runtimeConfig: {
// The private keys which are only available server-side // The private keys which are only available server-side
apiUrl: "", apiUrl: "",
// Keys within public are also exposed client-side // Keys within public are also exposed client-side
}, },
ssr: true, ssr: true,
compatibilityDate: "2024-12-13",
}); });

View file

@ -17,7 +17,7 @@
"@nuxt/image": "^1.6.0", "@nuxt/image": "^1.6.0",
"@trpc/client": "^10.45.2", "@trpc/client": "^10.45.2",
"@trpc/server": "^10.45.2", "@trpc/server": "^10.45.2",
"nuxt": "^3.11.2", "nuxt": "^3.14.1592",
"nuxt-icon": "^0.6.10", "nuxt-icon": "^0.6.10",
"trpc-nuxt": "^0.10.22", "trpc-nuxt": "^0.10.22",
"vue": "^3.4.21", "vue": "^3.4.21",
@ -28,6 +28,7 @@
"@tailwindcss/typography": "^0.5.13", "@tailwindcss/typography": "^0.5.13",
"autoprefixer": "^10.4.19", "autoprefixer": "^10.4.19",
"daisyui": "^4.10.2", "daisyui": "^4.10.2",
"nuxt-delay-hydration": "^1.3.8",
"postcss": "^8.4.38", "postcss": "^8.4.38",
"prettier": "3.2.5", "prettier": "3.2.5",
"prettier-plugin-tailwindcss": "^0.5.14", "prettier-plugin-tailwindcss": "^0.5.14",

View file

@ -1,11 +1,24 @@
<script setup lang="ts"> <script setup lang="ts">
useHead({
htmlAttrs: {
lang: "en",
},
link: [
{
rel: "icon",
type: "image/png",
href: "/favicon.png",
},
],
});
const { params } = useRoute(); const { params } = useRoute();
const routeParam = params.id; const routeParam = params.id;
const id = const id =
typeof routeParam === "string" ? Number(routeParam) : Number(routeParam[0]); typeof routeParam === "string" ? Number(routeParam) : Number(routeParam[0]);
const { data: recipe, pending, error } = await useRecipeById(id); const { data: recipe, status, error } = await useRecipeById(id);
if (error.value) { if (error.value) {
let statusCode = 400; let statusCode = 400;
@ -22,10 +35,23 @@ if (error.value) {
message: error.value.message, message: error.value.message,
}); });
} }
const url = useRequestURL();
useSeoMeta({
title: `${recipe.value!.title} | Mood2Food`,
description: "The perfect meal that fits your mood",
ogTitle: `${recipe.value!.title} | Mood2Food`,
ogDescription: "The perfect meal that fits your mood",
ogImage: recipe.value!.pictureUrl,
ogUrl: url.href,
twitterTitle: `${recipe.value!.title} | Mood2Food`,
twitterDescription: "The perfect meal that fits your mood",
twitterImage: recipe.value!.pictureUrl,
twitterCard: "summary",
});
</script> </script>
<template> <template>
<div v-if="pending">Loading</div> <div v-if="status !== 'success'">Loading</div>
<section v-else> <section v-else>
<Recipe :recipe="recipe!" /> <Recipe :recipe="recipe!" />
</section> </section>

View file

@ -14,5 +14,6 @@ export default {
plugins: [require("@tailwindcss/typography"), require("daisyui")], plugins: [require("@tailwindcss/typography"), require("daisyui")],
daisyui: { daisyui: {
themes: ["cupcake"], themes: ["cupcake"],
logs: false,
}, },
}; };

View file

@ -1,6 +0,0 @@
import { z } from "zod";
export const idSchema = z.string({
required_error: "recipe id is required",
invalid_type_error: "recipe id must be a number",
});