Skip to content

Commit d3a1a02

Browse files
committed
Código de la clase del 8 de Junio
1 parent c6f65b2 commit d3a1a02

33 files changed

+6786
-0
lines changed

2023-06-08/next1/.eslintrc.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "next/core-web-vitals"
3+
}

2023-06-08/next1/.gitignore

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# next.js
12+
/.next/
13+
/out/
14+
15+
# production
16+
/build
17+
18+
# misc
19+
.DS_Store
20+
*.pem
21+
22+
# debug
23+
npm-debug.log*
24+
yarn-debug.log*
25+
yarn-error.log*
26+
27+
# local env files
28+
.env*.local
29+
30+
# vercel
31+
.vercel
32+
33+
# typescript
34+
*.tsbuildinfo
35+
next-env.d.ts

2023-06-08/next1/README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
2+
3+
## Getting Started
4+
5+
First, run the development server:
6+
7+
```bash
8+
npm run dev
9+
# or
10+
yarn dev
11+
# or
12+
pnpm dev
13+
```
14+
15+
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
16+
17+
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
18+
19+
This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font.
20+
21+
## Learn More
22+
23+
To learn more about Next.js, take a look at the following resources:
24+
25+
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
26+
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
27+
28+
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
29+
30+
## Deploy on Vercel
31+
32+
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
33+
34+
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
export default function Page() {
3+
return <div className="text-4xl">Alpha</div>
4+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function Page() {
2+
return <div className="text-4xl">Beta</div>
3+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import Link from "next/link";
2+
3+
type Props = {
4+
children: React.ReactNode;
5+
};
6+
export default function Layout({ children }: Props) {
7+
return (
8+
<div className="min-h-screen flex flex-row items-stretch">
9+
<div className="bg-blue-200 w-20 flex flex-col">
10+
<Link href="/alpha">Alpha</Link>
11+
<Link href="/beta">Beta</Link>
12+
</div>
13+
{children}
14+
</div>
15+
);
16+
}

2023-06-08/next1/app/api/route.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { NextRequest, NextResponse } from "next/server";
2+
3+
export async function POST(request: NextRequest) {
4+
console.log(await request.json());
5+
return NextResponse.json({ ok: true });
6+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import Beer from "@/components/Beer";
2+
3+
type Beer = Record<string, any>;
4+
5+
const getBeerById = async (id: string): Promise<Beer> => {
6+
console.log("getBeerById", id);
7+
const response = await fetch(`https://api.punkapi.com/v2/beers/${id}`);
8+
const [beer] = await response.json();
9+
return beer;
10+
};
11+
12+
13+
type Props = {
14+
params: {
15+
beerId: string,
16+
}
17+
}
18+
export default async function Page({ params }: Props) {
19+
const { beerId } = params;
20+
const beer = await getBeerById(beerId);
21+
return <Beer beer={beer} />
22+
}
23+
24+
export async function generateStaticParams() {
25+
const params = [];
26+
for (let i = 1; i <= 10; i++) {
27+
params.push({ beerId: String(i) });
28+
}
29+
return params;
30+
}

2023-06-08/next1/app/beers/page.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import Link from "next/link";
2+
3+
type Beer = Record<string, any>;
4+
5+
const loadBeers = async (): Promise<Array<Beer>> => {
6+
const response = await fetch(`https://api.punkapi.com/v2/beers`);
7+
const beers = await response.json();
8+
return beers;
9+
};
10+
11+
export default async function Page() {
12+
const beers = await loadBeers();
13+
return (
14+
<div className="flex flex-col">
15+
{beers.map((beer) => (
16+
<Link key={beer.id} href={`/beers/${beer.id}`}>{beer.name}</Link>
17+
))}
18+
</div>
19+
);
20+
}

2023-06-08/next1/app/favicon.ico

25.3 KB
Binary file not shown.

0 commit comments

Comments
 (0)