This commit is contained in:
2025-07-31 23:40:46 +09:00
parent 432736e19d
commit 732ad0ef21
4 changed files with 29 additions and 28 deletions
+4 -3
View File
@@ -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) => (
<ReactMarkdown components={{ a: (
({ href, children }) => (['/', '.'].some (e => href?.startsWith (e))
? <Link to={href!}>{children}</Link>
: <a href={href} target="_blank" rel="noopener noreferrer">{children}</a>)) }}>
{body}
{body || `このページは存在しません。[新規作成してください](/wiki/new?title=${ encodeURIComponent (title) })。`}
</ReactMarkdown>)
+4 -4
View File
@@ -129,11 +129,11 @@ export default () => {
{loading && 'Loading...'}
<div ref={loaderRef} className="h-12"></div>
</Tab>
{(wikiPage && wikiPage.body) && (
<Tab name="Wiki" init={!(posts.length)}>
<WikiBody body={wikiPage.body} />
{tags.length === 1 && (
<Tab name="Wiki">
<WikiBody body={wikiPage?.body} title={tags[0]} />
<div className="my-2">
<Link to={`/wiki/${ encodeURIComponent (wikiPage.title) }`}>
<Link to={`/wiki/${ encodeURIComponent (tags[0]) }`}>
Wiki
</Link>
</div>
+1 -1
View File
@@ -123,7 +123,7 @@ export default () => {
<div className="prose mx-auto p-4">
{wikiPage === undefined
? 'Loading...'
: <WikiBody body={wikiPage?.body || `このページは存在しません。[新規作成してください](/wiki/new?title=${ encodeURIComponent (title) })。`} />}
: <WikiBody body={wikiPage?.body} title={title} />}
</div>
{(!(version) && posts.length > 0) && (