diff --git a/frontend/src/assets/images/not-found.gif b/frontend/src/assets/images/not-found.gif new file mode 100644 index 0000000..0e8a77c Binary files /dev/null and b/frontend/src/assets/images/not-found.gif differ diff --git a/frontend/src/pages/NotFound.tsx b/frontend/src/pages/NotFound.tsx index a1b7f2f..ea681fd 100644 --- a/frontend/src/pages/NotFound.tsx +++ b/frontend/src/pages/NotFound.tsx @@ -1,5 +1,6 @@ import { Helmet } from 'react-helmet-async' +import notFoundImg from '@/assets/images/not-found.gif' import MainArea from '@/components/layout/MainArea' import { SITE_TITLE } from '@/config' @@ -7,12 +8,19 @@ import { SITE_TITLE } from '@/config' export default () => ( - - ページないよ (笑) | {SITE_TITLE} + + ページないよ (笑) | {SITE_TITLE} -
- 404
ページないよ(笑) +
+

404

+
+

帰れ!

+ 404 +

帰れ!

+
+

ページないよ(笑)

) diff --git a/frontend/src/pages/posts/PostDetailPage.tsx b/frontend/src/pages/posts/PostDetailPage.tsx index 20ac87d..d937084 100644 --- a/frontend/src/pages/posts/PostDetailPage.tsx +++ b/frontend/src/pages/posts/PostDetailPage.tsx @@ -13,6 +13,7 @@ import { Button } from '@/components/ui/button' import { toast } from '@/components/ui/use-toast' import { API_BASE_URL, SITE_TITLE } from '@/config' import { cn } from '@/lib/utils' +import NotFound from '@/pages/NotFound' import type { Post, User } from '@/types' @@ -24,6 +25,7 @@ export default ({ user }: Props) => { const [post, setPost] = useState (null) const [editing, setEditing] = useState (true) + const [found, setFound] = useState (true) const changeViewedFlg = async () => { const url = `${ API_BASE_URL }/posts/${ id }/viewed` @@ -57,7 +59,8 @@ export default ({ user }: Props) => { } catch (err) { - console.error ('うんち!', err) + if (err.status === 404) + setFound (false) } }) () }, [id]) @@ -71,6 +74,9 @@ export default ({ user }: Props) => { setEditing (true) }, [editing]) + if (!(found)) + return + const url = post ? new URL (post.url) : null const nicoFlg = url?.hostname.split ('.').slice (-2).join ('.') === 'nicovideo.jp' const match = nicoFlg ? url.pathname.match (/(?<=\/watch\/)[a-zA-Z0-9]+?(?=\/|$)/) : null