recipes.tsx 1009 B

1234567891011121314151617181920212223242526272829303132333435
  1. import Layout from "@/components/Layout";
  2. import { GetStaticProps, InferGetStaticPropsType } from "next";
  3. import { Recipe } from "types/recipes";
  4. import RecipeItem from "components/RecipeItem";
  5. export const getStaticProps = async () => {
  6. const res = await fetch("http://localhost:3000/recipes/all/");
  7. const recipeList: Recipe[] = await res.json();
  8. return {
  9. props: {
  10. recipeList,
  11. },
  12. };
  13. };
  14. const Recipes = ({
  15. recipeList = [],
  16. }: InferGetStaticPropsType<typeof getStaticProps>) => {
  17. return (
  18. <Layout>
  19. <p>
  20. No aliquip repudiare vis, consul deterruisset ne est, nec aliquid
  21. mediocrem argumentum at. Nec malis saepe in. Legere nostrum eu eos, nam
  22. ea facer diceret repudiare. Ad dicta omnes has. Ut tale brute vis, usu
  23. ei solet dolores. Fuisset periculis in has.
  24. </p>
  25. <h1>Recipes</h1>
  26. {recipeList.map((recipe, index) => (
  27. <RecipeItem recipe={recipe} key={index} />
  28. ))}
  29. </Layout>
  30. );
  31. };
  32. export default Recipes;