Step 2: The Menu Grid
Part of the Next.js Essentials section of Coddy's React journey — lesson 40 of 47.
Challenge
EasyFill the menu in app/page.jsx.
- Make
Homeasyncandawait getDishes()from../lib/menu.js. - Keep the hero, and after it render a
<ul className="grid">with one<li className="card">per dish (key= the slug). - Each card holds a
<div className="thumb">withid={'thumb-' + dish.slug}, the dish'semojias its content, andstyle={{ background: dish.gradient }}. - Then a
<div className="card-body">containing an<h2 className="card-title">withid={'name-' + dish.slug}and the name, a<p className="card-desc">with the description, and a<span className="price">withid={'price-' + dish.slug}reading$then the price.
Try it yourself
import Link from 'next/link';
import './globals.css';
export const metadata = {
title: {
default: 'Coddy Eats',
template: '%s | Coddy Eats',
},
};
export default function RootLayout({ children }) {
return (
<html lang="en">
<body>
<nav className="nav">
<Link className="brand" href="/">Coddy Eats</Link>
<Link id="nav-menu" href="/">Menu</Link>
<Link id="nav-desserts" href="/?category=dessert">Desserts</Link>
</nav>
<div className="container">
{children}
</div>
</body>
</html>
);
}All lessons in Next.js Essentials
2Routing & Links
Folders Are RoutesNested RoutesLinking PagesDynamic RoutesNot Found PagesRecap: Routing5Data on the Server
Async ComponentsAwaiting Route ParamsTwo Fetches at OnceLoading StatesHandling ErrorsRecap: Data Fetching8Project: Coddy Eats
Step 1: The Shell