= ({
15 | href,
16 | title,
17 | target,
18 | onClick,
19 | className,
20 | children,
21 | ...restProps
22 | }) => {
23 | const openInNewTab = target === '_blank'
24 | const isExternal = isExternalLink(href)
25 | const rel = openInNewTab ? 'noreferrer noopener' : undefined
26 |
27 | const handleClick = (e: MouseEvent) => {
28 | onClick?.(e)
29 | }
30 |
31 | if (isExternal || openInNewTab) {
32 | return (
33 |
41 | {children}
42 |
43 | )
44 | }
45 |
46 | return (
47 |
48 | {children}
49 |
50 | )
51 | }
52 |
53 | export default NextLink
54 |
--------------------------------------------------------------------------------
/README_CN.md:
--------------------------------------------------------------------------------
1 |
2 | Nextjs-TS-Antd-Redux-Storybook-Jest-Starter
3 |
4 |
5 |
6 | 一个快速构建 Next.js 项目的脚手架
7 |
8 |
9 |
10 |
11 | [](https://travis-ci.com/Jacky-Summer/nextjs-ts-antd-redux-storybook-starter) [](https://github.com/facebook/jest) [](https://github.com/prettier/prettier) 
12 |
13 |
14 |
15 |
18 |
19 | ## 状态
20 |
21 | 🚧 维护中...
22 |
23 | ## 技术栈
24 |
25 | - [Next.js 10.x](https://nextjs.org/)
26 | - [React 17.x](https://reactjs.org/)
27 | - [TypeScript 4.x](https://www.typescriptlang.org/)
28 | - [Ant Design 4.9](https://ant.design/index-cn)
29 | - [Styled-components 5.x](https://styled-components.com/)
30 | - [Storybook 6.x](https://storybook.js.org/)
31 | - [Redux Toolkit 1.8](https://redux-toolkit.js.org/)
32 | - [Redux-saga 1.x](https://redux-saga.js.org/)
33 | - [Jest 26.x](https://styled-components.com/)
34 |
35 | ## 使用
36 |
37 | ↗️ **点击该仓库右上角 "Use this template" 按钮**
38 |
39 | ```
40 | pnpm i
41 | pnpm dev
42 | ```
43 |
44 | ## 重大升级
45 |
46 | ### v1.0.0 -> v1.1.0(2022.08)
47 |
48 | - 从 `yarn` 迁移为 `pnpm`
49 | - 使用 `@redux/toolkit` 重构 `redux` 库的繁琐写法
50 | - 重构文件结构与文件命名、接口命名等
51 | - 弃用 `enzyme` 测试库
52 |
53 | ## 开源协议
54 |
55 | 版权 (c) 2020-至今 归 JackySummer 所有. 详情请阅 [LICENSE](./LICENSE).
56 |
--------------------------------------------------------------------------------
/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | env: {
3 | browser: true,
4 | es2021: true,
5 | node: true,
6 | },
7 | extends: [
8 | 'airbnb',
9 | 'prettier',
10 | 'plugin:react/recommended',
11 | 'plugin:import/typescript',
12 | 'plugin:@typescript-eslint/recommended',
13 | 'plugin:jest/recommended',
14 | 'prettier/react',
15 | ],
16 | settings: {
17 | 'import/resolver': {
18 | node: {
19 | extensions: ['.tsx', '.ts', '.js', '.json'],
20 | },
21 | alias: [
22 | ['src', './src'],
23 | ['server', './server'],
24 | ],
25 | },
26 | },
27 | parser: '@typescript-eslint/parser',
28 | parserOptions: {
29 | ecmaFeatures: {
30 | jsx: true,
31 | },
32 | ecmaVersion: 12,
33 | sourceType: 'module',
34 | },
35 | plugins: ['react', '@typescript-eslint', 'react-hooks', 'unicorn', 'jest'],
36 | rules: {
37 | semi: 0,
38 | indent: 0,
39 | 'react/jsx-filename-extension': 0,
40 | 'react/prop-types': 0,
41 | 'react/jsx-props-no-spreading': 0,
42 | 'react/require-default-props': 0,
43 |
44 | 'jsx-a11y/click-events-have-key-events': 0,
45 | 'jsx-a11y/no-static-element-interactions': 0,
46 | 'jsx-a11y/no-noninteractive-element-interactions': 0,
47 | 'jsx-a11y/anchor-is-valid': 0,
48 |
49 | 'no-use-before-define': 0,
50 | 'no-unused-vars': 0,
51 | 'no-param-reassign': 0,
52 | 'implicit-arrow-linebreak': 0,
53 | 'consistent-return': 0,
54 | 'arrow-parens': 0,
55 | 'object-curly-newline': 0,
56 | 'operator-linebreak': 0,
57 | 'import/no-extraneous-dependencies': 0,
58 | 'import/extensions': 0,
59 | 'import/no-unresolved': 0,
60 | 'import/prefer-default-export': 0,
61 |
62 | '@typescript-eslint/ban-ts-comment': 0,
63 | '@typescript-eslint/no-var-requires': 0,
64 | '@typescript-eslint/explicit-module-boundary-types': 0,
65 | },
66 | }
67 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | Nextjs-TS-Antd-Redux-Storybook-Jest-Starter
3 |
4 |
5 |
6 | A starter project for Next.js applications for faster build
7 |
8 |
9 |
10 |
11 | [](https://travis-ci.com/Jacky-Summer/nextjs-ts-antd-redux-storybook-starter) [](https://github.com/facebook/jest) [](https://github.com/prettier/prettier) 
12 |
13 |
14 |
15 |
18 |
19 | ## Status
20 |
21 | 🚧 Maintaining...
22 |
23 | ## Tech Stack
24 |
25 | - [Next.js 10.x](https://nextjs.org/)
26 | - [React 17.x](https://reactjs.org/)
27 | - [TypeScript 4.x](https://www.typescriptlang.org/)
28 | - [Ant Design 4.9](https://ant.design/index-cn)
29 | - [Styled-components 5.x](https://styled-components.com/)
30 | - [Storybook 6.x](https://storybook.js.org/)
31 | - [Redux Toolkit 1.8](https://redux-toolkit.js.org/)
32 | - [Redux-saga 1.x](https://redux-saga.js.org/)
33 | - [Jest 26.x](https://styled-components.com/)
34 |
35 | ## Usage
36 |
37 | ↗️ **Click the green "Use this template" button in the top right corner.**
38 |
39 | ```
40 | pnpm i
41 | pnpm dev
42 | ```
43 |
44 | ## Major Upgrade
45 |
46 | ### v1.0.0 -> v1.1.0(2022.08)
47 |
48 | - migrate `yarn` to `pnpm`
49 | - replace `redux` with `@redux/toolkit`
50 | - refactor folder structure and rename variable
51 | - deprecate `enzyme` test library
52 |
53 | ## License
54 |
55 | Copyright (c) 2020-present JackySummer. See [LICENSE](./LICENSE) for details.
56 |
--------------------------------------------------------------------------------
/src/components/Footer/__snapshots__/index.stories.storyshot:
--------------------------------------------------------------------------------
1 | // Jest Snapshot v1, https://goo.gl/fbAQLP
2 |
3 | exports[`Storyshots Example/Footer Default 1`] = `
4 | .c0 {
5 | position: absolute;
6 | bottom: 0;
7 | display: -webkit-box;
8 | display: -webkit-flex;
9 | display: -ms-flexbox;
10 | display: flex;
11 | -webkit-box-pack: center;
12 | -webkit-justify-content: center;
13 | -ms-flex-pack: center;
14 | justify-content: center;
15 | -webkit-align-items: center;
16 | -webkit-box-align: center;
17 | -ms-flex-align: center;
18 | align-items: center;
19 | width: 100%;
20 | height: 70px;
21 | color: #6c757d;
22 | background: #e9ecef;
23 | font-size: 16px;
24 | text-align: center;
25 | }
26 |
27 | .c1 {
28 | margin-left: 6px;
29 | color: #000;
30 | }
31 |
32 |
68 | `;
69 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4 |
5 | ## [1.1.0](https://github.com/Jacky-Summer/nextjs-ts-antd-redux-storybook-starter/compare/v1.0.0...v1.1.0) (2022-08-28)
6 |
7 | ### Features
8 |
9 | - deprecate enzyme test library ([0ed816f](https://github.com/Jacky-Summer/nextjs-ts-antd-redux-storybook-starter/commit/0ed816f8d7cb30a3dd72f870e0b11f10b2382a0b))
10 | - migrate to pnpm ([3362dc2](https://github.com/Jacky-Summer/nextjs-ts-antd-redux-storybook-starter/commit/3362dc27cabf128b425d493f3bde27b0f1ba0cab))
11 |
12 | ### [1.0.0](https://github.com/Jacky-Summer/nextjs-ts-antd-redux-storybook-starter/compare/v0.1.0...v1.0.0) (2021-01-31)
13 |
14 | ### Features
15 |
16 | - ✨ add 404 page ([832beb5](https://github.com/Jacky-Summer/nextjs-ts-antd-redux-storybook-starter/commit/832beb531b052ba3f092945a8fad1f16d11840d5))
17 | - add nextjs bundle analyzer ([acc1bdb](https://github.com/Jacky-Summer/nextjs-ts-antd-redux-storybook-starter/commit/acc1bdb1f4bd03eb6fd71d7cb9fa4a20464e8f12))
18 |
19 | ### 0.1.1 (2020-12-24)
20 |
21 | ### Features
22 |
23 | - ✨ add ant design support ([32367fb](https://github.com/Jacky-Summer/nextjs-ts-antd-redux-storybook-starter/commit/32367fbaf777ac200956d626a9cf6d007f82b3ab))
24 | - ✨ add footer layout ([06fa6c5](https://github.com/Jacky-Summer/nextjs-ts-antd-redux-storybook-starter/commit/06fa6c5eca0d8de243d0b9276791a67ab6c5aa15))
25 | - ✨ add Link component ([4fddf4e](https://github.com/Jacky-Summer/nextjs-ts-antd-redux-storybook-starter/commit/4fddf4e60104ee079cb34af5bedc094c4a9ce810))
26 | - ✨ add redux and redux-saga support ([8ea49cc](https://github.com/Jacky-Summer/nextjs-ts-antd-redux-storybook-starter/commit/8ea49cc21fb39eca7248c39c63559b5ffda9bfca))
27 | - ✨ add redux example - show user data demo ([ab97271](https://github.com/Jacky-Summer/nextjs-ts-antd-redux-storybook-starter/commit/ab972717abe0283e09df778431ef7ce7ed260c21))
28 | - ✨ add storybook support ([de5b127](https://github.com/Jacky-Summer/nextjs-ts-antd-redux-storybook-starter/commit/de5b127ca0d6012295e4752aa61f9a5b6accd55b))
29 | - ✨ add styled-components support ([e216894](https://github.com/Jacky-Summer/nextjs-ts-antd-redux-storybook-starter/commit/e216894300a874d2875711c1976da3cc023b48af))
30 | - ✨ article list page ([0f308f8](https://github.com/Jacky-Summer/nextjs-ts-antd-redux-storybook-starter/commit/0f308f85a8fbdb66dbb60384cd4516dab03ac68b))
31 | - ✨ complete Header component layout ([1ba67d7](https://github.com/Jacky-Summer/nextjs-ts-antd-redux-storybook-starter/commit/1ba67d75d1ca899cbd15d8be89f5bb5961583ee2))
32 | - ✨ complete Home page layout ([36a225d](https://github.com/Jacky-Summer/nextjs-ts-antd-redux-storybook-starter/commit/36a225dc9fafb87cacf75b13793c280ff13e90db))
33 | - ✨ handle Link component external link ([c9d8ea2](https://github.com/Jacky-Summer/nextjs-ts-antd-redux-storybook-starter/commit/c9d8ea24c1c6360a02e63d0f2cd0b1e2e2e3127b))
34 | - ✨ jest and enzyme support ([2a3900a](https://github.com/Jacky-Summer/nextjs-ts-antd-redux-storybook-starter/commit/2a3900ae049d71daadd8c46ac8b88923655c440b))
35 | - ✨ page base layout and init style ([de07fa5](https://github.com/Jacky-Summer/nextjs-ts-antd-redux-storybook-starter/commit/de07fa5831f1371033e5f2e6e0c91db5679819b5))
36 | - ✨ support internationalization ([bd2feb6](https://github.com/Jacky-Summer/nextjs-ts-antd-redux-storybook-starter/commit/bd2feb669e818fb2ad2697efdfa11e82a7dc1b55))
37 | - ✨ user page layout ([bd99db6](https://github.com/Jacky-Summer/nextjs-ts-antd-redux-storybook-starter/commit/bd99db68607efdc86a45d1c15555bbc4fdaf2bf7))
38 |
39 | ### Bug Fixes
40 |
41 | - 🐛 judge href whether url is external ([631eaba](https://github.com/Jacky-Summer/nextjs-ts-antd-redux-storybook-starter/commit/631eaba422db5e3f0ae660d660a2c4d56fd9e190))
42 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "nextjs-ts-antd-redux-storybook-jest-starter",
3 | "version": "1.1.0",
4 | "description": "Next.js + TypeScript Project Starter",
5 | "title": "Next.js Project Template",
6 | "author": "JackySummer",
7 | "keywords": [
8 | "react",
9 | "nextjs",
10 | "nextjs-starter",
11 | "nextjs-template",
12 | "typescript",
13 | "redux",
14 | "redux-saga",
15 | "ant-design",
16 | "styled-components",
17 | "storybook",
18 | "jest"
19 | ],
20 | "repository": {
21 | "type": "git",
22 | "url": "https://github.com/Jacky-Summer/nextjs-ts-antd-redux-storybook-starter"
23 | },
24 | "license": "MIT",
25 | "scripts": {
26 | "dev": "next dev",
27 | "build": "next build",
28 | "start": "next start",
29 | "commit": "git-cz",
30 | "test": "jest",
31 | "coverage": "yarn jest --coverage",
32 | "lint": "yarn lint:eslint && yarn lint:css",
33 | "lint:eslint": "eslint --ext js,jsx,ts,tsx .",
34 | "lint:css": "stylelint **/*.{ts,tsx}",
35 | "prettier": "prettier --write \"**/*.{js,jsx,tsx,ts,less,md,json}\"",
36 | "tsc:client": "tsc --noEmit -p tsconfig.json",
37 | "storybook": "start-storybook -p 6006",
38 | "build-storybook": "build-storybook -o ./dist_storybook",
39 | "analyze": "cross-env ANALYZE=true next build",
40 | "bump-version": "standard-version --skip.commit --skip.tag"
41 | },
42 | "husky": {
43 | "hooks": {
44 | "commit-msg": "commitlint --config .commitlintrc.js -E HUSKY_GIT_PARAMS",
45 | "pre-commit": "lint-staged && yarn tsc",
46 | "pre-push": "yarn test"
47 | }
48 | },
49 | "lint-staged": {
50 | "*.{tsx,ts,js,jsx}": [
51 | "stylelint",
52 | "prettier --write",
53 | "eslint --fix"
54 | ],
55 | "*.{md,json,yaml,yml}": [
56 | "prettier --write"
57 | ]
58 | },
59 | "config": {
60 | "commitizen": {
61 | "path": "./node_modules/cz-conventional-changelog"
62 | }
63 | },
64 | "dependencies": {
65 | "@ant-design/icons": "^4.3.0",
66 | "@reduxjs/toolkit": "1.8.5",
67 | "antd": "4.9.3",
68 | "axios": "^0.21.0",
69 | "i18next": "^19.8.4",
70 | "next": "10.0.3",
71 | "react": "17.0.1",
72 | "react-dom": "17.0.1",
73 | "react-i18next": "^11.8.4",
74 | "react-redux": "^7.2.2",
75 | "redux-saga": "1.2.1",
76 | "styled-components": "^5.2.1",
77 | "styled-normalize": "^8.0.7"
78 | },
79 | "devDependencies": {
80 | "@babel/core": "^7.12.10",
81 | "@commitlint/cli": "^11.0.0",
82 | "@commitlint/config-conventional": "^11.0.0",
83 | "@next/bundle-analyzer": "^10.0.5",
84 | "@storybook/addon-actions": "^6.1.11",
85 | "@storybook/addon-essentials": "^6.1.11",
86 | "@storybook/addon-links": "^6.1.11",
87 | "@storybook/addon-storyshots": "^6.1.11",
88 | "@storybook/react": "^6.1.11",
89 | "@types/jest": "^26.0.19",
90 | "@types/node": "^14.14.11",
91 | "@types/react": "^17.0.0",
92 | "@types/react-dom": "^17.0.0",
93 | "@types/react-redux": "^7.1.12",
94 | "@types/styled-components": "^5.1.5",
95 | "@typescript-eslint/eslint-plugin": "^4.9.1",
96 | "@typescript-eslint/parser": "^4.9.1",
97 | "babel-jest": "^26.6.3",
98 | "babel-loader": "^8.2.2",
99 | "babel-plugin-import": "^1.13.3",
100 | "babel-plugin-styled-components": "^1.12.0",
101 | "cross-env": "^7.0.3",
102 | "cz-conventional-changelog": "^3.3.0",
103 | "eslint": "^7.15.0",
104 | "eslint-config-airbnb": "^18.2.1",
105 | "eslint-config-prettier": "^7.0.0",
106 | "eslint-import-resolver-alias": "^1.1.2",
107 | "eslint-import-resolver-typescript": "^2.3.0",
108 | "eslint-plugin-import": "^2.22.1",
109 | "eslint-plugin-jest": "^24.1.3",
110 | "eslint-plugin-jsx-a11y": "^6.4.1",
111 | "eslint-plugin-react": "^7.21.5",
112 | "eslint-plugin-react-hooks": "^4.2.0",
113 | "eslint-plugin-unicorn": "^23.0.0",
114 | "husky": "^4.3.5",
115 | "identity-obj-proxy": "^3.0.0",
116 | "jest": "^26.6.3",
117 | "jest-specific-snapshot": "^4.0.0",
118 | "jest-styled-components": "7.0.3",
119 | "lint-staged": "^10.5.3",
120 | "prettier": "^2.2.1",
121 | "standard-version": "^9.0.0",
122 | "storybook-addon-next-router": "^2.0.3",
123 | "stylelint": "^13.8.0",
124 | "stylelint-config-prettier": "^8.0.2",
125 | "stylelint-config-standard": "^20.0.0",
126 | "stylelint-config-styled-components": "^0.1.1",
127 | "stylelint-order": "^4.1.0",
128 | "stylelint-processor-styled-components": "^1.10.0",
129 | "typescript": "^4.1.2"
130 | }
131 | }
132 |
--------------------------------------------------------------------------------