├── typings └── global.d.ts ├── .eslintignore ├── src ├── components │ ├── common │ │ ├── index.tsx │ │ └── Title.tsx │ ├── Header │ │ ├── types.ts │ │ ├── index.stories.tsx │ │ ├── __fixtures__ │ │ │ └── menuItem.json │ │ ├── index.tsx │ │ ├── NavMenu.tsx │ │ └── __snapshots__ │ │ │ └── index.stories.storyshot │ ├── Footer │ │ ├── index.stories.tsx │ │ ├── index.tsx │ │ └── __snapshots__ │ │ │ └── index.stories.storyshot │ ├── User │ │ ├── index.tsx │ │ └── Profile.tsx │ ├── Article │ │ ├── index.tsx │ │ └── ArticleCard.tsx │ ├── Layout │ │ └── index.tsx │ ├── Error │ │ └── index.tsx │ └── Link │ │ └── index.tsx ├── types │ ├── articles.ts │ └── user.ts ├── utils │ ├── url.ts │ ├── __tests__ │ │ └── url.test.ts │ └── request.ts ├── store │ ├── rootSagas.ts │ ├── rootReducers.ts │ ├── user │ │ ├── types.ts │ │ ├── saga.ts │ │ └── index.ts │ └── index.ts ├── api │ ├── articles.ts │ └── user.ts ├── styles │ └── GlobalBaseStyle.ts ├── containers │ └── ArticleContainer.tsx ├── i18n │ ├── index.ts │ └── locales │ │ ├── zh_CN.json │ │ └── en_US.json └── tests │ └── storyshot.test.ts ├── .storybook ├── storybook.css ├── preview.ts └── main.ts ├── .commitlintrc.js ├── next-env.d.ts ├── public ├── favicon.ico └── vercel.svg ├── .travis.yml ├── pages ├── 404.tsx ├── user.tsx ├── _app.tsx ├── _document.tsx ├── articles.tsx └── index.tsx ├── next.config.js ├── .prettierignore ├── .editorconfig ├── .prettierrc ├── .stylelintrc ├── .vscode └── settings.json ├── .gitignore ├── tsconfig.json ├── jest.config.js ├── LICENSE ├── babel.config.js ├── README_CN.md ├── .eslintrc.js ├── README.md ├── CHANGELOG.md └── package.json /typings/global.d.ts: -------------------------------------------------------------------------------- 1 | type Errors = string[] 2 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /public 3 | /dist 4 | /.next 5 | /coverage 6 | -------------------------------------------------------------------------------- /src/components/common/index.tsx: -------------------------------------------------------------------------------- 1 | export { default as Title } from './Title' 2 | -------------------------------------------------------------------------------- /.storybook/storybook.css: -------------------------------------------------------------------------------- 1 | .sb-show-main { 2 | padding: 0 !important; 3 | } 4 | -------------------------------------------------------------------------------- /.commitlintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: ['@commitlint/config-conventional'], 3 | } 4 | -------------------------------------------------------------------------------- /next-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jacky-Summer/nextjs-ts-antd-redux-storybook-starter/HEAD/public/favicon.ico -------------------------------------------------------------------------------- /src/types/articles.ts: -------------------------------------------------------------------------------- 1 | export interface IArticleInfo { 2 | id: number 3 | title: string 4 | body: string 5 | userId?: number 6 | } 7 | -------------------------------------------------------------------------------- /src/components/Header/types.ts: -------------------------------------------------------------------------------- 1 | export interface IMenuItem { 2 | key: string 3 | title: string 4 | desc: string 5 | pathname: string 6 | } 7 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | 3 | node_js: 4 | - 16.7.0 5 | 6 | install: 7 | - npm install -g pnpm@6 8 | - pnpm i 9 | script: 10 | - pnpm run test 11 | - pnpm run build 12 | -------------------------------------------------------------------------------- /src/utils/url.ts: -------------------------------------------------------------------------------- 1 | import { LinkProps } from 'next/link' 2 | 3 | export const isExternalLink = (href?: LinkProps['href']): boolean => 4 | !href || (typeof href === 'string' && /^(https?:)?\/\//.test(href)) 5 | -------------------------------------------------------------------------------- /src/store/rootSagas.ts: -------------------------------------------------------------------------------- 1 | import { all, fork } from 'redux-saga/effects' 2 | import userSaga from './user/saga' 3 | 4 | function* rootSaga() { 5 | yield all([fork(userSaga)]) 6 | } 7 | 8 | export default rootSaga 9 | -------------------------------------------------------------------------------- /src/components/common/Title.tsx: -------------------------------------------------------------------------------- 1 | import styled from 'styled-components' 2 | 3 | const Title = styled.h2` 4 | margin-top: 25px; 5 | margin-bottom: 15px; 6 | font-size: 30px; 7 | ` 8 | 9 | export default Title 10 | -------------------------------------------------------------------------------- /src/store/rootReducers.ts: -------------------------------------------------------------------------------- 1 | import { combineReducers } from '@reduxjs/toolkit' 2 | import { userReducer } from 'src/store/user' 3 | 4 | const rootReducer = combineReducers({ 5 | user: userReducer, 6 | }) 7 | 8 | export default rootReducer 9 | -------------------------------------------------------------------------------- /pages/404.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import { NextPage } from 'next' 3 | import Error from 'src/components/Error' 4 | 5 | const Error404Page: NextPage = () => 6 | 7 | export default Error404Page 8 | -------------------------------------------------------------------------------- /src/api/articles.ts: -------------------------------------------------------------------------------- 1 | import { AxiosResponse } from 'axios' 2 | import request from 'src/utils/request' 3 | import { IArticleInfo } from 'src/types/articles' 4 | 5 | export const getArticles = (): Promise> => request.get(`/posts`) 6 | -------------------------------------------------------------------------------- /next.config.js: -------------------------------------------------------------------------------- 1 | const withBundleAnalyzer = require('@next/bundle-analyzer')({ 2 | enabled: process.env.ANALYZE === 'true', 3 | }) 4 | 5 | const nextConfig = { 6 | // any configs you need 7 | } 8 | 9 | module.exports = withBundleAnalyzer(nextConfig) 10 | -------------------------------------------------------------------------------- /src/api/user.ts: -------------------------------------------------------------------------------- 1 | import { AxiosResponse } from 'axios' 2 | import request from 'src/utils/request' 3 | import { IProfile } from 'src/types/user' 4 | 5 | export const getProfileApi = (id: number): Promise> => 6 | request.get(`/users/${id}`) 7 | -------------------------------------------------------------------------------- /src/components/Footer/index.stories.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import Footer from '.' 3 | 4 | export default { 5 | title: 'Example/Footer', 6 | component: Footer, 7 | } 8 | 9 | const Template = () =>