// @ts-nocheck
import { useParams } from "react-router"
import MainTemplate from "./MainTemplate"
import PostListing from "@/containers/PostListing"
import { usePosts } from "@/hooks/usePosts"

const TagTemplate = () => {
  const { tag } = useParams()
  const { posts } = usePosts()

  const filteredPosts = posts.filter((post) => post.tags.includes(tag))

  return (
    <MainTemplate>
      <PostListing title={`Posts tagged: #${tag}`} posts={filteredPosts} />
    </MainTemplate>
  )
}

export default TagTemplate
