-
Image
+
-
Title
- Date Added -
+ {title}
+ {date}
Apply Now
diff --git a/components/common/Header/Header.js b/components/common/Header/Header.js
index 2217dacb..ae734e81 100644
--- a/components/common/Header/Header.js
+++ b/components/common/Header/Header.js
@@ -5,7 +5,7 @@ import Image from 'next/image';
import Navbar from '../Navbar';
import { IconContainer, IconsDiv, StyledHeader } from './HeaderStyles';
import { getRandomBackground, icons } from './config';
-
+
const Header = (props) => {
const { image, text } = props;
return (
diff --git a/components/common/Navbar.js b/components/common/Navbar.js
index eb20f087..093162e9 100644
--- a/components/common/Navbar.js
+++ b/components/common/Navbar.js
@@ -3,6 +3,7 @@ import { useRouter } from 'next/router';
import styles from '@styles/Navbar.module.css';
import { useState, useEffect, useRef } from 'react';
import Image from 'node_modules/next/image';
+import { FaKey } from 'react-icons/fa';
const Navbar = () => {
const checkboxRef = useRef();
@@ -368,6 +369,14 @@ const Navbar = () => {
Contact Us
+
+ router.push('/Login')}
+ className="flex py-2 px-2 text-white hover:bg-sky-400 hover:text-black rounded-lg transition duration-500"
+ >
+
+
+
>
diff --git a/db/models/Blog.js b/db/models/Blog.js
index 24fe7470..bc05355f 100644
--- a/db/models/Blog.js
+++ b/db/models/Blog.js
@@ -16,6 +16,14 @@ const blogSchema = new mongoose.Schema({
type: String,
required: true,
},
+ like: {
+ type: Number,
+ required: true,
+ },
+ numberOfComments: {
+ type: Number,
+ required: true,
+ }
});
const Blog = mongoose.models.Blog || mongoose.model("Blog", blogSchema);
diff --git a/db/models/BlogComment.js b/db/models/BlogComment.js
new file mode 100644
index 00000000..17a2c6e8
--- /dev/null
+++ b/db/models/BlogComment.js
@@ -0,0 +1,22 @@
+import mongoose from "mongoose";
+
+const blogCommentSchema = new mongoose.Schema({
+ userName: {
+ type: String,
+ },
+ blogId: {
+ type: String,
+ required: true,
+ },
+ message: {
+ type: String,
+ required: true,
+ },
+ date: {
+ type: String,
+ required: true,
+ }
+});
+
+const BlogComment = mongoose.models.BlogComment || mongoose.model("BlogComment", blogCommentSchema);
+export default BlogComment;
diff --git a/package.json b/package.json
index ce3c36df..864511b4 100644
--- a/package.json
+++ b/package.json
@@ -11,8 +11,13 @@
"@fortawesome/fontawesome-svg-core": "^1.2.36",
"@fortawesome/free-brands-svg-icons": "^5.15.4",
"@fortawesome/free-solid-svg-icons": "^5.15.4",
+
"@fortawesome/react-fontawesome": "^0.2.0",
"aos": "^2.3.4",
+
+ "@fortawesome/react-fontawesome": "^0.1.16",
+ "@types/webidl-conversions": "^7.0.0",
+
"axios": "^0.27.2",
"bcryptjs": "^2.4.3",
"framer-motion": "^5.5.5",
@@ -20,7 +25,7 @@
"lodash": "^4.17.21",
"markdown-it": "^13.0.1",
"mongoose": "^7.2.1",
- "next": "^12.3.3",
+ "next": "^12.3.4",
"next-connect": "^1.0.0",
"next-images": "^1.8.5",
"prettier": "^2.8.1",
diff --git a/components/Login.js b/pages/Login.js
similarity index 92%
rename from components/Login.js
rename to pages/Login.js
index b27106b8..494c56b9 100644
--- a/components/Login.js
+++ b/pages/Login.js
@@ -10,6 +10,7 @@ import {
} from "node_modules/@fortawesome/free-solid-svg-icons/index";
import { useContext, useState } from "react";
import { Store } from "utils/Store/Store";
+import Link from 'next/link'
const Login = () => {
const { state, dispatch } = useContext(Store);
@@ -95,6 +96,10 @@ const Login = () => {
Forgot Password ?
+
Or
+
+
Signup
+
diff --git a/pages/Signup.js b/pages/Signup.js
new file mode 100644
index 00000000..203e7a9b
--- /dev/null
+++ b/pages/Signup.js
@@ -0,0 +1,9 @@
+import React from 'react'
+
+const Signup = () => {
+ return (
+
Signup
+ )
+}
+
+export default Signup
\ No newline at end of file
diff --git a/pages/_app.js b/pages/_app.js
index 9b04d25e..b0e988d8 100644
--- a/pages/_app.js
+++ b/pages/_app.js
@@ -1,5 +1,9 @@
+
import Navbar from "@comp/common/Navbar";
import jwt from "jsonwebtoken";
+//import Navbar from "@comp/Navbar";
+// import jwt from "jsonwebtoken";
+
import "@styles/globals.css";
import Head from "node_modules/next/head";
// import { useEffect } from 'react';
@@ -71,86 +75,72 @@ function MyApp({ Component, pageProps, router }) {
// }
// }, []);
- return (
-
- {/* */}
-
- {/* */}
-
-
- {/* */}
-
- Amupedia
- {/* Primary meta tags */}
-
-
-
-
-
-
-
-
- {/* Open Graph / Facebook */}
-
-
-
-
-
-
-
-
-
-
- {/* Twitter */}
-
-
-
-
-
-
- );
+
+
Amupedia
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
}
export default MyApp;
diff --git a/pages/adFix.js b/pages/adFix.js
new file mode 100644
index 00000000..aec4c26e
--- /dev/null
+++ b/pages/adFix.js
@@ -0,0 +1,12 @@
+const body = document.querySelector('body');
+const googleAd = document.querySelector('ins[data-anchor-status]');
+
+setInterval(() => {
+ if (googleAd.getAttribute("data-anchor-status") === "displayed") {
+ body.style.paddingTop = "100px";
+ } else if (googleAd.getAttribute("data-anchor-status") === "dismissed") {
+ body.style.paddingTop = "0";
+ }
+}, 0);
+
+console.log("Testing");
\ No newline at end of file
diff --git a/pages/api/blogs/comments/fetchComments.js b/pages/api/blogs/comments/fetchComments.js
new file mode 100644
index 00000000..edeaeb16
--- /dev/null
+++ b/pages/api/blogs/comments/fetchComments.js
@@ -0,0 +1,20 @@
+import db from "db/db";
+import BlogComment from "db/models/BlogComment";
+import nextConnect from "next-connect";
+const handler = nextConnect();
+
+handler.get(async (req, res) => {
+ try {
+ await db.connect();
+ const data = req.body;
+ console.log(data);
+ const result = await BlogComment.find();
+ console.log(result)
+ await db.disconnect();
+ res.status(200).json({ success: true, result: result });
+ } catch (error) {
+ res.status(500).json({ success: false, error });
+ }
+});
+
+export default handler;
diff --git a/pages/api/blogs/comments/publishComment.js b/pages/api/blogs/comments/publishComment.js
new file mode 100644
index 00000000..a7d9b51b
--- /dev/null
+++ b/pages/api/blogs/comments/publishComment.js
@@ -0,0 +1,28 @@
+import db from "db/db";
+import BlogComment from "db/models/BlogComment";
+import nextConnect from "next-connect";
+const handler = nextConnect();
+
+handler.post(async (req, res) => {
+ try {
+ await db.connect();
+ const data = req.body;
+ const today = new Date();
+ const dd = String(today.getDate()).padStart(2, '0');
+ const mm = String(today.getMonth() + 1).padStart(2, '0');
+ const yyyy = today.getFullYear();
+ console.log(data);
+ const result = await BlogComment.create({
+ userName: req.body.userName,
+ blogId: req.body.blogId,
+ message: req.body.message,
+ date: mm + '/' + dd + '/' + yyyy,
+ });
+ await db.disconnect();
+ res.status(200).json({ success: true, result: result });
+ } catch (error) {
+ res.status(500).json({ success: false, error });
+ }
+});
+
+export default handler;
diff --git a/pages/api/blogs/fetchBlogs.js b/pages/api/blogs/fetchBlogs.js
new file mode 100644
index 00000000..507424f4
--- /dev/null
+++ b/pages/api/blogs/fetchBlogs.js
@@ -0,0 +1,19 @@
+import db from 'db/db';
+import Blog from 'db/models/Blog';
+import nextConnect from 'next-connect';
+const handler = nextConnect();
+
+handler.get(async (req, res) => {
+ try {
+ await db.connect();
+ const data = req.body;
+ console.log(data);
+ const result = await Blog.find();
+ await db.disconnect();
+ res.status(200).json({ success: true, result: result });
+ } catch (error) {
+ res.status(500).json({ success: false, error });
+ }
+});
+
+export default handler;
diff --git a/pages/api/blogs/publishBlog.js b/pages/api/blogs/publishBlog.js
index 0d58ebce..e94d50f5 100644
--- a/pages/api/blogs/publishBlog.js
+++ b/pages/api/blogs/publishBlog.js
@@ -13,6 +13,8 @@ handler.post(async (req, res) => {
title: req.body.title,
coverImg: req.body.coverImg,
content: req.body.content,
+ like: 0, // we dont need that because it will automatically set it
+ numberOfComments: 0,
});
await db.disconnect();
res.status(200).json({ success: true, result: result });
diff --git a/pages/api/opportunities/postOpportunity.js b/pages/api/opportunities/publishOpportunity.js
similarity index 96%
rename from pages/api/opportunities/postOpportunity.js
rename to pages/api/opportunities/publishOpportunity.js
index 480717bc..88a66354 100644
--- a/pages/api/opportunities/postOpportunity.js
+++ b/pages/api/opportunities/publishOpportunity.js
@@ -1,26 +1,26 @@
-import db from 'db/db';
-import Opportunities from 'db/models/Opportunities';
-import nextConnect from 'next-connect';
-const handler = nextConnect();
-
-handler.post(async (req, res) => {
- try {
- await db.connect();
-
- console.log(data);
- const result = await Opportunities.create({
- id: data.id,
- image: data.image,
- title: data.title,
- date: data.date,
- applyNow: data.applyNow,
- description: data.description,
- });
- await db.disconnect();
- res.status(200).json({ success: true, result: result });
- } catch (error) {
- res.status(500).json({ success: false, error });
- }
-});
-
-export default handler;
+import db from 'db/db';
+import Opportunities from 'db/models/Opportunities';
+import nextConnect from 'next-connect';
+const handler = nextConnect();
+
+handler.post(async (req, res) => {
+ try {
+ await db.connect();
+
+ console.log(data);
+ const result = await Opportunities.create({
+ id: data.id,
+ image: data.image,
+ title: data.title,
+ date: data.date,
+ applyNow: data.applyNow,
+ description: data.description,
+ });
+ await db.disconnect();
+ res.status(200).json({ success: true, result: result });
+ } catch (error) {
+ res.status(500).json({ success: false, error });
+ }
+});
+
+export default handler;
diff --git a/pages/blog/[blogId].js b/pages/blog/[blogId].js
index aa6a5f0e..e64ccfae 100644
--- a/pages/blog/[blogId].js
+++ b/pages/blog/[blogId].js
@@ -11,6 +11,7 @@ import { faLinkedin } from "node_modules/@fortawesome/free-brands-svg-icons/inde
import { faLink } from "node_modules/@fortawesome/free-solid-svg-icons/index";
import { faBookmark } from "node_modules/@fortawesome/free-solid-svg-icons/index";
import { faEllipsisH } from "node_modules/@fortawesome/free-solid-svg-icons/index";
+<<<<<<< HEAD
import {faArrowLeft} from "node_modules/@fortawesome/free-solid-svg-icons/index";
import BlogCard from "components/Blogs/BlogCard";
import blogData from "/data/blogdata";
@@ -27,12 +28,50 @@ export default function BlogId() {
console.log(blog)
console.log("heelo",blogId);
+=======
+import BlogCard from "components/BlogCard";
+import axios from 'axios';
+// import blogData from "/data/blogdata";
+import Link from "next/link";
+
+export default function BlogId({ blogsData, commentsData }) {
+ const router = useRouter();
+ const { blogId } = router.query;
+ const blogDetail = blogsData.result[blogId];
+ console.log(blogDetail)
+ const { userId, title, coverImg, content, _id } = blogDetail;
+ console.log(coverImg)
+
+ const submitComment = (e) => {
+ e.preventDefault();
+ const message = document.getElementById("userCommentMessage").value;
+ const userCommentName = document.querySelector(".userCommentName").value;
+ const blogId = _id;
+ if (message.length < 3) {
+ return alert("Message must longer than 3 characters")
+ }
+ if (userCommentName < 3) {
+ return alert("Your Name must longer than 3 characters")
+ }
+ if (blogId.length <= 1) {
+ return alert("Blog Id must be longer than 1 characters")
+ }
+ axios.post("http://localhost:3000/api/blogs/comments/publishComment", { userName: userCommentName, blogId, message }).then(res => {
+ console.log(res)
+ alert("Comment has been sent!")
+ })
+ }
+>>>>>>> 2e3ced3f1a6c1a70341b50aee0bde119b118a150
return (
+<<<<<<< HEAD
{blog.title}
+=======
+
{title}
+>>>>>>> 2e3ced3f1a6c1a70341b50aee0bde119b118a150
@@ -44,7 +83,7 @@ export default function BlogId() {
-
- Test User
+ {userId}
-
@@ -95,6 +134,7 @@ export default function BlogId() {
+<<<<<<< HEAD
{blog.description}
+=======
+
+
+
+
+ {content}
+
+>>>>>>> 2e3ced3f1a6c1a70341b50aee0bde119b118a150
+
+
+
Comment
+
+
+ {commentsData.result.map((comment, index) => {
+ if (comment.blogId === _id) {
+ return (
+ (
+ -
+
+
+
+ {comment.userName}
+
+
{comment.date}
+
+
+
+ )
+ )
+ }
+ })}
+
+
See other blogs
- {blogData.map((blogItem) => (
+ {blogsData.result.map((blogItem, index) => (
>>>>>> 2e3ced3f1a6c1a70341b50aee0bde119b118a150
/>
))}
@@ -126,8 +222,21 @@ export default function BlogId() {
);
}
+<<<<<<< HEAD
export async function getServerSideProps(context) {
return {
props: {},
};
}
+=======
+export const getServerSideProps = async () => {
+ const resBlogs = await fetch('http://localhost:3000/api/blogs/fetchBlogs');
+ const resBlogComments = await fetch('http://localhost:3000/api/blogs/comments/fetchComments');
+ const blogsData = await resBlogs.json();
+ const commentsData = await resBlogComments.json();
+
+ return {
+ props: { blogsData, commentsData }
+ }
+}
+>>>>>>> 2e3ced3f1a6c1a70341b50aee0bde119b118a150
diff --git a/pages/blog/index.js b/pages/blog/index.js
index 42c78772..7cb2ccb4 100644
--- a/pages/blog/index.js
+++ b/pages/blog/index.js
@@ -3,6 +3,7 @@ import BlogCard from "components/Blogs/BlogCard";
import Footer from "components/common/Footer";
import Header from "components/common/Header/Header";
import styles from "@styles/scss/blog.module.scss";
+<<<<<<< HEAD
import blogData from "/data/blogdata";
import GoToTop from "components/GoToTop";
import WriteBlog from "./writeblog";
@@ -19,6 +20,20 @@ export default function Blogs() {
blogItem.title.toLowerCase().includes(query.toLowerCase())
);
+=======
+// import blogData from "/data/blogdata";
+
+export const getStaticProps = async () => {
+ const res = await fetch('http://localhost:3000/api/blogs/fetchBlogs');
+ const blogsData = await res.json();
+
+ return {
+ props: { blogsData }
+ }
+}
+
+export default function Blogs({ blogsData }) {
+>>>>>>> 2e3ced3f1a6c1a70341b50aee0bde119b118a150
return (
<>
@@ -40,6 +55,7 @@ export default function Blogs() {
{/*
Write a blog */}
+<<<<<<< HEAD
{filteredBlogData.length > 0 ? (
filteredBlogData.map((blogItem) => (
)}
+=======
+ {blogsData.result.map((blogItem, index) => (
+
+ ))}
+
+>>>>>>> 2e3ced3f1a6c1a70341b50aee0bde119b118a150
>
);
diff --git a/public/images/blog/blogDetails/photo1.avif b/public/images/blog/blogDetails/photo1.avif
deleted file mode 100644
index bc937fab..00000000
Binary files a/public/images/blog/blogDetails/photo1.avif and /dev/null differ
diff --git a/public/images/blog/test.png b/public/images/blog/test.png
new file mode 100644
index 00000000..61d2129b
Binary files /dev/null and b/public/images/blog/test.png differ
diff --git a/styles/BlogDetail.module.css b/styles/BlogDetail.module.css
index 98107dcd..ea156fd6 100644
--- a/styles/BlogDetail.module.css
+++ b/styles/BlogDetail.module.css
@@ -80,8 +80,8 @@
display: block;
width: 100%;
height: 100%;
- max-width: 1700px;
- max-height: 1100px;
+ max-width: 700px;
+ max-height: 700px;
margin: 20px auto;
border: 3px solid black;
}
@@ -93,6 +93,79 @@
font-size: x-large;
}
+.blogCommentSection {
+ display: flex;
+ align-items: center;
+ flex-direction: column;
+ justify-content: center;
+ gap: 20px;
+}
+
+.sendComment {
+ display: flex;
+ flex-direction: column;
+ gap: 15px;
+ width: 100%;
+ max-width: 1700px;
+ margin-bottom: 30px;
+}
+
+.userComment {
+ display: flex;
+ align-items: center;
+ gap: 10px;
+ font-size: 20px;
+ width: 100%;
+}
+
+.userMessageInput {
+ display: flex;
+ flex-direction: column;
+ gap: 15px;
+}
+
+.userMessageInput input,
+.userMessageInput textarea {
+ width: 100%;
+ max-width: 1700px;
+ border: 1px solid black;
+ background-color: white;
+ padding: 15px;
+ font-size: 17px;
+ outline: none;
+}
+
+.sendComment button {
+ padding: 15px 50px;
+ background-color: rgb(22, 81, 211);
+ border: none;
+ color: white;
+ border-radius: 30px;
+ width: fit-content;
+ font-size: 17px;
+ cursor: pointer;
+}
+
+.userMessageInput input::placeholder,
+.userMessageInput textarea::placeholder {
+ color: #121212;
+}
+
+.blogCommentSection ul {
+ display: flex;
+ flex-direction: column;
+ gap: 20px;
+ width: 100%;
+ max-width: 1700px;
+}
+
+.blogCommentSection ul li {
+ width: 100%;
+ border: 1px solid grey;
+ padding: 10px 15px;
+ cursor: pointer;
+}
+
.otherBlogsCard {
display: flex;
flex-direction: column;