mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
## Description This PR ensures that the default prettier config is used for examples and templates. This config is compatible with `prettier@3` as well (upgrading prettier is bigger change that can be a future PR). ## Changes - Updated `.prettierrc.json` in root with `"trailingComma": "es5"` (will be needed upgrading to prettier@3) - Added `examples/.prettierrc.json` with default config (this will change every example) - Added `packages/create-next-app/templates/.prettierrc.json` with default config (this will change every template) ## Related - Fixes #54402 - Closes #54409
47 lines
1.3 KiB
JavaScript
47 lines
1.3 KiB
JavaScript
import Head from "next/head";
|
|
import Product from "../components/Product";
|
|
import prisma from "../lib/prisma";
|
|
|
|
export default function Home({ products }) {
|
|
return (
|
|
<div>
|
|
<Head>
|
|
<title>PlanetScale Next.js Quickstart</title>
|
|
<meta name="description" content="PlanetScale Quickstart for Next.js" />
|
|
<link rel="icon" href="/favicon.ico" />
|
|
</Head>
|
|
|
|
<main className="p-10 mx-auto max-w-4xl">
|
|
<h1 className="text-6xl font-bold mb-4 text-center">Next.js Starter</h1>
|
|
<p className="mb-20 text-xl text-center">
|
|
🔥 Shop from the hottest items in the world 🔥
|
|
</p>
|
|
<div className="grid md:grid-cols-3 sm:grid-cols-2 grid-cols-1 justify-items-center gap-4">
|
|
{products.map((product) => (
|
|
<Product product={product} key={product.id} />
|
|
))}
|
|
</div>
|
|
</main>
|
|
|
|
<footer></footer>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export async function getStaticProps(context) {
|
|
const data = await prisma.product.findMany({
|
|
include: {
|
|
category: true,
|
|
},
|
|
});
|
|
|
|
//convert decimal value to string to pass through as json
|
|
const products = data.map((product) => ({
|
|
...product,
|
|
price: product.price.toString(),
|
|
}));
|
|
return {
|
|
props: { products },
|
|
};
|
|
}
|