|
|
@@ -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"> |
|
|
|