Skip to content

Commit b81fd2c

Browse files
committed
404 fix and Added validation npm scripts
1 parent b631ca2 commit b81fd2c

File tree

3 files changed

+19
-20
lines changed

3 files changed

+19
-20
lines changed

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
"lint": "eslint --ignore-path .gitignore .",
1919
"format": "prettier --ignore-path .gitignore --write \"**/*.+(ts|tsx|json)\"",
2020
"test": "npx jest",
21-
"test:watch": "yarn test --watch"
21+
"test:watch": "yarn test --watch",
22+
"test:coverage": "yarn test --coverage",
23+
"validate": "yarn lint && yarn test && yarn build"
2224
},
2325
"dependencies": {
2426
"next": "10.0.0",
@@ -50,4 +52,4 @@
5052
"prettier": "^2.1.2",
5153
"typescript": "^4.1.0-beta"
5254
}
53-
}
55+
}

pages/404.tsx

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
import { NextPage } from 'next';
22
import Link from 'next/link';
3-
import { Translate } from 'i18n';
3+
import { useI18n } from 'i18n';
44
import { PageTemplate } from 'components/template';
55

6-
type NotFoundProps = {
7-
t: Translate;
6+
const NotFound: NextPage = () => {
7+
const { t } = useI18n();
8+
9+
return (
10+
<PageTemplate t={t} title={t(404)} meta={{ description: t(404) }}>
11+
<h1>🤔 404</h1>
12+
<p>{t(404)}</p>
13+
<Link href="/">{t('backtohome')}</Link>
14+
</PageTemplate>
15+
);
816
};
9-
const NotFound: NextPage<NotFoundProps> = ({ t }) => (
10-
<PageTemplate t={t} title={t(404)} meta={{ description: t(404) }}>
11-
<h1>🤔 404</h1>
12-
<p>{t(404)}</p>
13-
<Link href="/">{t('backtohome')}</Link>
14-
</PageTemplate>
15-
);
1617

1718
export default NotFound;

pages/_app.tsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
import type { AppProps } from 'next/app';
2-
import { Translate } from 'i18n';
31
import { useEffect } from 'react';
2+
import type { AppProps } from 'next/app';
3+
44
import * as gtag from 'lib/gtag';
55

6-
type CustomProps = {
7-
t: Translate;
8-
};
9-
function MyApp({ Component, pageProps, router }: AppProps<CustomProps>) {
10-
const { locale } = router;
6+
function App({ Component, pageProps, router }: AppProps) {
117
useEffect(() => {
128
const handleRouteChange = (url: string) => {
139
gtag.pageview(url);
@@ -21,4 +17,4 @@ function MyApp({ Component, pageProps, router }: AppProps<CustomProps>) {
2117
return <Component {...pageProps} />;
2218
}
2319

24-
export default MyApp;
20+
export default App;

0 commit comments

Comments
 (0)