Skip to content

Commit e07d1f6

Browse files
chore: add next with app router (#3595)
1 parent 1d51c41 commit e07d1f6

File tree

432 files changed

+24262
-68
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

432 files changed

+24262
-68
lines changed

apps/next-app-router/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Dont get excited, it doesnt work.
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+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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+
/.yarn
8+
9+
# testing
10+
/coverage
11+
12+
# next.js
13+
/.next/
14+
/out/
15+
16+
# production
17+
/build
18+
19+
# misc
20+
.DS_Store
21+
*.pem
22+
23+
# debug
24+
npm-debug.log*
25+
yarn-debug.log*
26+
yarn-error.log*
27+
.pnpm-debug.log*
28+
29+
# local env files
30+
.env*
31+
!.env*.example
32+
33+
# vercel
34+
.vercel
35+
36+
# typescript
37+
*.tsbuildinfo
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
save-exact=true
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.next
2+
pnpm-lock.yaml
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export type Category = {
2+
name: string;
3+
slug: string;
4+
count: number;
5+
parent: string | null;
6+
};
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import { notFound } from 'next/navigation';
2+
import type { Category } from './category';
3+
4+
// `server-only` guarantees any modules that import code in file
5+
// will never run on the client. Even though this particular API
6+
// doesn't currently use sensitive environment variables, it's
7+
// good practice to add `server-only` preemptively.
8+
import 'server-only';
9+
10+
export async function getCategories({ parent }: { parent?: string } = {}) {
11+
const res = await fetch(
12+
`https://app-playground-api.vercel.app/api/categories${
13+
parent ? `?parent=${parent}` : ''
14+
}`,
15+
);
16+
17+
if (!res.ok) {
18+
// Render the closest `error.js` Error Boundary
19+
throw new Error('Something went wrong!');
20+
}
21+
22+
const categories = (await res.json()) as Category[];
23+
24+
if (categories.length === 0) {
25+
// Render the closest `not-found.js` Error Boundary
26+
notFound();
27+
}
28+
29+
return categories;
30+
}
31+
32+
export async function getCategory({ slug }: { slug: string }) {
33+
const res = await fetch(
34+
`https://app-playground-api.vercel.app/api/categories${
35+
slug ? `?slug=${slug}` : ''
36+
}`,
37+
);
38+
39+
if (!res.ok) {
40+
// Render the closest `error.js` Error Boundary
41+
throw new Error('Something went wrong!');
42+
}
43+
44+
const category = (await res.json()) as Category;
45+
46+
if (!category) {
47+
// Render the closest `not-found.js` Error Boundary
48+
notFound();
49+
}
50+
51+
return category;
52+
}
Binary file not shown.

0 commit comments

Comments
 (0)