このコミットが含まれているのは:
2026-02-07 01:01:10 +09:00
コミット 4c5668653f
6個のファイルの変更43行の追加47行の削除
+1 -1
ファイルの表示
@@ -123,7 +123,7 @@ export default (({ user }: Props) => {
const wikiPage = await fetchWikiPage (String (wikiId ?? ''), { })
const tag = await fetchTagByName (wikiPage.title)
setPostCount (tag.postCount)
setPostCount (tag?.postCount ?? 0)
}
catch
{
+9 -19
ファイルの表示
@@ -1,18 +1,18 @@
import { useEffect, useMemo, useState } from 'react'
import { useQuery } from '@tanstack/react-query'
import { useMemo } from 'react'
import ReactMarkdown from 'react-markdown'
import remarkGFM from 'remark-gfm'
import PrefetchLink from '@/components/PrefetchLink'
import SectionTitle from '@/components/common/SectionTitle'
import SubsectionTitle from '@/components/common/SubsectionTitle'
import { apiGet } from '@/lib/api'
import { wikiKeys } from '@/lib/queryKeys'
import remarkWikiAutoLink from '@/lib/remark-wiki-autolink'
import { fetchWikiPages } from '@/lib/wiki'
import type { FC } from 'react'
import type { Components } from 'react-markdown'
import type { WikiPage } from '@/types'
type Props = { title: string
body?: string }
@@ -32,25 +32,15 @@ const mdComponents = { h1: ({ children }) => <SectionTitle>{children}</SectionT
export default (({ title, body }: Props) => {
const [pageNames, setPageNames] = useState<string[]> ([])
const { data } = useQuery ({
enabled: Boolean (body),
queryKey: wikiKeys.index ({ }),
queryFn: () => fetchWikiPages ({ }) })
const pageNames = (data ?? []).map (page => page.title).sort ((a, b) => b.length - a.length)
const remarkPlugins = useMemo (
() => [() => remarkWikiAutoLink (pageNames), remarkGFM], [pageNames])
useEffect (() => {
void (async () => {
try
{
const data = await apiGet<WikiPage[]> ('/wiki')
setPageNames (data.map (page => page.title).sort ((a, b) => b.length - a.length))
}
catch
{
setPageNames ([])
}
}) ()
}, [])
return (
<ReactMarkdown components={mdComponents} remarkPlugins={remarkPlugins}>
{body || `このページは存在しません。[新規作成してください](/wiki/new?title=${ encodeURIComponent (title) })。`}