This commit is contained in:
2026-02-08 01:11:05 +09:00
parent d3cc8805fb
commit 26bd40d804
3 changed files with 16 additions and 6 deletions
+1 -1
View File
@@ -65,7 +65,7 @@ export default (({ user }: Props) => {
const postCount = tag?.postCount ?? 0
const wikiPageFlg = Boolean (/^\/wiki\/(?!new|changes)[^\/]+/.test (location.pathname) && wikiId)
const wikiTitle = location.pathname.split ('/')[2]
const wikiTitle = location.pathname.split ('/')[2] ?? ''
const menu: Menu = [
{ name: '広場', to: '/posts', subMenu: [
{ name: '一覧', to: '/posts' },
+12 -2
View File
@@ -4,7 +4,9 @@ import { match } from 'path-to-regexp'
import { fetchPost, fetchPosts, fetchPostChanges } from '@/lib/posts'
import { postsKeys, tagsKeys, wikiKeys } from '@/lib/queryKeys'
import { fetchTagByName } from '@/lib/tags'
import { fetchWikiPageByTitle, fetchWikiPages } from '@/lib/wiki'
import { fetchWikiPage,
fetchWikiPageByTitle,
fetchWikiPages } from '@/lib/wiki'
type Prefetcher = (qc: QueryClient, url: URL) => Promise<void>
@@ -33,12 +35,20 @@ const prefetchWikiPageShow: Prefetcher = async (qc, url) => {
queryKey: wikiKeys.show (title, { version }),
queryFn: () => fetchWikiPageByTitle (title, { version }) })
if (wikiPage?.body)
if (wikiPage)
{
const effectiveId = String (wikiPage.id ?? '')
await qc.prefetchQuery ({
queryKey: wikiKeys.show (effectiveId, { }),
queryFn: () => fetchWikiPage (effectiveId, { } ) })
if (wikiPage.body)
{
await qc.prefetchQuery ({
queryKey: wikiKeys.index ({ }),
queryFn: () => fetchWikiPages ({ }) })
}
}
const effectiveTitle = wikiPage?.title ?? title
+1 -1
View File
@@ -22,7 +22,7 @@ export const fetchWikiPageByTitle = async (
): Promise<WikiPage | null> => {
try
{
return await apiGet (`/wiki/title/${ title }`, { params: { version } })
return await apiGet (`/wiki/title/${ encodeURIComponent (title) }`, { params: { version } })
}
catch
{