This commit is contained in:
2025-07-03 01:26:32 +09:00
parent 42cf25246f
commit f47d7bbb87
4 changed files with 81 additions and 31 deletions
+10 -2
View File
@@ -7,6 +7,7 @@ import TagSearch from '@/components/TagSearch'
import SectionTitle from '@/components/common/SectionTitle'
import SidebarComponent from '@/components/layout/SidebarComponent'
import { API_BASE_URL } from '@/config'
import { CATEGORIES } from '@/consts'
import type { Post, Tag } from '@/types'
@@ -27,6 +28,8 @@ export default ({ posts }: Props) => {
useEffect (() => {
const tagsTmp: TagByCategory = { }
let cnt = 0
loop:
for (const post of posts)
{
for (const tag of post.tags)
@@ -34,7 +37,12 @@ export default ({ posts }: Props) => {
if (!(tag.category in tagsTmp))
tagsTmp[tag.category] = []
if (!(tagsTmp[tag.category].map (t => t.id).includes (tag.id)))
tagsTmp[tag.category].push (tag)
{
tagsTmp[tag.category].push (tag)
++cnt
if (cnt >= 25)
break loop
}
}
}
for (const cat of Object.keys (tagsTmp))
@@ -47,7 +55,7 @@ export default ({ posts }: Props) => {
<TagSearch />
<SectionTitle></SectionTitle>
<ul>
{['general', 'deerjikist', 'nico'].map (cat => cat in tags && (
{CATEGORIES.map (cat => cat in tags && (
<>
{tags[cat].map (tag => (
<li key={tag.id} className="mb-1">