バグ修正(#253) #254

Closed
みてるぞ wants to merge 25 commits from feature/253 into main
3 changed files with 16 additions and 6 deletions
Showing only changes of commit 26bd40d804 - Show all commits
+1 -1
View File
@@ -65,7 +65,7 @@ export default (({ user }: Props) => {
const postCount = tag?.postCount ?? 0 const postCount = tag?.postCount ?? 0
const wikiPageFlg = Boolean (/^\/wiki\/(?!new|changes)[^\/]+/.test (location.pathname) && wikiId) 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 = [ const menu: Menu = [
{ name: '広場', to: '/posts', subMenu: [ { name: '広場', to: '/posts', subMenu: [
{ name: '一覧', to: '/posts' }, { 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 { fetchPost, fetchPosts, fetchPostChanges } from '@/lib/posts'
import { postsKeys, tagsKeys, wikiKeys } from '@/lib/queryKeys' import { postsKeys, tagsKeys, wikiKeys } from '@/lib/queryKeys'
import { fetchTagByName } from '@/lib/tags' 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> type Prefetcher = (qc: QueryClient, url: URL) => Promise<void>
@@ -33,12 +35,20 @@ const prefetchWikiPageShow: Prefetcher = async (qc, url) => {
queryKey: wikiKeys.show (title, { version }), queryKey: wikiKeys.show (title, { version }),
queryFn: () => fetchWikiPageByTitle (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 ({ await qc.prefetchQuery ({
queryKey: wikiKeys.index ({ }), queryKey: wikiKeys.index ({ }),
queryFn: () => fetchWikiPages ({ }) }) queryFn: () => fetchWikiPages ({ }) })
} }
}
const effectiveTitle = wikiPage?.title ?? title const effectiveTitle = wikiPage?.title ?? title
+1 -1
View File
@@ -22,7 +22,7 @@ export const fetchWikiPageByTitle = async (
): Promise<WikiPage | null> => { ): Promise<WikiPage | null> => {
try try
{ {
return await apiGet (`/wiki/title/${ title }`, { params: { version } }) return await apiGet (`/wiki/title/${ encodeURIComponent (title) }`, { params: { version } })
} }
catch catch
{ {