/* eslint-disable jsx-a11y/anchor-is-valid */ 'use client' import { usePathname } from 'next/navigation' import { slug } from 'github-slugger' import { formatDate } from 'pliny/utils/formatDate' import { CoreContent } from 'pliny/utils/contentlayer' import type { Blog } from 'contentlayer/generated' import Link from '@/components/Link' import Tag from '@/components/Tag' import siteMetadata from '@/data/siteMetadata' import tagData from 'app/tag-data.json' interface PaginationProps { totalPages: number currentPage: number } interface ListLayoutProps { posts: CoreContent[] title: string initialDisplayPosts?: CoreContent[] pagination?: PaginationProps } function Pagination({ totalPages, currentPage }: PaginationProps) { const pathname = usePathname() const basePath = pathname.split('/')[1] const prevPage = currentPage - 1 > 0 const nextPage = currentPage + 1 <= totalPages return (
) } export default function ListLayoutWithTags({ posts, title, initialDisplayPosts = [], pagination, }: ListLayoutProps) { const pathname = usePathname() const tagCounts = tagData as Record const tagKeys = Object.keys(tagCounts) const sortedTags = tagKeys.sort((a, b) => tagCounts[b] - tagCounts[a]) const displayPosts = initialDisplayPosts.length > 0 ? initialDisplayPosts : posts return ( <>

{title}

{pathname.startsWith('/blog') ? (

All Posts

) : ( All Posts )}
    {sortedTags.map((t) => { return (
  • {decodeURI(pathname.split('/tags/')[1]) === slug(t) ? (

    {`${t} (${tagCounts[t]})`}

    ) : ( {`${t} (${tagCounts[t]})`} )}
  • ) })}
    {displayPosts.map((post) => { const { path, date, title, summary, tags } = post return (
  • Published on

    {title}

    {tags?.map((tag) => )}
    {summary}
  • ) })}
{pagination && pagination.totalPages > 1 && ( )}
) }