feat: improve search to include summary and tags

This commit is contained in:
Timothy 2021-01-31 10:42:05 +08:00
parent 84a2bceb13
commit f43d6c3702

View File

@ -7,9 +7,10 @@ const postDateTemplate = tinytime('{MMMM} {DD}, {YYYY}')
export default function ListLayout({ posts, title }) {
const [searchValue, setSearchValue] = useState('')
const filteredBlogPosts = posts.filter((frontMatter) =>
frontMatter.title.toLowerCase().includes(searchValue.toLowerCase())
)
const filteredBlogPosts = posts.filter((frontMatter) => {
const searchContent = frontMatter.title + frontMatter.summary + frontMatter.tags.join(' ')
return searchContent.toLowerCase().includes(searchValue.toLowerCase())
})
return (
<>