-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
686 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,15 @@ | ||
/** @type {import('next').NextConfig} */ | ||
const nextConfig = { | ||
reactStrictMode: true, | ||
reactStrictMode: true, | ||
images: { | ||
remotePatterns: [ | ||
{ | ||
protocol: 'https', | ||
hostname: 'cdn.dummyjson.com', | ||
pathname: '/**', | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
export default nextConfig; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// import { useRouter } from "next/router"; | ||
import Link from "next/link"; | ||
import Image from "next/image"; | ||
|
||
interface Recipe { | ||
id: number; | ||
name: string; | ||
image: string; | ||
} | ||
export default function DynamicRount({ recipe }: { recipe: Recipe }) { | ||
// const router = useRouter(); | ||
// const { id } = router.query; | ||
// console.log(router); | ||
return ( | ||
<div className="container"> | ||
<div className="flex justify-between"> | ||
<h4 className="text-xl font-bold decoration-stone-600"> | ||
This page is about dynamic route | ||
</h4> | ||
<Link href="/">Back</Link> | ||
</div> | ||
<div>Post: {recipe.id}</div> | ||
<div className="flex justify-center"> | ||
<div | ||
className="flex-shrink flex flex-col items-center p-3 xl:mx-5 shadow-lg border rounded-xl" | ||
key={recipe.id} | ||
> | ||
<p className="text-lg font-semibold pb-2">{recipe.name}</p> | ||
<Image | ||
src={recipe.image} | ||
width="300" | ||
height="300" | ||
alt="random image" | ||
className="rounded-xl" | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export async function getStaticProps({ | ||
params, | ||
}: { | ||
params: { id: string | number }; | ||
}) { | ||
const id = params.id; | ||
const res = await fetch(`https://dummyjson.com/recipes/${id}`); | ||
const recipe = await res.json(); | ||
return { props: { recipe } }; | ||
} | ||
|
||
export async function getStaticPaths() { | ||
const url = `https://dummyjson.com/recipes`; | ||
const res = await fetch(url); | ||
const dummy = await res.json(); | ||
const recipes = dummy.recipes; | ||
// console.log(recipes); | ||
// console.log(Array.isArray(recipes)); // Should print true if recipes is an array | ||
|
||
const paths = recipes.map((recipe: Recipe) => { | ||
return { | ||
params: { id: recipe.id.toString() }, | ||
}; | ||
}); | ||
// const paths = recipes.map((recipe: Recipe) => { | ||
// return { | ||
// params: { id: String(recipe.id) }, | ||
// }; | ||
// }); | ||
|
||
return { | ||
paths, | ||
// fallback: true, | ||
fallback: false, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,16 @@ | ||
import "@/styles/globals.css"; | ||
import type { AppProps } from "next/app"; | ||
import Layout from "./layout"; | ||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; | ||
|
||
const queryClient = new QueryClient(); | ||
|
||
export default function App({ Component, pageProps }: AppProps) { | ||
return <Component {...pageProps} />; | ||
return ( | ||
<QueryClientProvider client={queryClient}> | ||
<Layout> | ||
<Component {...pageProps} /> | ||
</Layout> | ||
</QueryClientProvider> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import Link from "next/link"; | ||
import TanStack from "../utils/tanStack"; | ||
export default function Navbar() { | ||
const getRandomInt = (max: number) => { | ||
return Math.floor(Math.random() * max + 1); | ||
}; | ||
const data = TanStack(); | ||
// console.log(data); | ||
return ( | ||
<div className="flex flex-col items-center text-center top-0 left-0 right-0 border-b shadow-lg border-gray-400 mb-5"> | ||
<div className="py-28 bg-yellow-500 w-screen text-slate-100 uppercase"> | ||
<h4 className="text-5xl "> | ||
<Link href={"/"}>Basic App</Link> | ||
</h4> | ||
<p className="text-lg">The way i can do</p> | ||
</div> | ||
<div className="w-screen flex justify-center bg-gray-900"> | ||
<ul className="flex gap-3 text-slate-100 uppercase"> | ||
<li> | ||
<Link className="hover:underline" href="/prop"> | ||
Property | ||
</Link> | ||
</li> | ||
<li> | ||
<Link className="hover:underline" href="/event"> | ||
Event | ||
</Link> | ||
</li> | ||
<li> | ||
<Link className="hover:underline" href={`/${getRandomInt(30)}`}> | ||
Route | ||
</Link> | ||
</li> | ||
<li> | ||
<Link className="hover:underline" href={`dummy-ssr`}> | ||
ssr | ||
</Link> | ||
</li> | ||
<li> | ||
<Link className="hover:underline" href="dummy-ssg"> | ||
ssg | ||
</Link> | ||
</li> | ||
<li> | ||
<Link className="hover:underline" href="dummy-isr"> | ||
isr | ||
</Link> | ||
</li> | ||
<li> | ||
<Link className="hover:underline" href="dummy-csr"> | ||
csr | ||
</Link> | ||
</li> | ||
<li> | ||
<Link className="hover:underline" href="dummy-tan"> | ||
tan | ||
</Link> | ||
</li> | ||
<li> | ||
<Link className="hover:underline" href="dummy-form"> | ||
form | ||
</Link> | ||
</li> | ||
</ul> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.