Skip to content

Commit 3a4af9f

Browse files
committed
update example
1 parent 44f9414 commit 3a4af9f

31 files changed

+762
-264
lines changed

.editorconfig

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
root = true
2+
3+
[*]
4+
tab_width = 2
5+
indent_size = 2
6+
charset = utf-8
7+
end_of_line = lf
8+
indent_style = space
9+
insert_final_newline = true
10+
trim_trailing_whitespace = true
11+
12+
[Makefile]
13+
indent_style = tab

.prettierignore

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
*.d.ts
2+
.DS_Store
3+
.editorconfig
4+
.git
5+
.github
6+
.gitignore
7+
.idea/*
8+
.jest-cache
9+
.jest-coverage
10+
.next
11+
.npmrc
12+
.nvmrc
13+
.out
14+
.prettierignore
15+
.vscode/*
16+
build
17+
dist
18+
lib
19+
node_modules
20+
package.json
21+
out

.prettierrc

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"arrowParens": "always",
3+
"jsxSingleQuote": false,
4+
"printWidth": 120,
5+
"semi": true,
6+
"singleQuote": true,
7+
"tabWidth": 2,
8+
"trailingComma": "es5"
9+
}

.yarnrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
save-prefix ""

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# my-next.js-starter
2+
23
`npx create-next-app --example with-typescript my-next.js-starter`
34

45
# TypeScript Next.js example

components/List.tsx

-19
This file was deleted.

components/ListDetail.tsx

-16
This file was deleted.

components/ListItem.tsx

-18
This file was deleted.

interfaces/index.ts

-10
This file was deleted.

package.json

+24-8
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,37 @@
11
{
2-
"name": "with-typescript",
2+
"name": "my-next.js-starter",
33
"version": "1.0.0",
4+
"husky": {
5+
"hooks": {
6+
"pre-commit": "pretty-quick --staged",
7+
"post-commit": "git update-index -g"
8+
}
9+
},
410
"scripts": {
511
"dev": "next",
612
"build": "next build",
713
"start": "next start",
8-
"type-check": "tsc"
14+
"---------- Linting ----------------------------------------------------": "",
15+
"prettier": "npx prettier --write \"./**/*.{ts,tsx,js,jsx,json,md}\"",
16+
"---------- helper commands --------------------------------------------": "",
17+
"serve": "http-server ./out",
18+
"ts": "tsc --noEmit",
19+
"ts:watch": "npm run ts -- --watch",
20+
"-----------------------------------------------------------------------": ""
921
},
1022
"dependencies": {
11-
"next": "latest",
12-
"react": "^17.0.1",
13-
"react-dom": "^17.0.1"
23+
"next": "10.0.2",
24+
"react": "17.0.1",
25+
"react-dom": "17.0.1"
1426
},
1527
"devDependencies": {
16-
"@types/node": "^14.14.9",
17-
"@types/react": "^17.0.0",
18-
"@types/react-dom": "^17.0.0",
28+
"@types/node": "14.14.9",
29+
"@types/react": "17.0.0",
30+
"@types/react-dom": "17.0.0",
31+
"http-server": "0.12.3",
32+
"husky": "4.3.0",
33+
"prettier": "2.1.2",
34+
"pretty-quick": "3.1.0",
1935
"typescript": "4.1.2"
2036
},
2137
"license": "MIT"

pages/about.tsx

-16
This file was deleted.

pages/api/users/index.ts

-16
This file was deleted.

pages/index.tsx

-15
This file was deleted.

pages/users/[id].tsx

-61
This file was deleted.

pages/users/index.tsx

-37
This file was deleted.

src/components/List.tsx

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import React from 'react';
2+
import { ListItem } from './ListItem';
3+
import { IUser } from '../domains/users/users.constants';
4+
5+
interface IProps {
6+
users: IUser[];
7+
}
8+
9+
export const List: React.FC<IProps> = (props) => (
10+
<ul>
11+
{props.users.map((user) => (
12+
<li key={user.id}>
13+
<ListItem user={user} />
14+
</li>
15+
))}
16+
</ul>
17+
);

src/components/ListDetail.tsx

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import React from 'react';
2+
import { IUser } from '../domains/users/users.constants';
3+
4+
interface IProps {
5+
user: IUser;
6+
}
7+
8+
export const ListDetail: React.FC<IProps> = (props) => (
9+
<div>
10+
<h1>Detail for {props.user.name}</h1>
11+
<p>ID: {props.user.id}</p>
12+
</div>
13+
);

src/components/ListItem.tsx

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import React from 'react';
2+
import Link from 'next/link';
3+
import { IUser } from '../domains/users/users.constants';
4+
5+
interface IProps {
6+
user: IUser;
7+
}
8+
9+
export const ListItem: React.FC<IProps> = (props) => (
10+
<Link href={`/users/${props.user.id}`}>
11+
<a>
12+
{props.user.id}: {props.user.name}
13+
</a>
14+
</Link>
15+
);

src/components/pages/AboutPage.tsx

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import React from 'react';
2+
import Link from 'next/link';
3+
4+
interface IProps {}
5+
6+
export const AboutPage: React.FC<IProps> = (props) => (
7+
<div>
8+
<h1>About</h1>
9+
<p>This is the about page</p>
10+
<p>
11+
<Link href="/">
12+
<a>Go home</a>
13+
</Link>
14+
</p>
15+
</div>
16+
);

src/components/pages/IndexPage.tsx

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import React from 'react';
2+
import Link from 'next/link';
3+
import { Routes } from '../../constants/Routes';
4+
5+
interface IProps {}
6+
7+
export const IndexPage: React.FC<IProps> = (props) => (
8+
<div>
9+
<h1>Hello Next.js 👋</h1>
10+
<p>
11+
<Link href={Routes.About}>
12+
<a>About</a>
13+
</Link>
14+
</p>
15+
</div>
16+
);

0 commit comments

Comments
 (0)