Skip to content
This repository has been archived by the owner on Jan 7, 2022. It is now read-only.

Commit

Permalink
Merge pull request #483 from Yancey-Blog/feature/upgrade-next-to-11
Browse files Browse the repository at this point in the history
Feature/upgrade next to 11
  • Loading branch information
YanceyOfficial authored Jun 23, 2021
2 parents 887d3f4 + c57e95e commit a6230b8
Show file tree
Hide file tree
Showing 19 changed files with 311 additions and 225 deletions.
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
next-env.d.ts

shims-env.d.ts
ecosystem.config.js
85 changes: 1 addition & 84 deletions next-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,86 +1,3 @@
/// <reference types="next" />
/// <reference types="next/types/global" />

declare module '*.bmp' {
const src: string
export default src
}

declare module '*.gif' {
const src: string
export default src
}

declare module '*.jpg' {
const src: string
export default src
}

declare module '*.jpeg' {
const src: string
export default src
}

declare module '*.png' {
const src: string
export default src
}

declare module '*.svg' {
import { SFC, SVGProps } from 'react'

export const ReactComponent: SFC<SVGProps<SVGSVGElement>>

const src: string
export default src
}

declare module '*.cur' {
const src: string
export default src
}

declare module 'aplayer' {
interface Audio {
name: string
url: string
cover: string
lrc: string
}
interface Props {
container: HTMLElement
lrcType: number
fixed: boolean
audio: Audio[]
}
class APlayer {
constructor({ container, lrcType, fixed, audio }: Props) {}
public lrc: { show: Function }
}

export default APlayer
}

interface Window {
ga: Function
GA_INITIALIZED: boolean
}

declare namespace NodeJS {
export interface ProcessEnv {
NEXT_PUBLIC_API_URL: string
NEXT_PUBLIC_DOMAIN_URL: string
NEXT_PUBLIC_STATIC_FILE_URL: string
NEXT_PUBLIC_GA_KEY: string
NEXT_PUBLIC_SENTRY_DSN: string
NEXT_PUBLIC_HOTJAR_ID: string
NEXT_PUBLIC_HOTJAR_SV: string
NEXT_PUBLIC_DISCUSSION_KEY: string
NEXT_PUBLIC_ALGOLIA_SEARCH_APP_ID: string
NEXT_PUBLIC_ALGOLIA_SEARCH_API_KEY: string
NEXT_PUBLIC_ALGOLIA_SEARCH_INDEX_NAME: string
}
}

declare const __YANCEY_BLOG_VERSION__: string
declare const __GIT_HASH__: string
/// <reference types="next/image-types/global" />
40 changes: 16 additions & 24 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,22 @@
const withSourceMaps = require('@zeit/next-source-maps')
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
})

