Merge branch '#23'
This commit is contained in:
@@ -42,7 +42,7 @@ export default ({ status }: Props) => {
|
|||||||
<meta name="robots" content="noindex" />
|
<meta name="robots" content="noindex" />
|
||||||
<title>{title} | {SITE_TITLE}</title>
|
<title>{title} | {SITE_TITLE}</title>
|
||||||
</Helmet>
|
</Helmet>
|
||||||
<div className="text-2xl sm:text-4xl md:text-6xl font-bold text-transparent
|
<div className="text-6xl font-bold text-transparent
|
||||||
bg-[linear-gradient(90deg,#ff0000,#ff8800,#ffff00,#00ff00,#00ffff,#0000ff,#ff00ff,#ff0000)]
|
bg-[linear-gradient(90deg,#ff0000,#ff8800,#ffff00,#00ff00,#00ffff,#0000ff,#ff00ff,#ff0000)]
|
||||||
bg-clip-text bg-[length:200%_100%] animate-rainbow-scroll drop-shadow-[0_0_6px_black]
|
bg-clip-text bg-[length:200%_100%] animate-rainbow-scroll drop-shadow-[0_0_6px_black]
|
||||||
space-y-2 sm:space-y-4 md:space-y-6 text-center flex flex-col justify-center items-center"
|
space-y-2 sm:space-y-4 md:space-y-6 text-center flex flex-col justify-center items-center"
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ const TagSearch: React.FC = () => {
|
|||||||
}, [location.search])
|
}, [location.search])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="relative w-full mb-4">
|
<div className="relative w-full">
|
||||||
<input type="text"
|
<input type="text"
|
||||||
placeholder="タグ検索..."
|
placeholder="タグ検索..."
|
||||||
value={search}
|
value={search}
|
||||||
|
|||||||
@@ -8,10 +8,11 @@ import SectionTitle from '@/components/common/SectionTitle'
|
|||||||
import SidebarComponent from '@/components/layout/SidebarComponent'
|
import SidebarComponent from '@/components/layout/SidebarComponent'
|
||||||
import { API_BASE_URL } from '@/config'
|
import { API_BASE_URL } from '@/config'
|
||||||
import { CATEGORIES } from '@/consts'
|
import { CATEGORIES } from '@/consts'
|
||||||
|
import { cn } from '@/lib/utils'
|
||||||
|
|
||||||
import type { Post, Tag } from '@/types'
|
import type { Post, Tag } from '@/types'
|
||||||
|
|
||||||
type TagByCategory = { [key: string]: Tag[] }
|
type TagByCategory = Record<string, Tag[]>
|
||||||
|
|
||||||
type Props = { posts: Post[] }
|
type Props = { posts: Post[] }
|
||||||
|
|
||||||
@@ -19,6 +20,7 @@ type Props = { posts: Post[] }
|
|||||||
export default ({ posts }: Props) => {
|
export default ({ posts }: Props) => {
|
||||||
const navigate = useNavigate ()
|
const navigate = useNavigate ()
|
||||||
|
|
||||||
|
const [tagsVsbl, setTagsVsbl] = useState (false)
|
||||||
const [tags, setTags] = useState<TagByCategory> ({ })
|
const [tags, setTags] = useState<TagByCategory> ({ })
|
||||||
|
|
||||||
const location = useLocation ()
|
const location = useLocation ()
|
||||||
@@ -57,34 +59,44 @@ export default ({ posts }: Props) => {
|
|||||||
return (
|
return (
|
||||||
<SidebarComponent>
|
<SidebarComponent>
|
||||||
<TagSearch />
|
<TagSearch />
|
||||||
<SectionTitle>タグ</SectionTitle>
|
<div className={cn (!(tagsVsbl) && 'hidden', 'md:block mt-4')}>
|
||||||
<ul>
|
<SectionTitle>タグ</SectionTitle>
|
||||||
{CATEGORIES.flatMap (cat => cat in tags ? (
|
<ul>
|
||||||
tags[cat].map (tag => (
|
{CATEGORIES.flatMap (cat => cat in tags ? (
|
||||||
<li key={tag.id} className="mb-1">
|
tags[cat].map (tag => (
|
||||||
<TagLink tag={tag} />
|
<li key={tag.id} className="mb-1">
|
||||||
</li>))) : [])}
|
<TagLink tag={tag} />
|
||||||
</ul>
|
</li>))) : [])}
|
||||||
<SectionTitle>関聯</SectionTitle>
|
</ul>
|
||||||
{posts.length > 0 && (
|
<SectionTitle>関聯</SectionTitle>
|
||||||
<a href="#"
|
{posts.length > 0 && (
|
||||||
onClick={ev => {
|
<a href="#"
|
||||||
ev.preventDefault ()
|
onClick={ev => {
|
||||||
void ((async () => {
|
ev.preventDefault ()
|
||||||
try
|
void ((async () => {
|
||||||
{
|
try
|
||||||
const { data } = await axios.get (`${ API_BASE_URL }/posts/random`,
|
{
|
||||||
{ params: { tags: tagsQuery.split (' ').filter (e => e !== '').join (','),
|
const { data } = await axios.get (`${ API_BASE_URL }/posts/random`,
|
||||||
match: (anyFlg ? 'any' : 'all') } })
|
{ params: { tags: tagsQuery.split (' ').filter (e => e !== '').join (','),
|
||||||
navigate (`/posts/${ (data as Post).id }`)
|
match: (anyFlg ? 'any' : 'all') } })
|
||||||
}
|
navigate (`/posts/${ (data as Post).id }`)
|
||||||
catch
|
}
|
||||||
{
|
catch
|
||||||
;
|
{
|
||||||
}
|
;
|
||||||
}) ())
|
}
|
||||||
}}>
|
}) ())
|
||||||
ランダム
|
}}>
|
||||||
</a>)}
|
ランダム
|
||||||
|
</a>)}
|
||||||
|
</div>
|
||||||
|
<a href="#"
|
||||||
|
className="md:hidden block my-2 text-center text-sm text-gray-500"
|
||||||
|
onClick={ev => {
|
||||||
|
ev.preventDefault ()
|
||||||
|
setTagsVsbl (!(tagsVsbl))
|
||||||
|
}}>
|
||||||
|
{tagsVsbl ? '▲▲▲ タグ一覧を閉じる ▲▲▲' : '▼▼▼ タグ一覧を表示 ▼▼▼'}
|
||||||
|
</a>
|
||||||
</SidebarComponent>)
|
</SidebarComponent>)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,9 +85,9 @@ export default () => {
|
|||||||
: `${ SITE_TITLE } 〜 ぼざろクリーチャーシリーズ綜合リンク集サイト`}
|
: `${ SITE_TITLE } 〜 ぼざろクリーチャーシリーズ綜合リンク集サイト`}
|
||||||
</title>
|
</title>
|
||||||
</Helmet>
|
</Helmet>
|
||||||
<div className="hidden md:block">
|
|
||||||
<TagSidebar posts={posts.slice (0, 20)} />
|
<TagSidebar posts={posts.slice (0, 20)} />
|
||||||
</div>
|
|
||||||
<MainArea>
|
<MainArea>
|
||||||
<TabGroup>
|
<TabGroup>
|
||||||
<Tab name="広場">
|
<Tab name="広場">
|
||||||
@@ -120,8 +120,5 @@ export default () => {
|
|||||||
</Tab>)}
|
</Tab>)}
|
||||||
</TabGroup>
|
</TabGroup>
|
||||||
</MainArea>
|
</MainArea>
|
||||||
<div className="md:hidden">
|
|
||||||
<TagSidebar posts={posts.slice (0, 20)} />
|
|
||||||
</div>
|
|
||||||
</div>)
|
</div>)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user