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