細部
This commit is contained in:
@@ -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}
|
||||
({ href, children }) => (['/', '.'].some (e => href?.startsWith (e))
|
||||
? <Link to={href!}>{children}</Link>
|
||||
: <a href={href} target="_blank" rel="noopener noreferrer">{children}</a>)) }}>
|
||||
{body || `このページは存在しません。[新規作成してください](/wiki/new?title=${ encodeURIComponent (title) })。`}
|
||||
</ReactMarkdown>)
|
||||
|
||||
@@ -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 (
|
||||
<div className="mt-4">
|
||||
<div className="flex gap-4">
|
||||
{tabs.map ((tab, i) => (
|
||||
<a key={i}
|
||||
href="#"
|
||||
className={cn (i === current && 'font-bold')}
|
||||
onClick={ev => {
|
||||
ev.preventDefault ()
|
||||
setCurrent (i)
|
||||
}}>
|
||||
{tab.props.name}
|
||||
</a>))}
|
||||
</div>
|
||||
<div className="mt-2">
|
||||
{tabs[current]}
|
||||
</div>
|
||||
<div className="flex gap-4">
|
||||
{tabs.map ((tab, i) => (
|
||||
<a key={i}
|
||||
href="#"
|
||||
className={cn (i === current && 'font-bold')}
|
||||
onClick={ev => {
|
||||
ev.preventDefault ()
|
||||
setCurrent (i)
|
||||
}}>
|
||||
{tab.props.name}
|
||||
</a>))}
|
||||
</div>
|
||||
<div className="mt-2">
|
||||
{tabs[current]}
|
||||
</div>
|
||||
</div>)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user