このコミットが含まれているのは:
2026-01-11 13:39:50 +09:00
コミット fbe97ac634
4個のファイルの変更12行の追加10行の削除
+3 -5
ファイルの表示
@@ -36,12 +36,10 @@ const mdComponents = { h1: ({ children }) => <SectionTitle>{children}</SectionT
export default (({ title, body }: Props) => { export default (({ title, body }: Props) => {
const [pageNames, setPageNames] = useState<string[]> ([]) const [pageNames, setPageNames] = useState<string[]> ([])
const remarkPlugins = useMemo (() => [remarkWikiAutoLink (pageNames)], [pageNames]) const remarkPlugins = useMemo (
() => [() => remarkWikiAutoLink (pageNames), remarkGFM], [pageNames])
useEffect (() => { useEffect (() => {
if (!(body))
return
void (async () => { void (async () => {
try try
{ {
@@ -54,7 +52,7 @@ export default (({ title, body }: Props) => {
setPageNames ([]) setPageNames ([])
} }
}) () }) ()
}, [body]) }, [])
return ( return (
<ReactMarkdown components={mdComponents} remarkPlugins={remarkPlugins}> <ReactMarkdown components={mdComponents} remarkPlugins={remarkPlugins}>
+2 -2
ファイルの表示
@@ -4,7 +4,7 @@ const escapeForRegExp = (s: string) => s.replace (/[.*+?^${}()|[\]\\]/g, '\\$&')
export default (pageNames: string[], basePath = '/wiki'): ((tree: Root) => void) => { export default (pageNames: string[], basePath = '/wiki'): ((tree: Root) => void) => {
const names = pageNames.sort ((a, b) => b.length - a.length) const names = [...pageNames].sort ((a, b) => b.length - a.length)
if (names.length === 0) if (names.length === 0)
{ {
@@ -46,7 +46,7 @@ export default (pageNames: string[], basePath = '/wiki'): ((tree: Root) => void)
if (start > last) if (start > last)
parts.push ({ type: 'text', value: value.slice (last, start) }) parts.push ({ type: 'text', value: value.slice (last, start) })
const name = m[0] const name = m[1]
parts.push ({ type: 'link', parts.push ({ type: 'link',
url: `${ basePath }/${ encodeURIComponent (name) }`, url: `${ basePath }/${ encodeURIComponent (name) }`,
title: null, title: null,
+2
ファイルの表示
@@ -36,6 +36,7 @@ export default () => {
if (/^\d+$/.test (title)) if (/^\d+$/.test (title))
{ {
void (async () => { void (async () => {
setWikiPage (undefined)
try try
{ {
const res = await axios.get (`${ API_BASE_URL }/wiki/${ title }`) const res = await axios.get (`${ API_BASE_URL }/wiki/${ title }`)
@@ -52,6 +53,7 @@ export default () => {
} }
void (async () => { void (async () => {
setWikiPage (undefined)
try try
{ {
const res = await axios.get ( const res = await axios.get (
+5 -3
ファイルの表示
@@ -12,6 +12,8 @@ import Forbidden from '@/pages/Forbidden'
import 'react-markdown-editor-lite/lib/index.css' import 'react-markdown-editor-lite/lib/index.css'
import type { FC } from 'react'
import type { User, WikiPage } from '@/types' import type { User, WikiPage } from '@/types'
const mdParser = new MarkdownIt const mdParser = new MarkdownIt
@@ -19,7 +21,7 @@ const mdParser = new MarkdownIt
type Props = { user: User | null } type Props = { user: User | null }
export default ({ user }: Props) => { export default (({ user }: Props) => {
if (!(['admin', 'member'].some (r => user?.role === r))) if (!(['admin', 'member'].some (r => user?.role === r)))
return <Forbidden/> return <Forbidden/>
@@ -93,9 +95,9 @@ export default ({ user }: Props) => {
{/* 送信 */} {/* 送信 */}
<button onClick={handleSubmit} <button onClick={handleSubmit}
className="px-4 py-2 bg-blue-600 text-white rounded disabled:bg-gray-400"> className="px-4 py-2 bg-blue-600 text-white rounded disabled:bg-gray-400">
</button> </button>
</>)} </>)}
</div> </div>
</MainArea>) </MainArea>)
} }) satisfies FC<Props>