コミットを比較
2
コミット
| 作成者 | SHA1 | 日付 | |
|---|---|---|---|
|
|
4a7296eea0 | ||
|
|
2b18d72f7a |
@@ -6,6 +6,11 @@ class WikiPagesController < ApplicationController
|
||||
def index
|
||||
locale = resolve_locale!
|
||||
|
||||
resource_type = params[:resource_type]
|
||||
unless resource_type.nil? || ['tag_description', 'tag_group'].include?(resource_type)
|
||||
return head :bad_request
|
||||
end
|
||||
|
||||
title = params[:title].to_s.strip
|
||||
descriptions =
|
||||
HistoryAccess.current(TagDescription.all, TagDescriptionVersion)
|
||||
@@ -14,6 +19,8 @@ class WikiPagesController < ApplicationController
|
||||
|
||||
descriptions = descriptions.order(updated_at: :desc, id: :asc)
|
||||
tag_groups = HistoryAccess.current(TagGroup.all, TagGroupVersion).order(updated_at: :desc, id: :asc)
|
||||
descriptions = descriptions.none if resource_type == 'tag_group'
|
||||
tag_groups = tag_groups.none if resource_type == 'tag_description'
|
||||
if title.present?
|
||||
pattern = "%#{ ApplicationRecord.sanitize_sql_like(title) }%"
|
||||
descriptions =
|
||||
|
||||
+7
-1
@@ -166,7 +166,13 @@ export const pageRoutes = (
|
||||
robots: 'noindex', authentication: 'user' } },
|
||||
{ path: ':id', element: <MaterialDetailPage/>,
|
||||
handle: { preload: MaterialDetailPage.preload, sitemap: ['materials'] } }] },
|
||||
{ path: 'wiki', element: <WikiSearchPage/>,
|
||||
{ path: 'wiki', element: <LocaleRedirect to="/tag-descriptions"/>,
|
||||
handle: { redirectTo: '/tag-descriptions' } },
|
||||
{ path: 'tag-descriptions',
|
||||
element: <WikiSearchPage key="tag_description" resourceType="tag_description"/>,
|
||||
handle: { preload: WikiSearchPage.preload, sitemap: ['static'] } },
|
||||
{ path: 'tag-groups',
|
||||
element: <WikiSearchPage key="tag_group" resourceType="tag_group"/>,
|
||||
handle: { preload: WikiSearchPage.preload, sitemap: ['static'] } },
|
||||
{ path: 'wiki/:title', element: <WikiDetailPage/>,
|
||||
handle: { preload: WikiDetailPage.preload, switchLocale: switchWikiLocale,
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
|
||||
import { useLocale } from '@/lib/useLocale'
|
||||
import PostList from '@/components/PostList'
|
||||
import PostOriginalCreatedTimeField from '@/components/PostOriginalCreatedTimeField'
|
||||
import FieldError from '@/components/common/FieldError'
|
||||
import PostDurationField from '@/components/posts/PostDurationField'
|
||||
@@ -12,15 +10,14 @@ import { Button } from '@/components/ui/button'
|
||||
import { toast } from '@/components/ui/use-toast'
|
||||
import { isApiError } from '@/lib/api'
|
||||
import useDialogue from '@/lib/dialogues/useDialogue'
|
||||
import { fetchPosts, updatePost } from '@/lib/posts'
|
||||
import { postsKeys } from '@/lib/queryKeys'
|
||||
import { updatePost } from '@/lib/posts'
|
||||
import { msToTime } from '@/lib/utils'
|
||||
import { useValidationErrors } from '@/lib/useValidationErrors'
|
||||
import { useUITranslation } from '@/lib/useUITranslation'
|
||||
|
||||
import type { FC, FormEvent } from 'react'
|
||||
|
||||
import type { FetchPostsParams, Post, TagWithSections } from '@/types'
|
||||
import type { Post, TagWithSections } from '@/types'
|
||||
|
||||
type PostFormField =
|
||||
'parentPostIds' | 'tags' | 'videoMs'
|
||||
@@ -71,33 +68,6 @@ const PostEditForm: FC<Props> = ({ post, onSave }) => {
|
||||
const [tags, setTags] = useState<string> (() => tagsToStr (post.tags))
|
||||
const [title, setTitle] = useState (post.title)
|
||||
|
||||
const [importVisible, setImportVisible] = useState (false)
|
||||
const [sourceTitle, setSourceTitle] = useState ('')
|
||||
const [sourcePage, setSourcePage] = useState (1)
|
||||
const sourceParams: FetchPostsParams = {
|
||||
title: sourceTitle, page: sourcePage, limit: 20,
|
||||
url: '', tags: '', match: 'all', order: 'original_created_at:desc',
|
||||
originalCreatedFrom: '', originalCreatedTo: '',
|
||||
createdFrom: '', createdTo: '', updatedFrom: '', updatedTo: '' }
|
||||
const { data: sources, isError: sourceError } = useQuery ({
|
||||
queryKey: postsKeys.index (sourceParams, locale),
|
||||
queryFn: () => fetchPosts (sourceParams, locale),
|
||||
enabled: importVisible && !disabled })
|
||||
|
||||
const importTags = (source: Post) => {
|
||||
if (disabled)
|
||||
return
|
||||
setTags (current => {
|
||||
const existing = new Set (current.split (/\s+/))
|
||||
const additions = tagsToStr (source.tags).split (/\s+/)
|
||||
.filter (tag => tag !== '' && !existing.has (tag))
|
||||
return additions.length > 0
|
||||
? `${current}${current.trim () === '' ? '' : ' '}${additions.join (' ')}`
|
||||
: current
|
||||
})
|
||||
setImportVisible (false)
|
||||
}
|
||||
|
||||
const videoFlg =
|
||||
useMemo (() => tags.split (/\s+/).some (tag => tag.replace (/\[.*\]$/, '') === '動画'),
|
||||
[tags])
|
||||
@@ -222,48 +192,6 @@ const PostEditForm: FC<Props> = ({ post, onSave }) => {
|
||||
setTags={setTags}
|
||||
errors={fieldErrors.tags}/>
|
||||
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
disabled={disabled}
|
||||
aria-expanded={importVisible}
|
||||
onClick={() => setImportVisible (visible => !visible)}>
|
||||
{label ('edit.import')}
|
||||
</Button>
|
||||
{importVisible && (
|
||||
<div className="space-y-2" onKeyDown={event => {
|
||||
if (event.key === 'Enter' && event.target instanceof HTMLInputElement)
|
||||
event.preventDefault ()
|
||||
}}>
|
||||
<PostTextField
|
||||
label={label ('shared:labels.title')}
|
||||
type="search"
|
||||
value={sourceTitle}
|
||||
disabled={disabled}
|
||||
onChange={value => {
|
||||
setSourceTitle (value)
|
||||
setSourcePage (1)
|
||||
}}/>
|
||||
<FieldError messages={sourceError ? [label ('common:fetchError')] : []}/>
|
||||
{!disabled && <PostList posts={sources?.posts ?? []} onSelect={importTags}/>}
|
||||
<div className="flex flex-col gap-2 md:flex-row">
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
disabled={disabled || sourcePage <= 1}
|
||||
onClick={() => setSourcePage (page => page - 1)}>
|
||||
{label ('common:pagination.previous')}
|
||||
</Button>
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
disabled={disabled || sourcePage * 20 >= (sources?.count ?? 0)}
|
||||
onClick={() => setSourcePage (page => page + 1)}>
|
||||
{label ('common:pagination.next')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>)}
|
||||
|
||||
{/* オリジナルの作成日時 */}
|
||||
<PostOriginalCreatedTimeField
|
||||
disabled={disabled}
|
||||
|
||||
@@ -3,7 +3,6 @@ import { useRef } from 'react'
|
||||
import { useLocation } from 'react-router-dom'
|
||||
|
||||
import PrefetchLink from '@/components/PrefetchLink'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { useUITranslation } from '@/lib/useUITranslation'
|
||||
import { useClientBehaviourSettings } from '@/lib/useClientBehaviourSettings'
|
||||
import { cn } from '@/lib/utils'
|
||||
@@ -14,11 +13,10 @@ import type { FC, MouseEvent } from 'react'
|
||||
import type { Post } from '@/types'
|
||||
|
||||
type Props = { posts: Post[]
|
||||
onSelect?: (post: Post) => void
|
||||
onClick?: (event: MouseEvent<HTMLElement>) => void }
|
||||
|
||||
|
||||
const PostList: FC<Props> = ({ posts, onClick, onSelect }) => {
|
||||
const PostList: FC<Props> = ({ posts, onClick }) => {
|
||||
const { label } = useUITranslation ('shared')
|
||||
const location = useLocation ()
|
||||
const behaviourSettings = useClientBehaviourSettings ()
|
||||
@@ -41,63 +39,7 @@ const PostList: FC<Props> = ({ posts, onClick, onSelect }) => {
|
||||
const sharedId = `page-${ post.id }`
|
||||
const layoutId = sharedId
|
||||
|
||||
const card = (
|
||||
<motion.div
|
||||
ref={cardRef}
|
||||
layout={animationMode === 'off' ? false : true}
|
||||
layoutId={(onSelect || animationMode === 'off') ? undefined : layoutId}
|
||||
className={cn ('w-full h-full overflow-hidden rounded-xl shadow',
|
||||
'transform-gpu will-change-transform',
|
||||
(post.childPosts ?? []).length > 0 && 'ring-4 ring-green-500',
|
||||
(post.parentPosts ?? []).length > 0 && 'ring-4 ring-yellow-500')}
|
||||
whileHover={{ scale: 1.02 }}
|
||||
onLayoutAnimationStart={() => {
|
||||
if (!(cardRef.current))
|
||||
return
|
||||
|
||||
cardRef.current.style.position = 'relative'
|
||||
cardRef.current.style.zIndex = '9999'
|
||||
}}
|
||||
onLayoutAnimationComplete={() => {
|
||||
if (!(cardRef.current))
|
||||
return
|
||||
|
||||
cardRef.current.style.zIndex = ''
|
||||
cardRef.current.style.position = ''
|
||||
}}
|
||||
transition={{ layout: cardLayoutTransition }}>
|
||||
{thumbnailMode === 'off'
|
||||
? (
|
||||
<div className="flex h-full w-full items-center justify-center
|
||||
bg-muted text-center text-xs text-muted-foreground">
|
||||
{label ('labels.noThumbnail')}
|
||||
</div>)
|
||||
: (
|
||||
<img
|
||||
src={post.thumbnail || post.thumbnailBase || undefined}
|
||||
alt={post.title || post.url}
|
||||
title={post.title || post.url || undefined}
|
||||
loading={
|
||||
thumbnailMode === 'light'
|
||||
? 'lazy'
|
||||
: (i < 12 ? 'eager' : 'lazy')
|
||||
}
|
||||
decoding="async"
|
||||
className="object-cover w-full h-full"/>)}
|
||||
</motion.div>)
|
||||
|
||||
return onSelect
|
||||
? (
|
||||
<Button
|
||||
key={post.id}
|
||||
type="button"
|
||||
variant="ghost"
|
||||
className="w-40 h-40 p-0"
|
||||
aria-label={post.title || post.url}
|
||||
onClick={() => onSelect (post)}>
|
||||
{card}
|
||||
</Button>)
|
||||
: (
|
||||
return (
|
||||
<PrefetchLink
|
||||
to={`/posts/${ post.id }`}
|
||||
key={post.id}
|
||||
@@ -107,7 +49,51 @@ const PostList: FC<Props> = ({ posts, onClick, onSelect }) => {
|
||||
setForLocationKey (location.key, sharedId)
|
||||
onClick?.(e)
|
||||
}}>
|
||||
{card}
|
||||
<motion.div
|
||||
ref={cardRef}
|
||||
layout={animationMode === 'off' ? false : true}
|
||||
layoutId={animationMode === 'off' ? undefined : layoutId}
|
||||
className={cn ('w-full h-full overflow-hidden rounded-xl shadow',
|
||||
'transform-gpu will-change-transform',
|
||||
(post.childPosts ?? []).length > 0 && 'ring-4 ring-green-500',
|
||||
(post.parentPosts ?? []).length > 0 && 'ring-4 ring-yellow-500')}
|
||||
whileHover={{ scale: 1.02 }}
|
||||
onLayoutAnimationStart={() => {
|
||||
if (!(cardRef.current))
|
||||
return
|
||||
|
||||
cardRef.current.style.position = 'relative'
|
||||
cardRef.current.style.zIndex = '9999'
|
||||
}}
|
||||
onLayoutAnimationComplete={() => {
|
||||
if (!(cardRef.current))
|
||||
return
|
||||
|
||||
cardRef.current.style.zIndex = ''
|
||||
cardRef.current.style.position = ''
|
||||
}}
|
||||
transition={{ layout: cardLayoutTransition }}>
|
||||
{thumbnailMode === 'off'
|
||||
? (
|
||||
<div className="flex h-full w-full items-center justify-center
|
||||
bg-muted text-center text-xs text-muted-foreground">
|
||||
{label ('labels.noThumbnail')}
|
||||
</div>)
|
||||
: (
|
||||
<img
|
||||
src={post.thumbnail || post.thumbnailBase || undefined}
|
||||
alt={post.title || post.url}
|
||||
title={post.title || post.url || undefined}
|
||||
loading={
|
||||
thumbnailMode === 'light'
|
||||
? 'lazy'
|
||||
: i < 12
|
||||
? 'eager'
|
||||
: 'lazy'
|
||||
}
|
||||
decoding="async"
|
||||
className="object-cover w-full h-full"/>)}
|
||||
</motion.div>
|
||||
</PrefetchLink>)
|
||||
})}
|
||||
</div>)
|
||||
|
||||
@@ -29,7 +29,7 @@ import { fetchWikiPage } from '@/lib/wiki'
|
||||
import type { FC, MouseEvent } from 'react'
|
||||
|
||||
import type { AvailableLocale, LocaleCode } from '@/lib/locales'
|
||||
import type { Material, Menu, MenuVisibleItem, Tag, User } from '@/types'
|
||||
import type { Material, Menu, MenuVisibleItem, Tag, User, WikiPage } from '@/types'
|
||||
|
||||
type Props = {
|
||||
user: User | null
|
||||
@@ -39,10 +39,11 @@ type NavDensity = 'auto' | 'comfortable' | 'compact'
|
||||
|
||||
|
||||
export const menuOutline = (
|
||||
{ tag, material, wikiId, user, pathName: fullPathname }: {
|
||||
{ tag, material, wikiId, wikiResourceType, user, pathName: fullPathname }: {
|
||||
tag?: Tag | null
|
||||
material?: Material | null
|
||||
wikiId: number | null
|
||||
wikiResourceType?: WikiPage['resourceType']
|
||||
user: User | null
|
||||
pathName: string },
|
||||
): Menu => {
|
||||
@@ -99,17 +100,30 @@ export const menuOutline = (
|
||||
visible: materialFlg && Boolean (material?.tag) },
|
||||
{ ...message ('history'), to: `/materials/changes?material_id=${ material?.id }`,
|
||||
visible: materialFlg }] },
|
||||
{ ...message ('wiki'), to: '/wiki', subMenu: [
|
||||
{ ...message ('search'), to: '/wiki' },
|
||||
{ ...message ('create'), to: '/wiki/new', visible: editable },
|
||||
{ ...message ('allHistory'), to: '/wiki/changes' },
|
||||
{ ...message ('help'), to: '/wiki/ヘルプ:Wiki' },
|
||||
{ component: <Separator/>, visible: wikiPageFlg },
|
||||
{ ...message ('postsWithCount', { count: postCount }), to: `/posts?tags=${ wikiTitle }`,
|
||||
visible: wikiPageFlg },
|
||||
{ ...message ('history'), to: `/wiki/changes?id=${ wikiId }`, visible: wikiPageFlg },
|
||||
{ ...message ('edit'), to: `/wiki/${ wikiId || wikiTitle }/edit`,
|
||||
visible: wikiPageFlg && editable }] },
|
||||
...([
|
||||
{ key: 'tagDescriptions', path: '/tag-descriptions', type: 'tag_description' },
|
||||
{ key: 'tagGroups', path: '/tag-groups', type: 'tag_group' }] as const)
|
||||
.map (({ key, path, type }): MenuVisibleItem => {
|
||||
const current = (wikiResourceType ?? 'tag_description') === type
|
||||
const detailFlg = wikiPageFlg && current
|
||||
const creationPath =
|
||||
type === 'tag_group'
|
||||
? `/wiki/new?title=${ encodeURIComponent ('タググループ:') }` : '/wiki/new'
|
||||
return { ...message (key), to: path,
|
||||
base: (pathName.startsWith ('/wiki') && current) ? '/wiki' : path,
|
||||
subMenu: [
|
||||
{ ...message ('search'), to: path },
|
||||
{ ...message ('create'), to: creationPath, visible: editable },
|
||||
{ ...message ('allHistory'), to: '/wiki/changes' },
|
||||
{ ...message ('help'), to: '/wiki/ヘルプ:Wiki' },
|
||||
{ component: <Separator/>, visible: detailFlg },
|
||||
{ ...message ('postsWithCount', { count: postCount }),
|
||||
to: `/posts?tags=${ wikiTitle }`, visible: detailFlg },
|
||||
{ ...message ('history'), to: `/wiki/changes?id=${ wikiId }`,
|
||||
visible: detailFlg },
|
||||
{ ...message ('edit'), to: `/wiki/${ wikiId || wikiTitle }/edit`,
|
||||
visible: detailFlg && editable }] }
|
||||
}),
|
||||
{ ...message ('help'), to: '/help/home', base: '/help', subMenu: [
|
||||
{ ...message ('search'), to: '/help' },
|
||||
{ ...message ('allHistory'), to: '/help/changes' },
|
||||
@@ -229,7 +243,8 @@ const TopNav: FC<Props> = ({ user, locales, resolveLocaleSwitch }) => {
|
||||
queryKey: materialsKeys.show (effectiveTitle, locale),
|
||||
queryFn: () => fetchMaterial (effectiveTitle, locale) })
|
||||
|
||||
const menu = menuOutline ({ tag, material, wikiId, user, pathName: location.pathname })
|
||||
const menu = menuOutline ({ tag, material, wikiId,
|
||||
wikiResourceType: wikiPage?.resourceType, user, pathName: location.pathname })
|
||||
const visibleMenu = menu.filter ((item): item is MenuVisibleItem => item.visible ?? true)
|
||||
const menuLabels = visibleMenu.map (item => item.name).join ('\u0000')
|
||||
const moreMenu = menu.filter (item =>
|
||||
|
||||
@@ -100,10 +100,11 @@ const prefetchHelpDiff: Prefetcher = async (qc, url, locale) => {
|
||||
|
||||
const prefetchWikiPagesIndex: Prefetcher = async (qc, url, locale) => {
|
||||
const title = url.searchParams.get ('title') ?? ''
|
||||
const resourceType = url.pathname === '/tag-groups' ? 'tag_group' : 'tag_description'
|
||||
|
||||
await qc.prefetchQuery ({
|
||||
queryKey: wikiKeys.index ({ title }, locale),
|
||||
queryFn: () => fetchWikiPages ({ title }, locale) })
|
||||
queryKey: wikiKeys.index ({ title, resourceType }, locale),
|
||||
queryFn: () => fetchWikiPages ({ title, resourceType }, locale) })
|
||||
}
|
||||
|
||||
|
||||
@@ -310,7 +311,8 @@ export const routePrefetchers: { test: (u: URL) => boolean; run: Prefetcher }[]
|
||||
&& Boolean (mPost (u.pathname))),
|
||||
run: prefetchPostShow },
|
||||
{ test: u => u.pathname === '/posts/changes', run: prefetchPostChanges },
|
||||
{ test: u => u.pathname === '/wiki', run: prefetchWikiPagesIndex },
|
||||
{ test: u => ['/wiki', '/tag-descriptions', '/tag-groups'].includes (u.pathname),
|
||||
run: prefetchWikiPagesIndex },
|
||||
{ test: u => (!(['/wiki/new', '/wiki/changes'].includes (u.pathname))
|
||||
&& Boolean (mWiki (u.pathname))),
|
||||
run: prefetchWikiPageShow },
|
||||
|
||||
@@ -5,6 +5,7 @@ import type {
|
||||
FetchPostsParams,
|
||||
FetchTagsParams,
|
||||
MaterialFilter,
|
||||
WikiPage,
|
||||
WikiTagReference } from '@/types'
|
||||
|
||||
export const localesKeys = {
|
||||
@@ -130,7 +131,7 @@ export const wikiKeys = {
|
||||
autolinkCandidates: (language: string, locale: LocaleCode) =>
|
||||
['wiki', 'autolink', locale, language] as const,
|
||||
index: (
|
||||
p: { title?: string },
|
||||
p: { title?: string, resourceType?: WikiPage['resourceType'] },
|
||||
locale: LocaleCode = 'ja',
|
||||
) => ['wiki', locale, 'index', p] as const,
|
||||
show: (
|
||||
|
||||
@@ -24,10 +24,10 @@ export const fetchWikiChanges = (
|
||||
|
||||
|
||||
export const fetchWikiPages = async (
|
||||
{ title }: { title?: string },
|
||||
{ title, resourceType }: { title?: string, resourceType?: WikiPage['resourceType'] },
|
||||
locale: LocaleCode = 'ja',
|
||||
): Promise<WikiPage[]> =>
|
||||
await apiGet ('/wiki', { locale, params: { title } })
|
||||
await apiGet ('/wiki', { locale, params: { title, resource_type: resourceType } })
|
||||
|
||||
|
||||
export const fetchWikiPage = async (
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
"materials": "チカㇻペ",
|
||||
"suppressions": "アエアイカㇷ゚テㇷ゚",
|
||||
"wiki": "Wiki",
|
||||
"tagDescriptions": "$t(counts:resources.tag_descriptions)",
|
||||
"tagGroups": "$t(counts:resources.tag_groups)",
|
||||
"create": "アシㇼ",
|
||||
"edit": "イヌイェㇷ゚",
|
||||
"entertainment": "シノッ",
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
{
|
||||
"_untranslated": ["edit.import"],
|
||||
"list": {
|
||||
"tagline": "{{brand}}",
|
||||
"empty": "ミンタㇻ タ ネン カ イサㇺ",
|
||||
@@ -32,7 +31,6 @@
|
||||
"showExternal": "ソイタㇰ ソㇱ アヌカレ"
|
||||
},
|
||||
"edit": {
|
||||
"import": "インポート",
|
||||
"validationFailed": "アシㇼ カㇻ カ エアイカㇷ゚……",
|
||||
"conflictTitle": "モㇱマ クㇽ アシㇼ カㇻ ワ アン!",
|
||||
"conflictDescription": "モㇱマ イカㇻ クㇽ エエトコ アシㇼ カㇻ ワ アン。",
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
"materials": "素材",
|
||||
"suppressions": "抑止",
|
||||
"wiki": "Wiki",
|
||||
"tagDescriptions": "$t(counts:resources.tag_descriptions)",
|
||||
"tagGroups": "$t(counts:resources.tag_groups)",
|
||||
"create": "新規",
|
||||
"edit": "編輯",
|
||||
"entertainment": "おたのしみ",
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
"question": "表示しますか?", "showExternal": "外部ページを表示"
|
||||
},
|
||||
"edit": {
|
||||
"import": "インポート",
|
||||
"validationFailed": "更新はできなかったよ……",
|
||||
"conflictTitle": "競合が発生しました.",
|
||||
"conflictDescription": "ほかの耕作員が先に更新してゐます.",
|
||||
|
||||
@@ -135,7 +135,7 @@ const MaterialDetailPage: FC = () => {
|
||||
|
||||
<TabGroup>
|
||||
{material.tag && (
|
||||
<Tab name={label ('navigation:wiki')}>
|
||||
<Tab name={label ('navigation:tagDescriptions')}>
|
||||
<WikiBody
|
||||
title={material.tag.name}
|
||||
language={localeLanguage (locale)}
|
||||
|
||||
@@ -176,7 +176,7 @@ const PostListPage: FC = () => {
|
||||
{loading && label ('common:loading')}
|
||||
</Tab>
|
||||
{tags.length === 1 && (
|
||||
<Tab name={label ('navigation:wiki')}>
|
||||
<Tab name={label ('navigation:tagDescriptions')}>
|
||||
<WikiBody title={tags[0]} body={wikiPage?.body}
|
||||
language={wikiPage?.languageCode ?? (wikiPage?.resourceType === 'tag_description'
|
||||
? localeLanguage (locale) : 'und')}/>
|
||||
|
||||
@@ -51,7 +51,8 @@ const WikiDetailPage: FC = () => {
|
||||
queryKey: helpKeys.titles ('ja'),
|
||||
queryFn: () => getHelpTitleIndex ('ja'),
|
||||
staleTime: Infinity })
|
||||
const lookupTitle = title.trim ().normalize ('NFKC').toLowerCase ().replace (/^ヘルプ:/, '')
|
||||
const lookupTitle = title.trim ().normalize ('NFKC').toLowerCase ()
|
||||
.replace (/^(?:ヘルプ|手引):/, '')
|
||||
const identifiers = useMemo (() => (
|
||||
(titleIndex != null && Object.hasOwn (titleIndex, lookupTitle))
|
||||
? titleIndex[lookupTitle] : []), [titleIndex, lookupTitle])
|
||||
|
||||
@@ -8,7 +8,7 @@ import FormField from '@/components/common/FormField'
|
||||
import PageTitle from '@/components/common/PageTitle'
|
||||
import MainArea from '@/components/layout/MainArea'
|
||||
import PageHead from '@/components/common/PageHead'
|
||||
import { apiGet } from '@/lib/api'
|
||||
import { fetchWikiPages } from '@/lib/wiki'
|
||||
import { wikiKeys } from '@/lib/queryKeys'
|
||||
import { dateString, inputClass } from '@/lib/utils'
|
||||
|
||||
@@ -17,16 +17,20 @@ import type { FormEvent , FC } from 'react'
|
||||
import type { WikiPage } from '@/types'
|
||||
|
||||
|
||||
const WikiSearchPage: FC = () => {
|
||||
const WikiSearchPage: FC<{ resourceType?: WikiPage['resourceType'] }> = (
|
||||
{ resourceType = 'tag_description' },
|
||||
) => {
|
||||
const { message, label } = useUITranslation ('shared')
|
||||
const locale = useLocale ()
|
||||
const heading =
|
||||
resourceType === 'tag_group'
|
||||
? 'navigation:tagGroups' : 'navigation:tagDescriptions'
|
||||
const [title, setTitle] = useState ('')
|
||||
const [text, setText] = useState ('')
|
||||
const [submittedTitle, setSubmittedTitle] = useState ('')
|
||||
const { data: results = [], refetch } = useQuery ({
|
||||
queryKey: wikiKeys.index ({ title: submittedTitle }, locale),
|
||||
queryFn: () => apiGet<WikiPage[]> ('/wiki', {
|
||||
locale, params: { title: submittedTitle } }) })
|
||||
queryKey: wikiKeys.index ({ title: submittedTitle, resourceType }, locale),
|
||||
queryFn: () => fetchWikiPages ({ title: submittedTitle, resourceType }, locale) })
|
||||
|
||||
const handleSearch = (ev: FormEvent) => {
|
||||
ev.preventDefault ()
|
||||
@@ -42,10 +46,10 @@ const WikiSearchPage: FC = () => {
|
||||
|
||||
return (
|
||||
<MainArea>
|
||||
<PageHead title={message ('navigation:wiki')}/>
|
||||
<PageHead title={message (heading)}/>
|
||||
|
||||
<div className="max-w-xl">
|
||||
<PageTitle>{label ('navigation:wiki')}</PageTitle>
|
||||
<PageTitle>{label (heading)}</PageTitle>
|
||||
<form onSubmit={handleSearch} className="space-y-2">
|
||||
{/* タイトル */}
|
||||
<FormField label={label ('labels.title')}>
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする