mirror of
https://github.com/yusufipk/teknolojirehberleri.xyz.git
synced 2026-09-11 10:56:08 +00:00
(create) created searchbar component and styled it
This commit is contained in:
+13
-1
@@ -1,9 +1,21 @@
|
||||
import { useState } from "react";
|
||||
import Searchbar from "../components/searchbar";
|
||||
export default function Home({ posts }) {
|
||||
const [search, setSearch] = useState("");
|
||||
const filteredPosts =
|
||||
search.length === 0
|
||||
? posts
|
||||
: posts.filter((post) =>
|
||||
post.title.toLowerCase().includes(search.toLowerCase())
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="homepage">
|
||||
<Searchbar search={search} setSearch={setSearch} />
|
||||
|
||||
<h1 className="homepage_heading-1">Rehberler</h1>
|
||||
<div className="homepage_posts">
|
||||
{posts.slice(0, 20).map((post) => (
|
||||
{filteredPosts.slice(0, 20).map((post) => (
|
||||
<li key={post.id}>{post.title}</li>
|
||||
))}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user