diff --git a/backend/app/controllers/wiki_pages_controller.rb b/backend/app/controllers/wiki_pages_controller.rb
index 9ac9992..c068fcc 100644
--- a/backend/app/controllers/wiki_pages_controller.rb
+++ b/backend/app/controllers/wiki_pages_controller.rb
@@ -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 =
diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx
index a6799ad..5626212 100644
--- a/frontend/src/App.tsx
+++ b/frontend/src/App.tsx
@@ -166,7 +166,13 @@ export const pageRoutes = (
robots: 'noindex', authentication: 'user' } },
{ path: ':id', element: ,
handle: { preload: MaterialDetailPage.preload, sitemap: ['materials'] } }] },
- { path: 'wiki', element: ,
+ { path: 'wiki', element: ,
+ handle: { redirectTo: '/tag-descriptions' } },
+ { path: 'tag-descriptions',
+ element: ,
+ handle: { preload: WikiSearchPage.preload, sitemap: ['static'] } },
+ { path: 'tag-groups',
+ element: ,
handle: { preload: WikiSearchPage.preload, sitemap: ['static'] } },
{ path: 'wiki/:title', element: ,
handle: { preload: WikiDetailPage.preload, switchLocale: switchWikiLocale,
diff --git a/frontend/src/components/TopNav.tsx b/frontend/src/components/TopNav.tsx
index 22dc2dd..6810a85 100644
--- a/frontend/src/components/TopNav.tsx
+++ b/frontend/src/components/TopNav.tsx
@@ -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: , 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: , 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 = ({ 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 =>
diff --git a/frontend/src/lib/prefetchers.ts b/frontend/src/lib/prefetchers.ts
index 65dd142..20de1b0 100644
--- a/frontend/src/lib/prefetchers.ts
+++ b/frontend/src/lib/prefetchers.ts
@@ -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 },
diff --git a/frontend/src/lib/queryKeys.ts b/frontend/src/lib/queryKeys.ts
index 7e1d09c..2d20b9e 100644
--- a/frontend/src/lib/queryKeys.ts
+++ b/frontend/src/lib/queryKeys.ts
@@ -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: (
diff --git a/frontend/src/lib/wiki.ts b/frontend/src/lib/wiki.ts
index 743a6ee..753e29c 100644
--- a/frontend/src/lib/wiki.ts
+++ b/frontend/src/lib/wiki.ts
@@ -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 =>
- await apiGet ('/wiki', { locale, params: { title } })
+ await apiGet ('/wiki', { locale, params: { title, resource_type: resourceType } })
export const fetchWikiPage = async (
diff --git a/frontend/src/locales/ain-Kana/navigation.json b/frontend/src/locales/ain-Kana/navigation.json
index 02e4509..24925b0 100644
--- a/frontend/src/locales/ain-Kana/navigation.json
+++ b/frontend/src/locales/ain-Kana/navigation.json
@@ -14,6 +14,8 @@
"materials": "チカㇻペ",
"suppressions": "アエアイカㇷ゚テㇷ゚",
"wiki": "Wiki",
+ "tagDescriptions": "$t(counts:resources.tag_descriptions)",
+ "tagGroups": "$t(counts:resources.tag_groups)",
"create": "アシㇼ",
"edit": "イヌイェㇷ゚",
"entertainment": "シノッ",
diff --git a/frontend/src/locales/ja/navigation.json b/frontend/src/locales/ja/navigation.json
index 5e00f5e..9a375c3 100644
--- a/frontend/src/locales/ja/navigation.json
+++ b/frontend/src/locales/ja/navigation.json
@@ -13,6 +13,8 @@
"materials": "素材",
"suppressions": "抑止",
"wiki": "Wiki",
+ "tagDescriptions": "$t(counts:resources.tag_descriptions)",
+ "tagGroups": "$t(counts:resources.tag_groups)",
"create": "新規",
"edit": "編輯",
"entertainment": "おたのしみ",
diff --git a/frontend/src/pages/materials/MaterialDetailPage.tsx b/frontend/src/pages/materials/MaterialDetailPage.tsx
index 957d2c8..62ed374 100644
--- a/frontend/src/pages/materials/MaterialDetailPage.tsx
+++ b/frontend/src/pages/materials/MaterialDetailPage.tsx
@@ -135,7 +135,7 @@ const MaterialDetailPage: FC = () => {
{material.tag && (
-
+
{
{loading && label ('common:loading')}
{tags.length === 1 && (
-
+
diff --git a/frontend/src/pages/wiki/WikiDetailPage.tsx b/frontend/src/pages/wiki/WikiDetailPage.tsx
index 758925a..d5a5099 100644
--- a/frontend/src/pages/wiki/WikiDetailPage.tsx
+++ b/frontend/src/pages/wiki/WikiDetailPage.tsx
@@ -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])
diff --git a/frontend/src/pages/wiki/WikiSearchPage.tsx b/frontend/src/pages/wiki/WikiSearchPage.tsx
index 412ca15..ad3b4c3 100644
--- a/frontend/src/pages/wiki/WikiSearchPage.tsx
+++ b/frontend/src/pages/wiki/WikiSearchPage.tsx
@@ -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 ('/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 (
-
+
-
{label ('navigation:wiki')}
+
{label (heading)}