diff --git a/frontend/src/pages/posts/PostDetailPage.tsx b/frontend/src/pages/posts/PostDetailPage.tsx index 175d883..4bee984 100644 --- a/frontend/src/pages/posts/PostDetailPage.tsx +++ b/frontend/src/pages/posts/PostDetailPage.tsx @@ -2,7 +2,7 @@ import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query' import { motion } from 'framer-motion' import { useEffect, useState } from 'react' import { Helmet } from 'react-helmet-async' -import { useLocation, useParams } from 'react-router-dom' +import { useParams } from 'react-router-dom' import PostEditForm from '@/components/PostEditForm' import PostEmbed from '@/components/PostEmbed' @@ -31,11 +31,6 @@ export default (({ user }: Props) => { const postId = String (id ?? '') const postKey = postsKeys.show (postId) - const location = useLocation () - const navState = (location.state ?? { }) as { sharedId?: string } - - const inboundSharedId = navState.sharedId - const { data: post, isError: errorFlg, error } = useQuery ({ enabled: Boolean (id), queryKey: postKey, @@ -112,15 +107,15 @@ export default (({ user }: Props) => { {post ? ( <> - {inboundSharedId === `page-${ id }` && ( + {(post.thumbnail || post.thumbnailBase) && ( - {post.title diff --git a/frontend/src/pages/posts/PostListPage.tsx b/frontend/src/pages/posts/PostListPage.tsx index 1440985..8dc20d6 100644 --- a/frontend/src/pages/posts/PostListPage.tsx +++ b/frontend/src/pages/posts/PostListPage.tsx @@ -15,10 +15,12 @@ import { fetchPosts } from '@/lib/posts' import { postsKeys } from '@/lib/queryKeys' import { fetchWikiPageByTitle } from '@/lib/wiki' +import type { FC } from 'react' + import type { WikiPage } from '@/types' -export default () => { +export default (() => { const containerRef = useRef (null) const [wikiPage, setWikiPage] = useState (null) @@ -41,21 +43,24 @@ export default () => { const totalPages = data ? Math.ceil (data.count / limit) : 0 useLayoutEffect (() => { + scroll (0, 0) + setWikiPage (null) - if (tags.length === 1) + + if (tags.length !== 1) + return + + void (async () => { + try + { + const tagName = tags[0] + setWikiPage (await fetchWikiPageByTitle (tagName, { })) + } + catch { - void (async () => { - try - { - const tagName = tags[0] - setWikiPage (await fetchWikiPageByTitle (tagName, { })) - } - catch - { - ; - } - }) () + ; } + }) () }, [location.search]) return ( @@ -100,4 +105,4 @@ export default () => { ) -} +}) satisfies FC