アニメーション(#139) (#252)

#139

#139

#139

#139

#139

Merge branch 'feature/140' into feature/139

Merge remote-tracking branch 'origin/main' into feature/139

#140

Merge remote-tracking branch 'origin/main' into feature/140

Merge remote-tracking branch 'origin/main' into feature/140

#140 ぼちぼち

Merge remote-tracking branch 'origin/main' into feature/140

#140

#140

#140

#139 アニメーション

Co-authored-by: miteruzo <miteruzo@naver.com>
Reviewed-on: #252
This commit was merged in pull request #252.
This commit is contained in:
2026-02-05 23:25:27 +09:00
parent f3cd108b2e
commit 797e67ac37
22 changed files with 810 additions and 311 deletions
+14 -23
View File
@@ -1,17 +1,19 @@
import axios from 'axios'
import toCamel from 'camelcase-keys'
import { useEffect, useState } from 'react'
import { Helmet } from 'react-helmet-async'
import { Link, useLocation, useNavigate, useParams } from 'react-router-dom'
import { useLocation, useNavigate, useParams } from 'react-router-dom'
import PostList from '@/components/PostList'
import PrefetchLink from '@/components/PrefetchLink'
import TagLink from '@/components/TagLink'
import WikiBody from '@/components/WikiBody'
import PageTitle from '@/components/common/PageTitle'
import TabGroup, { Tab } from '@/components/common/TabGroup'
import MainArea from '@/components/layout/MainArea'
import { API_BASE_URL, SITE_TITLE } from '@/config'
import { SITE_TITLE } from '@/config'
import { WikiIdBus } from '@/lib/eventBus/WikiIdBus'
import { fetchPosts } from '@/lib/posts'
import { fetchTagByName } from '@/lib/tags'
import { fetchWikiPage, fetchWikiPageByTitle } from '@/lib/wiki'
import type { Post, Tag, WikiPage } from '@/types'
@@ -39,8 +41,7 @@ export default () => {
setWikiPage (undefined)
try
{
const res = await axios.get (`${ API_BASE_URL }/wiki/${ title }`)
const data = res.data as WikiPage
const data = await fetchWikiPage (title)
navigate (`/wiki/${ encodeURIComponent(data.title) }`, { replace: true })
}
catch
@@ -56,10 +57,7 @@ export default () => {
setWikiPage (undefined)
try
{
const res = await axios.get (
`${ API_BASE_URL }/wiki/title/${ encodeURIComponent (title) }`,
{ params: version ? { version } : { } })
const data = toCamel (res.data as any, { deep: true }) as WikiPage
const data = await fetchWikiPageByTitle (title, version ? { version } : { })
if (data.title !== title)
navigate (`/wiki/${ encodeURIComponent(data.title) }`, { replace: true })
setWikiPage (data)
@@ -75,12 +73,7 @@ export default () => {
void (async () => {
try
{
const res = await axios.get (
`${ API_BASE_URL }/posts?${ new URLSearchParams ({ tags: title,
limit: '8' }) }`)
const data = toCamel (res.data as any,
{ deep: true }) as { posts: Post[]
nextCursor: string }
const data = await fetchPosts ({ tags: title, match: 'all', limit: 8 })
setPosts (data.posts)
}
catch
@@ -92,9 +85,7 @@ export default () => {
void (async () => {
try
{
const res = await axios.get (
`${ API_BASE_URL }/tags/name/${ encodeURIComponent (title) }`)
setTag (toCamel (res.data as any, { deep: true }) as Tag)
setTag (await fetchTagByName (title))
}
catch
{
@@ -115,16 +106,16 @@ export default () => {
{(wikiPage && version) && (
<div className="text-sm flex gap-3 items-center justify-center border border-gray-700 rounded px-2 py-1 mb-4">
{wikiPage.pred ? (
<Link to={`/wiki/${ encodeURIComponent (title) }?version=${ wikiPage.pred }`}>
<PrefetchLink to={`/wiki/${ encodeURIComponent (title) }?version=${ wikiPage.pred }`}>
&lt;
</Link>) : '(最古)'}
</PrefetchLink>) : '(最古)'}
<span>{wikiPage.updatedAt}</span>
{wikiPage.succ ? (
<Link to={`/wiki/${ encodeURIComponent (title) }?version=${ wikiPage.succ }`}>
<PrefetchLink to={`/wiki/${ encodeURIComponent (title) }?version=${ wikiPage.succ }`}>
&gt;
</Link>) : '(最新)'}
</PrefetchLink>) : '(最新)'}
</div>)}
<PageTitle>