From 732ad0ef21237fe1c9b2f0794706bfa95ff3d4ff Mon Sep 17 00:00:00 2001 From: miteruzo Date: Thu, 31 Jul 2025 23:40:46 +0900 Subject: [PATCH] =?UTF-8?q?=E7=B4=B0=E9=83=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/WikiBody.tsx | 13 ++++---- frontend/src/components/common/TabGroup.tsx | 34 ++++++++++----------- frontend/src/pages/posts/PostListPage.tsx | 8 ++--- frontend/src/pages/wiki/WikiDetailPage.tsx | 2 +- 4 files changed, 29 insertions(+), 28 deletions(-) diff --git a/frontend/src/components/WikiBody.tsx b/frontend/src/components/WikiBody.tsx index d3d707f..30727c7 100644 --- a/frontend/src/components/WikiBody.tsx +++ b/frontend/src/components/WikiBody.tsx @@ -1,13 +1,14 @@ import ReactMarkdown from 'react-markdown' import { Link } from 'react-router-dom' -type Props = { body: string } +type Props = { title: string + body?: string } -export default ({ body }: Props) => ( +export default ({ title, body }: Props) => ( (['/', '.'].some (e => href?.startsWith (e)) - ? {children} - : {children})) }}> - {body} + ({ href, children }) => (['/', '.'].some (e => href?.startsWith (e)) + ? {children} + : {children})) }}> + {body || `このページは存在しません。[新規作成してください](/wiki/new?title=${ encodeURIComponent (title) })。`} ) diff --git a/frontend/src/components/common/TabGroup.tsx b/frontend/src/components/common/TabGroup.tsx index 4444b23..fd15549 100644 --- a/frontend/src/components/common/TabGroup.tsx +++ b/frontend/src/components/common/TabGroup.tsx @@ -2,8 +2,8 @@ import React, { useState } from 'react' import { cn } from '@/lib/utils' type TabProps = { name: string - init?: boolean - children: React.ReactNode } + init?: boolean + children: React.ReactNode } type Props = { children: React.ReactNode } @@ -20,20 +20,20 @@ export default ({ children }: Props) => { return (
-
- {tabs.map ((tab, i) => ( - { - ev.preventDefault () - setCurrent (i) - }}> - {tab.props.name} - ))} -
-
- {tabs[current]} -
+
+ {tabs.map ((tab, i) => ( + { + ev.preventDefault () + setCurrent (i) + }}> + {tab.props.name} + ))} +
+
+ {tabs[current]} +
) } diff --git a/frontend/src/pages/posts/PostListPage.tsx b/frontend/src/pages/posts/PostListPage.tsx index e535138..95003b5 100644 --- a/frontend/src/pages/posts/PostListPage.tsx +++ b/frontend/src/pages/posts/PostListPage.tsx @@ -129,11 +129,11 @@ export default () => { {loading && 'Loading...'}
- {(wikiPage && wikiPage.body) && ( - - + {tags.length === 1 && ( + +
- + Wiki を見る
diff --git a/frontend/src/pages/wiki/WikiDetailPage.tsx b/frontend/src/pages/wiki/WikiDetailPage.tsx index 39b781d..be69f59 100644 --- a/frontend/src/pages/wiki/WikiDetailPage.tsx +++ b/frontend/src/pages/wiki/WikiDetailPage.tsx @@ -123,7 +123,7 @@ export default () => {
{wikiPage === undefined ? 'Loading...' - : } + : }
{(!(version) && posts.length > 0) && (