Skip to content

Commit 5e94f23

Browse files
authored
Merge pull request #176 from relative-ci/app-router
refactor: Migrate to app router
2 parents 42c5dfe + 98c72e5 commit 5e94f23

File tree

15 files changed

+138
-55
lines changed

15 files changed

+138
-55
lines changed

next-env.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/// <reference types="next" />
2+
/// <reference types="next/image-types/global" />
3+
/// <reference types="next/navigation-types/compat/navigation" />
4+
/// <reference path="./.next/types/routes.d.ts" />
5+
6+
// NOTE: This file should not be edited
7+
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.

package-lock.json

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@
1414
"license": "ISC",
1515
"devDependencies": {
1616
"@relative-ci/webpack-plugin": "5.1.0",
17+
"@types/node": "24.9.1",
1718
"eslint": "8.57.0",
1819
"eslint-config-next": "15.5.6"
1920
},
2021
"dependencies": {
21-
"@ant-design/cssinjs": "1.24.0",
2222
"@ant-design/compatible": "5.1.4",
23+
"@ant-design/cssinjs": "1.24.0",
2324
"@ant-design/icons": "5.3.7",
2425
"@ant-design/pro-components": "2.8.10",
2526
"antd": "5.27.6",

src/app/about/page.jsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"use client"
2+
3+
import { PageHeader } from '../../layout/page-header';
4+
import { Main } from '../../layout/main';
5+
import { About } from '../../components/about';
6+
7+
export default function AboutPage() {
8+
return (
9+
<>
10+
<PageHeader title="About" />
11+
<Main>
12+
<About />
13+
</Main>
14+
</>
15+
);
16+
}

src/app/layout.jsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import 'antd/dist/reset.css';
2+
3+
import { Layout } from '../layout';
4+
5+
export const metadata = {
6+
title: 'Next.js',
7+
description: 'Generated by Next.js',
8+
}
9+
10+
export default function RootLayout({ children }) {
11+
return (
12+
<html lang="en">
13+
<body>
14+
<Layout>
15+
{children}
16+
</Layout>
17+
</body>
18+
</html>
19+
)
20+
}

src/pages/not-found.jsx renamed to src/app/not-found.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
1-
import React from 'react';
2-
import { useRouter } from 'next/router';
1+
"use client"
32

43
import { PageHeader } from '../layout/page-header';
54
import { Main } from '../layout/main';
65
import { NotFound } from '../components/not-found';
76

87
export default function NotFoundPage() {
9-
const router = useRouter();
10-
118
return (
129
<>
1310
<PageHeader title="Not found" />
1411
<Main>
15-
<NotFound location={router.pathname} />
12+
<NotFound />
1613
</Main>
1714
</>
1815
);

src/pages/index.jsx renamed to src/app/page.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import React from 'react';
1+
"use client"
2+
23
import Link from 'next/link';
34
import { Divider } from 'antd';
45

src/pages/repos/[owner]/[repo].jsx renamed to src/app/repos/[owner]/[repo]/page.jsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import React from 'react';
1+
"use client"
2+
23
import { useRouter } from 'next/router';
34

4-
import { PageHeader } from '../../../layout/page-header';
5-
import { Main } from '../../../layout/main';
6-
import { RepoDetails } from '../../../components/repo-details';
5+
import { PageHeader } from '../../../../layout/page-header';
6+
import { Main } from '../../../../layout/main';
7+
import { RepoDetails } from '../../../../components/repo-details';
78

89
export default function RepoDetailsPage(all) {
910
const router = useRouter();

src/app/repos/page.jsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"use client"
2+
3+
import { PageHeader } from '@/layout/page-header';
4+
import { Main } from '@/layout/main';
5+
import { RepoList } from '@/components/repo-list';
6+
7+
export default function ReposPage() {
8+
return (
9+
<>
10+
<PageHeader title="Examples" />
11+
<Main>
12+
<RepoList />
13+
</Main>
14+
</>
15+
);
16+
}

src/components/not-found.jsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1+
"use client";
2+
13
import React from 'react';
24
import Link from 'next/link';
5+
import { usePathname } from 'next/navigation';
36
import { Typography } from 'antd';
47

5-
export function NotFound({ location }) {
8+
export function NotFound() {
9+
const pathname = usePathname();
10+
611
return (
712
<div>
813
<Typography.Paragraph>
9-
<code>{location}</code>
14+
<code>{pathname}</code>
1015
{' '}
1116
does not exit.
1217
</Typography.Paragraph>

0 commit comments

Comments
 (0)