feat: Wiki の URL におけるタイトルを完全一致に変更(#100) #153

マージ済み
みてるぞ が 3 個のコミットを feature/100 から main へマージ 2025-12-25 02:51:56 +09:00
2個のファイルの変更13行の追加4行の削除
コミット e76503c729 の変更だけを表示してゐます - すべてのコミットを表示
+1 -1
ファイルの表示
@@ -7,7 +7,7 @@ import type { ComponentProps, FC, HTMLAttributes } from 'react'
import type { Tag } from '@/types' import type { Tag } from '@/types'
type CommonProps = { tag: Tag type CommonProps = { tag: Pick<Tag, 'name' | 'category' | 'postCount'>
withWiki?: boolean withWiki?: boolean
withCount?: boolean } withCount?: boolean }
+10 -1
ファイルの表示
@@ -36,9 +36,16 @@ export default () => {
if (/^\d+$/.test (title)) if (/^\d+$/.test (title))
{ {
void (async () => { void (async () => {
try
{
const res = await axios.get (`${ API_BASE_URL }/wiki/${ title }`) const res = await axios.get (`${ API_BASE_URL }/wiki/${ title }`)
const data = res.data as WikiPage const data = res.data as WikiPage
navigate (`/wiki/${ data.title }`, { replace: true }) navigate (`/wiki/${ encodeURIComponent(data.title) }`, { replace: true })
}
catch
{
;
}
}) () }) ()
return return
@@ -51,6 +58,8 @@ export default () => {
`${ API_BASE_URL }/wiki/title/${ encodeURIComponent (title) }`, `${ API_BASE_URL }/wiki/title/${ encodeURIComponent (title) }`,
{ params: version ? { version } : { } }) { params: version ? { version } : { } })
const data = toCamel (res.data as any, { deep: true }) as WikiPage const data = toCamel (res.data as any, { deep: true }) as WikiPage
if (data.title !== title)
navigate (`/wiki/${ encodeURIComponent(data.title) }`, { replace: true })
setWikiPage (data) setWikiPage (data)
WikiIdBus.set (data.id) WikiIdBus.set (data.id)
} }