This commit is contained in:
2025-05-24 06:23:34 +09:00
parent 1b1392be4d
commit 643080ef76
3 changed files with 14 additions and 5 deletions
+5 -3
View File
@@ -1,6 +1,6 @@
import React, { useEffect, useState } from 'react'
import axios from 'axios'
import { Link } from 'react-router-dom'
import { Link, useParams } from 'react-router-dom'
import { API_BASE_URL } from '../config'
import TagSearch from './TagSearch'
@@ -17,12 +17,14 @@ const tagNameMap: { [key: string]: string } = {
nico: 'ニコニコタグ' }
const TagSidebar: React.FC = () => {
const { postId } = useParams<{ postId?: number }> ()
const [tags, setTags] = useState<TagByCategory> ({ })
useEffect(() => {
const fetchTags = async () => {
try {
const response = await axios.get (`${API_BASE_URL}/tags`)
const response = await axios.get (`${API_BASE_URL}/tags`
+ (postId ? `?post=${ postId }` : ''))
const tagsTmp: TagByCategory = { }
for (const tag of response.data)
{
@@ -37,7 +39,7 @@ const TagSidebar: React.FC = () => {
}
fetchTags()
}, [])
}, [postId])
return (
<div className="w-64 bg-gray-100 p-4 border-r border-gray-200 h-full">