import { Fragment, useEffect, useState } from 'react' import { Helmet } from 'react-helmet-async' import { useLocation } from 'react-router-dom' import nikumaru from '@/assets/fonts/nikumaru.otf' import PrefetchLink from '@/components/PrefetchLink' import TagLink from '@/components/TagLink' import PageTitle from '@/components/common/PageTitle' import SectionTitle from '@/components/common/SectionTitle' import SubsectionTitle from '@/components/common/SubsectionTitle' import MainArea from '@/components/layout/MainArea' import { SITE_TITLE } from '@/config' import { apiGet } from '@/lib/api' import type { FC } from 'react' import type { Material, Tag } from '@/types' type TagWithMaterial = Omit & { children: TagWithMaterial[] material: Material | null } const MaterialCard = ({ tag }: { tag: TagWithMaterial }) => { if (!(tag.material)) return return (
{(tag.material.contentType && /image\/.*/.test (tag.material.contentType)) ? : 照会}
) } const MaterialListPage: FC = () => { const [loading, setLoading] = useState (false) const [tag, setTag] = useState (null) const location = useLocation () const query = new URLSearchParams (location.search) const tagQuery = query.get ('tag') ?? '' useEffect (() => { if (!(tagQuery)) { setTag (null) return } void (async () => { try { setLoading (true) setTag ( await apiGet ( `/tags/name/${ encodeURIComponent (tagQuery) }/materials`)) } finally { setLoading (false) } }) () }, [location.search, tagQuery]) return ( {`${ tag ? `${ tag.name } 素材集` : '素材集' } | ${ SITE_TITLE }`} {loading ? 'Loading...' : ( tag ? ( <> {(!(tag.material) && tag.category !== 'meme') && (
追加
)}
{tag.children.map (c2 => ( {(!(c2.material) && c2.category !== 'meme') && (
追加
)}
{c2.children.map (c3 => ( {(!(c3.material) && c3.category !== 'meme') && (
追加
)}
))}
))}
) : ( <>

左のリストから照会したいタグを選択してください。

もしくは……

))}
) } export default MaterialListPage