forked from QuantStack/quantstack.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.tsx
58 lines (53 loc) · 1.84 KB
/
index.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import styles from "./styles.module.css";
import React, { useState } from "react";
import BlogpostCard from "./BlogpostCard";
export default function BlogsComponent({ blogpostsDetails }) {
const numberOfBlogs = blogpostsDetails.length;
const [searchField, setSearchField] = useState("");
const filteredBlogPosts = blogpostsDetails.filter((blogpost) => {
return (
blogpost.title.toLowerCase().includes(searchField.toLowerCase()) ||
blogpost.authors.toLowerCase().includes(searchField.toLowerCase()) ||
blogpost.date.toLowerCase().includes(searchField.toLowerCase()) ||
blogpost.summary.toLowerCase().includes(searchField.toLowerCase())
);
});
const handleChange = (event) => {
setSearchField(event.target.value);
};
return (
<div className="main-container-with-margins">
<div className="container upper-container-with-margin-top">
<div className={"row row-with-margin-bottom"}>
<div
className={"col col--8 col--offset-2"}
>
<h1 className="padding-none margin-none">
Featured Posts by QuantStack Contributors
</h1>
<div>
<input
className={styles.search_input}
type="search"
placeholder="Search for blog posts"
onChange={handleChange}
/>
</div>
</div>
</div>
<ul className={"row" + " " + "flex-full-centered"}>
{filteredBlogPosts.map((blogpost, index) => (
<li className="cards-list" key={index}>
<div className="col">
<BlogpostCard
blogpost={blogpost}
timeIndex={numberOfBlogs - index}
></BlogpostCard>
</div>
</li>
))}
</ul>
</div>
</div>
);
}