This commit is contained in:
2025-07-14 01:26:24 +09:00
parent a8faf0f7e5
commit de401cdd21
3 changed files with 21 additions and 7 deletions
+7 -1
View File
@@ -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<Post | null> (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 <NotFound />
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