diff --git a/client/src/App.jsx b/client/src/App.jsx index 919d318..557435b 100644 --- a/client/src/App.jsx +++ b/client/src/App.jsx @@ -10,6 +10,7 @@ import { import PropTypes from "prop-types"; import LoadingBar from "react-top-loading-bar"; import About from "./component/About"; +import BlogPage from "./component/Blog"; import Alert from "./component/Alert"; import Footer from "./component/Footer"; import Home from "./component/Home"; @@ -55,6 +56,7 @@ const Layout = ({ children, mode, setProgress, toggleMode, showAlert }) => { home='Home' about='About Us' community='Community' + BlogPage="Blogs" discussion='Discussion' showAlert={showAlert} mode={mode} @@ -191,6 +193,17 @@ function App() { /> } /> + + } + /> post.category))]; + + const filteredPosts = blogPosts.filter(post => { + const matchesSearch = post.title.toLowerCase().includes(searchTerm.toLowerCase()) || + post.excerpt.toLowerCase().includes(searchTerm.toLowerCase()); + const matchesCategory = selectedCategory === 'All' || post.category === selectedCategory; + return matchesSearch && matchesCategory; + }); + + return ( +
+ {/* Hero Section */} +
+
+

Explore Our Blog

+

Discover stories, insights, and knowledge

+
+
+ + {/* Search and Filter Section */} +
+
+
+ setSearchTerm(e.target.value)} + /> + +
+
+ {categories.map(category => ( + + ))} +
+
+ + {/* Blog Grid */} +
+ {filteredPosts.map(post => ( +
+ {post.title} +
+
+ + {post.category} + + + {post.readTime} + +
+

+ {post.title} +

+

+ {post.excerpt} +

+
+
+
+
+

+ {post.author} +

+

+ {post.date} +

+
+
+ +
+
+
+ ))} +
+
+
+ ); +} \ No newline at end of file diff --git a/client/src/component/Navbar.jsx b/client/src/component/Navbar.jsx index d1f00b2..e1a3be1 100644 --- a/client/src/component/Navbar.jsx +++ b/client/src/component/Navbar.jsx @@ -17,11 +17,10 @@ function Navbar(props) { const navigate = useNavigate(); const location = useLocation(); const [isScrolled, setIsScrolled] = useState(false); // State to keep track of whether page has been scrolled - // eslint-disable-next-line no-unused-vars const [isOpen, setIsOpen] = useState(false); const [isSidebarOpen, setIsSidebarOpen] = useState(false); - const style = { color: "white", fontSize: "1.5em" } + const style = { color: "white", fontSize: "1.5em" }; useEffect(() => { window.onscroll = function () { @@ -72,11 +71,9 @@ function Navbar(props) { const [image, setImage] = useState(); useEffect(() => { - // Fetch initial image when component mounts axios .get(`${VITE_SERVER_PORT}/getAvatarImage`) .then((res) => { - // Check if response data is valid if (res.data && res.data.length > 0) { setImage(res.data[res.data.length - 1].image); // Fetch the last uploaded image } @@ -117,7 +114,6 @@ function Navbar(props) { className={`gap-[4.8rem] visible navbar-collapse rnav ${isOpen ? "show" : ""}`} style={{ backgroundColor: props.mode === "dark" ? "black" : "white" }} > - {/* -
- {!localStorage.getItem("token") ? ( - <> -
    -
    - {/* Toggle Dark Mode */} -
    - {/* Toggle Dark Mode */} -
    -
    - - - -
    -
    -
    - - Login - - - Signup - -
    -
- - ) : ( - <> - - - )} -
- {/* */} + {/* Additional form or buttons */} + {/* Sidebar for smaller devices */}
@@ -409,7 +232,7 @@ Navbar.propTypes = { home: PropTypes.string, community: PropTypes.string, discussion: PropTypes.string, - myProjects: PropTypes.string, + BlogPage: PropTypes.string, about: PropTypes.string, mode: PropTypes.string, toggleMode: PropTypes.func,