module.exports = (phase, { defaultConfig }) =>
withBundleAnalyzer(
withSourceMaps({
compress: true,
pageExtensions: ['mdx', 'jsx', 'js', 'ts', 'tsx'],
future: {
webpack5: true,
},
webpack: (
config,
{ buildId, dev, isServer, defaultLoaders, webpack },
) => {
config.module.rules.push({
test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/, /\.webp$/, /\.cur$/],
use: [
{
loader: 'url-loader',
},
],
})
withBundleAnalyzer({
compress: true,
pageExtensions: ['mdx', 'jsx', 'js', 'ts', 'tsx'],
productionBrowserSourceMaps: true,
webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {
config.module.rules.push({
test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/, /\.webp$/, /\.cur$/],
use: [
{
loader: 'url-loader',
},
],
})

return config
},
}),
)
return config
},
})
10 changes: 4 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"license": "MIT",
"scripts": {
"dev": "next",
"build": "next build",
"start": "next start",
"build": "next build",
"analyze": "ANALYZE=true yarn build",
"commit": "npx git-cz",
"push": "git push --follow-tags origin master",
Expand All @@ -26,7 +26,6 @@
"@material-ui/lab": "^4.0.0-alpha.57",
"@sentry/browser": "^6.7.2",
"@sentry/tracing": "^6.7.1",
"@zeit/next-source-maps": "^0.0.3",
"algoliasearch": "^4.9.3",
"aplayer": "^1.10.1",
"disqus-react": "^1.0.9",
Expand All @@ -35,8 +34,8 @@
"lodash.orderby": "^4.6.0",
"lodash.throttle": "^4.1.1",
"luxon": "^1.27.0",
"next": "^10.2.0",
"next-with-apollo": "^5.1.0",
"next": "^11.0.1",
"next-with-apollo": "^5.2.1",
"normalize.css": "^8.0.1",
"notistack": "^1.0.9",
"nprogress": "^0.2.0",
Expand All @@ -47,7 +46,6 @@
"react-hotjar": "^2.2.1",
"react-instantsearch-core": "^6.11.0",
"react-instantsearch-dom": "^6.11.0",
"react-lazyload": "^3.2.0",
"react-markdown": "^6.0.2",
"react-progressive-graceful-image": "^0.6.13",
"react-share": "^4.4.0",
Expand All @@ -66,7 +64,6 @@
"@types/lodash.orderby": "^4.6.6",
"@types/lodash.throttle": "^4.1.6",
"@types/luxon": "^1.27.0",
"@types/markdown-to-jsx": "^6.11.3",
"@types/node": "^15.12.2",
"@types/nprogress": "^0.2.0",
"@types/react": "^17.0.8",
Expand All @@ -79,6 +76,7 @@
"cz-conventional-changelog": "^3.3.0",
"eslint": "^7.22.0",
"eslint-config-airbnb-typescript": "^11.4.0",
"eslint-config-next": "^11.0.1",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-jsx-a11y": "^6.4.1",
Expand Down
File renamed without changes
File renamed without changes.
83 changes: 83 additions & 0 deletions shims-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
declare module '*.bmp' {
const src: string
export default src
}

declare module '*.gif' {
const src: string
export default src
}

declare module '*.jpg' {
const src: string
export default src
}

declare module '*.jpeg' {
const src: string
export default src
}

declare module '*.png' {
const src: string
export default src
}

declare module '*.svg' {
import { SFC, SVGProps } from 'react'

export const ReactComponent: SFC<SVGProps<SVGSVGElement>>

const src: string
export default src
}

declare module '*.cur' {
const src: string
export default src
}

declare module 'aplayer' {
interface Audio {
name: string
url: string
cover: string
lrc: string
}
interface Props {
container: HTMLElement
lrcType: number
fixed: boolean
audio: Audio[]
}
class APlayer {
constructor({ container, lrcType, fixed, audio }: Props) {}
public lrc: { show: Function }
}

export default APlayer
}

interface Window {
ga: Function
GA_INITIALIZED: boolean
}

declare namespace NodeJS {
export interface ProcessEnv {
NEXT_PUBLIC_API_URL: string
NEXT_PUBLIC_DOMAIN_URL: string
NEXT_PUBLIC_STATIC_FILE_URL: string
NEXT_PUBLIC_GA_KEY: string
NEXT_PUBLIC_SENTRY_DSN: string
NEXT_PUBLIC_HOTJAR_ID: string
NEXT_PUBLIC_HOTJAR_SV: string
NEXT_PUBLIC_DISCUSSION_KEY: string
NEXT_PUBLIC_ALGOLIA_SEARCH_APP_ID: string
NEXT_PUBLIC_ALGOLIA_SEARCH_API_KEY: string
NEXT_PUBLIC_ALGOLIA_SEARCH_INDEX_NAME: string
}
}

declare const __YANCEY_BLOG_VERSION__: string
declare const __GIT_HASH__: string
2 changes: 1 addition & 1 deletion src/containers/Archive/Archive.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const Archive: FC = () => {
{DateTime.fromISO(day.createdAt).day}
{': '}
</Day>
<Link href="/post/[id]" as={`/post/${day.id}`}>
<Link href={`/post/${day.id}`}>
<a>
{day.title} ({day.pv} PV )
</a>
Expand Down
4 changes: 1 addition & 3 deletions src/containers/Home/components/Cover.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { FC } from 'react'
import styled from 'styled-components'
import LazyLoadImage from 'src/components/LazyLoadImage/LazyLoadImage'
import dot from 'src/static/images/dot.png'

import { ICover } from '../types'

Expand All @@ -18,9 +17,8 @@ const Covers = styled.figure`
height: 100%;
top: 0;
left: 0;
background-image: url(${dot});
background-image: url('images/dot.png');
background-repeat: repeat;
background-attachment: scroll;
opacity: 0.5;
}
`
Expand Down
2 changes: 1 addition & 1 deletion src/containers/Layout/components/Footer/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const Footer: FC<Props> = ({ globalSetting }) => {
affiliates.
</CopyRight>
<nav>
<Link href="/post/[id]" as={`/post/${releasePostId}`}>
<Link href={`/post/${releasePostId}`}>
<a>
<InnerLink>Chronicle of Events</InnerLink>
</a>
Expand Down
2 changes: 1 addition & 1 deletion src/containers/Layout/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const Header: FC<Props> = ({ globalSetting }) => {
Music
</a>
</Link>
<Link href="/post/[id]" as={`/post/${cvPostId}`}>
<Link href={`/post/${cvPostId}`}>
<a>
<svg>
<use xlinkHref={SVG_SPRITE.cv} />
Expand Down
6 changes: 3 additions & 3 deletions src/containers/Post/components/PostCard/PostCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const PostCard: FC<Props> = ({ post, isSupportWebp }) => {

return (
<PostCardWrapper>
<Link href={`/post/${_id}`} passHref prefetch={false}>
<Link href={`/post/${_id}`} passHref>
<PosterAnchor>
<LazyLoadImage
imageUrl={posterUrl}
Expand All @@ -44,7 +44,7 @@ const PostCard: FC<Props> = ({ post, isSupportWebp }) => {
Released At {formatDate(createdAt)}
</ReleasedAt>

<Link href="/post/[id]" as={`/post/${_id}`} prefetch={false}>
<Link href={`/post/${_id}`}>
<a>
<Title>{title}</Title>
</a>
Expand Down Expand Up @@ -75,7 +75,7 @@ const PostCard: FC<Props> = ({ post, isSupportWebp }) => {

<Summary>{summary}</Summary>

<Link href="/post/[id]" as={`/post/${_id}`} prefetch={false}>
<Link href={`/post/${_id}`}>
<a>
<ReadMoreSVG>
<use xlinkHref={SVG_SPRITE.more} />
Expand Down
2 changes: 1 addition & 1 deletion src/containers/Post/components/PrevAndNext/PrevAndNext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const PrevAndNext: FC<Props> = ({ prev, next }) => {
title: string,
type: ItemType,
) => (
<Link href="/post/[id]" as={`/post/${id}`}>
<Link href={`/post/${id}`}>
<a>
<PictureContainer>
<Picture src={posterUrl}>
Expand Down
5 changes: 3 additions & 2 deletions src/containers/Post/components/SharePanel/SharePanel.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FC, useState } from 'react'
import { useMutation } from '@apollo/client'
import Router from 'next/router'
import { useRouter } from 'next/router'
import styled from 'styled-components'
import { TwitterShareButton } from 'react-share'
import { flexMixin } from 'src/styled/mixins'
Expand Down Expand Up @@ -44,6 +44,7 @@ interface Props {
}

const SharePanel: FC<Props> = ({ id, title, like, postUrl }) => {
const router = useRouter()
const [likeStatus, setLikeStatus] = useState(false)

const [updateLike] = useMutation(UPDATE_LIKE, {
Expand All @@ -68,7 +69,7 @@ const SharePanel: FC<Props> = ({ id, title, like, postUrl }) => {
}
}

Router.events.on('routeChangeStart', () => {
router.events.on('routeChangeStart', () => {
setLikeStatus(false)
})
return (
Expand Down
2 changes: 1 addition & 1 deletion src/containers/Post/components/Top7PVPosts/Top7PVPosts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const Top7PVPosts: FC<Props> = ({ topPVPosts, isSupportWebp }) => {
topPVPosts.getTopPVPosts.map((post) => {
const { _id, title, posterUrl } = post
return (
<Link href="/post/[id]" as={`/post/${_id}`} key={_id}>
<Link href={`/post/${_id}`} key={_id}>
<a>
<CardItem>
<BlurBg
Expand Down
Loading

0 comments on commit a6230b8

Please sign in to comment.