- Published on
import Link from '@/components/Link' import Tag from '@/components/Tag' import siteMetadata from '@/data/siteMetadata' import { useState } from 'react' import Pagination from '@/components/Pagination' import formatDate from '@/lib/utils/formatDate' export default function ListLayout({ posts, title, initialDisplayPosts = [], pagination }) { const [searchValue, setSearchValue] = useState('') const filteredBlogPosts = posts.filter((frontMatter) => { const searchContent = frontMatter.title + frontMatter.summary + frontMatter.tags.join(' ') return searchContent.toLowerCase().includes(searchValue.toLowerCase()) }) // If initialDisplayPosts exist, display it if no searchValue is specified const displayPosts = initialDisplayPosts.length > 0 && !searchValue ? initialDisplayPosts : filteredBlogPosts return ( <>