This commit is contained in:
@@ -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">
|
||||
|
||||
Reference in New Issue
Block a user