diff --git a/frontend/src/components/WikiBody.tsx b/frontend/src/components/WikiBody.tsx index 187b52e..e041398 100644 --- a/frontend/src/components/WikiBody.tsx +++ b/frontend/src/components/WikiBody.tsx @@ -4,13 +4,31 @@ import { useEffect, useState } from 'react' import ReactMarkdown from 'react-markdown' import { Link } from 'react-router-dom' +import SectionTitle from '@/components/common/SectionTitle' +import SubsectionTitle from '@/components/common/SubsectionTitle' import { API_BASE_URL } from '@/config' +import type { Components } from 'react-markdown' + import type { WikiPage } from '@/types' type Props = { title: string body?: string } +const mdComponents = { h1: ({ children }) => {children}, + h2: ({ children }) => {children}, + ol: ({ children }) =>
    {children}
, + ul: ({ children }) => , + a: (({ href, children }) => ( + ['/', '.'].some (e => href?.startsWith (e)) + ? {children} + : ( + + {children} + ))) } as const satisfies Components + export default ({ title, body }: Props) => { const [pageNames, setPageNames] = useState ([]) @@ -79,10 +97,7 @@ export default ({ title, body }: Props) => { }, [body, pageNames]) return ( - (['/', '.'].some (e => href?.startsWith (e)) - ? {children} - : {children})) }}> + {realBody || `このページは存在しません。[新規作成してください](/wiki/new?title=${ encodeURIComponent (title) })。`} ) } diff --git a/frontend/src/pages/posts/PostListPage.tsx b/frontend/src/pages/posts/PostListPage.tsx index 95003b5..f1cdbed 100644 --- a/frontend/src/pages/posts/PostListPage.tsx +++ b/frontend/src/pages/posts/PostListPage.tsx @@ -131,7 +131,7 @@ export default () => { {tags.length === 1 && ( - +
Wiki を見る diff --git a/frontend/src/pages/wiki/WikiDetailPage.tsx b/frontend/src/pages/wiki/WikiDetailPage.tsx index be69f59..dbf1e5d 100644 --- a/frontend/src/pages/wiki/WikiDetailPage.tsx +++ b/frontend/src/pages/wiki/WikiDetailPage.tsx @@ -60,6 +60,7 @@ export default () => { } }) () + setPosts ([]) void (async () => { try { @@ -73,7 +74,7 @@ export default () => { } catch { - setPosts ([]) + ; } }) () @@ -123,7 +124,7 @@ export default () => {
{wikiPage === undefined ? 'Loading...' - : } + : }
{(!(version) && posts.length > 0) && (