From cc6d50cf173a1865309f092963e3995dae814b64 Mon Sep 17 00:00:00 2001 From: miteruzo Date: Sun, 3 Aug 2025 19:08:25 +0900 Subject: [PATCH] #89 --- frontend/src/components/WikiBody.tsx | 23 ++++++++++++++++++---- frontend/src/pages/posts/PostListPage.tsx | 2 +- frontend/src/pages/wiki/WikiDetailPage.tsx | 5 +++-- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/frontend/src/components/WikiBody.tsx b/frontend/src/components/WikiBody.tsx index e3f2fdb..851c427 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 ([]) @@ -75,10 +93,7 @@ export default ({ title, body }: Props) => { }, [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) && (