This commit is contained in:
2025-07-06 19:57:20 +09:00
parent da31fe93c4
commit 191e5d3a76
22 changed files with 344 additions and 231 deletions
+1 -1
View File
@@ -47,7 +47,7 @@ export default ({ post }: Props) => {
<SidebarComponent>
<TagSearch />
{CATEGORIES.map ((cat: Category) => cat in tags && (
<div className="my-3">
<div className="my-3" key={cat}>
<SubsectionTitle>{categoryNames[cat]}</SubsectionTitle>
<ul>
{tags[cat].map (tag => (
+45 -47
View File
@@ -32,18 +32,18 @@ export default ({ posts }: Props) => {
loop:
for (const post of posts)
{
for (const tag of post.tags)
{
if (!(tag.category in tagsTmp))
tagsTmp[tag.category] = []
if (!(tagsTmp[tag.category].map (t => t.id).includes (tag.id)))
{
tagsTmp[tag.category].push (tag)
++cnt
if (cnt >= 25)
break loop
}
}
for (const tag of post.tags)
{
if (!(tag.category in tagsTmp))
tagsTmp[tag.category] = []
if (!(tagsTmp[tag.category].map (t => t.id).includes (tag.id)))
{
tagsTmp[tag.category].push (tag)
++cnt
if (cnt >= 25)
break loop
}
}
}
for (const cat of Object.keys (tagsTmp))
tagsTmp[cat].sort ((tagA, tagB) => tagA.name < tagB.name ? -1 : 1)
@@ -52,40 +52,38 @@ export default ({ posts }: Props) => {
return (
<SidebarComponent>
<TagSearch />
<SectionTitle></SectionTitle>
<ul>
{CATEGORIES.map (cat => cat in tags && (
<>
{tags[cat].map (tag => (
<li key={tag.id} className="mb-1">
<Link to={`/posts?${ (new URLSearchParams ({ tags: tag.name })).toString () }`}>
{tag.name}
</Link>
<span className="ml-1">{tag.postCount}</span>
</li>))}
</>))}
</ul>
<SectionTitle></SectionTitle>
{posts.length && (
<a href="#"
onClick={ev => {
ev.preventDefault ()
void ((async () => {
try
{
const { data } = await axios.get (`${ API_BASE_URL }/posts/random`,
{ params: { tags: tagsQuery.split (' ').filter (e => e !== '').join (','),
match: (anyFlg ? 'any' : 'all') } })
navigate (`/posts/${ (data as Post).id }`)
}
catch
{
;
}
}) ())
}}>
</a>)}
<TagSearch />
<SectionTitle></SectionTitle>
<ul>
{CATEGORIES.flatMap (cat => cat in tags ? (
tags[cat].map (tag => (
<li key={tag.id} className="mb-1">
<Link to={`/posts?${ (new URLSearchParams ({ tags: tag.name })).toString () }`}>
{tag.name}
</Link>
<span className="ml-1">{tag.postCount}</span>
</li>))) : [])}
</ul>
<SectionTitle></SectionTitle>
{posts.length && (
<a href="#"
onClick={ev => {
ev.preventDefault ()
void ((async () => {
try
{
const { data } = await axios.get (`${ API_BASE_URL }/posts/random`,
{ params: { tags: tagsQuery.split (' ').filter (e => e !== '').join (','),
match: (anyFlg ? 'any' : 'all') } })
navigate (`/posts/${ (data as Post).id }`)
}
catch
{
;
}
}) ())
}}>
</a>)}
</SidebarComponent>)
}
@@ -0,0 +1,21 @@
import { Button } from '@/components/ui/button'
import { Dialog,
DialogContent,
DialogDescription,
DialogTitle,
DialogTrigger } from '@/components/ui/dialog'
type Props = { visible: boolean
onVisibleChange: (visible: boolean) => void
user: User | null,
setUser: (user: User) => void }
export default ({ visible, onVisibleChange, user, setUser }: Props) => {
return (
<Dialog open={visible} onOpenChange={onVisibleChange}>
<DialogContent className="space-y-6">
<DialogTitle></DialogTitle>
</DialogContent>
</Dialog>)
}
@@ -0,0 +1,32 @@
import { Button } from '@/components/ui/button'
import { Dialog,
DialogContent,
DialogDescription,
DialogTitle,
DialogTrigger } from '@/components/ui/dialog'
type Props = { visible: boolean
onVisibleChange: (visible: boolean) => void
user: User | null }
export default ({ visible, onVisibleChange, user }: Props) => {
return (
<Dialog open={visible} onOpenChange={onVisibleChange}>
<DialogContent className="space-y-6">
<DialogTitle></DialogTitle>
<div>
<p></p>
<div className="m-2">{user?.inheritanceCode}</div>
<p className="mt-1 text-sm text-red-500">
!
</p>
<div className="my-4">
<Button className="px-4 py-2 bg-red-600 text-white rounded disabled:bg-gray-400">
</Button>
</div>
</div>
</DialogContent>
</Dialog>)
}