├── .gitignore ├── README.md ├── package-lock.json ├── package.json ├── public └── index.html └── src ├── App.js ├── assets └── styles │ ├── _authors.scss │ ├── _fonts.scss │ ├── _reset.scss │ └── index.scss ├── components ├── authors │ ├── Author.js │ ├── AuthorPage.js │ └── Authors.js ├── blogs │ ├── Blog.js │ ├── Blogs.js │ └── BlogsPage.js ├── comments │ ├── CommentForm.js │ └── Comments.js ├── common │ ├── AuthorItems.js │ ├── CardItems.js │ ├── CustomScrollToTop.js │ └── PreLoader.js ├── home │ └── HomePage.js └── layout │ ├── Footer.js │ ├── Header.js │ └── index.js ├── graphql ├── mutations.js └── queries.js └── index.js /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env 17 | .env.local 18 | .env.development.local 19 | .env.test.local 20 | .env.production.local 21 | 22 | npm-debug.log* 23 | yarn-debug.log* 24 | yarn-error.log* 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Getting Started with Create React App 2 | 3 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 4 | 5 | ## Available Scripts 6 | 7 | In the project directory, you can run: 8 | 9 | ### `npm start` 10 | 11 | Runs the app in the development mode.\ 12 | Open [http://localhost:3000](http://localhost:3000) to view it in your browser. 13 | 14 | The page will reload when you make changes.\ 15 | You may also see any lint errors in the console. 16 | 17 | ### `npm test` 18 | 19 | Launches the test runner in the interactive watch mode.\ 20 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 21 | 22 | ### `npm run build` 23 | 24 | Builds the app for production to the `build` folder.\ 25 | It correctly bundles React in production mode and optimizes the build for the best performance. 26 | 27 | The build is minified and the filenames include the hashes.\ 28 | Your app is ready to be deployed! 29 | 30 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 31 | 32 | ### `npm run eject` 33 | 34 | **Note: this is a one-way operation. Once you `eject`, you can't go back!** 35 | 36 | If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 37 | 38 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own. 39 | 40 | You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it. 41 | 42 | ## Learn More 43 | 44 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 45 | 46 | To learn React, check out the [React documentation](https://reactjs.org/). 47 | 48 | ### Code Splitting 49 | 50 | This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting) 51 | 52 | ### Analyzing the Bundle Size 53 | 54 | This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size) 55 | 56 | ### Making a Progressive Web App 57 | 58 | This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app) 59 | 60 | ### Advanced Configuration 61 | 62 | This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration) 63 | 64 | ### Deployment 65 | 66 | This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment) 67 | 68 | ### `npm run build` fails to minify 69 | 70 | This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify) 71 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "blogs-project", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@apollo/client": "^3.6.9", 7 | "@emotion/react": "^11.9.3", 8 | "@emotion/styled": "^11.9.3", 9 | "@mui/icons-material": "^5.8.4", 10 | "@mui/material": "^5.9.2", 11 | "@testing-library/jest-dom": "^5.16.4", 12 | "@testing-library/react": "^13.3.0", 13 | "@testing-library/user-event": "^13.5.0", 14 | "formik": "^2.2.9", 15 | "graphql": "^16.5.0", 16 | "react": "^18.2.0", 17 | "react-dom": "^18.2.0", 18 | "react-loader-spinner": "^5.1.7-beta.1", 19 | "react-router-dom": "^6.3.0", 20 | "react-scripts": "5.0.1", 21 | "react-scroll-to-top": "^3.0.0", 22 | "react-toastify": "^9.0.7", 23 | "sanitize-html": "^2.7.1", 24 | "sass": "^1.54.0", 25 | "web-vitals": "^2.1.4", 26 | "yup": "^0.32.11" 27 | }, 28 | "scripts": { 29 | "start": "react-scripts start", 30 | "build": "react-scripts build", 31 | "test": "react-scripts test", 32 | "eject": "react-scripts eject" 33 | }, 34 | "eslintConfig": { 35 | "extends": [ 36 | "react-app", 37 | "react-app/jest" 38 | ] 39 | }, 40 | "browserslist": { 41 | "production": [ 42 | ">0.2%", 43 | "not dead", 44 | "not op_mini all" 45 | ], 46 | "development": [ 47 | "last 1 chrome version", 48 | "last 1 firefox version", 49 | "last 1 safari version" 50 | ] 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 14 | React Blogs 15 | 16 | 17 | 18 |
19 | 20 | 21 | -------------------------------------------------------------------------------- /src/App.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { createTheme, ThemeProvider } from "@mui/material/styles"; 3 | // react-router-dom 4 | import { Routes, Route, Navigate } from "react-router-dom"; 5 | // components 6 | import LayOut from "./components/layout"; 7 | import HomePage from "./components/home/HomePage"; 8 | import BlogsPage from "./components/blogs/BlogsPage"; 9 | import AuthorPage from "./components/authors/AuthorPage"; 10 | import Blog from "./components/blogs/Blog"; 11 | import Author from "./components/authors/Author"; 12 | import CustomScrollToTop from "./components/common/CustomScrollToTop"; 13 | // scroll to top button 14 | import ScrollToTop from "react-scroll-to-top"; 15 | 16 | const theme = createTheme({ 17 | typography: { 18 | fontFamily: ["Quicksand", "Rubik"].join(","), 19 | fontSize: 14, 20 | fontWeightLight: 400, 21 | fontWeightMedium: 500, 22 | fontWeightRegular: 600, 23 | fontWeightBold: 700, 24 | }, 25 | }); 26 | 27 | const App = () => { 28 | return ( 29 | 30 | 31 | 32 | 33 | 34 | } /> 35 | } /> 36 | } /> 37 | } /> 38 | } /> 39 | } /> 40 | 41 | 42 | 43 | ); 44 | }; 45 | 46 | export default App; -------------------------------------------------------------------------------- /src/assets/styles/_authors.scss: -------------------------------------------------------------------------------- 1 | .authors-list { 2 | background-color: rgb(223 223 223 / 38%); 3 | border-radius: 10px; 4 | box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important; 5 | } 6 | .authors-item:hover { 7 | background-color: #0ab9d861 !important; 8 | z-index: 9999; 9 | } 10 | -------------------------------------------------------------------------------- /src/assets/styles/_fonts.scss: -------------------------------------------------------------------------------- 1 | @import url("https://fonts.googleapis.com/css2?family=Quicksand&family=Rubik:ital,wght@0,300;1,300&display=swap"); -------------------------------------------------------------------------------- /src/assets/styles/_reset.scss: -------------------------------------------------------------------------------- 1 | *, 2 | *::before, 3 | *::after { 4 | margin: 0; 5 | padding: 0; 6 | box-sizing: border-box; 7 | outline: none; 8 | border: none; 9 | text-decoration: none; 10 | } 11 | body { 12 | font-family: "Quicksand", sans-serif !important; 13 | font-family: "Rubik", sans-serif !important; 14 | } 15 | a { 16 | color: inherit; 17 | } 18 | // scroll bar 19 | ::-webkit-scrollbar { 20 | width: 7px; 21 | } 22 | ::-webkit-scrollbar-track { 23 | background-color: transparent; 24 | } 25 | ::-webkit-scrollbar-thumb { 26 | background-color: rgb(209, 209, 209); 27 | border-radius: 5px; 28 | } 29 | ::-webkit-scrollbar-thumb:hover { 30 | background-color: rgb(187, 187, 187); 31 | } 32 | ::-webkit-scrollbar-thumb:active { 33 | background-color: rgb(207, 207, 207); 34 | } -------------------------------------------------------------------------------- /src/assets/styles/index.scss: -------------------------------------------------------------------------------- 1 | @import "authors"; 2 | @import "fonts"; 3 | @import "reset"; -------------------------------------------------------------------------------- /src/components/authors/Author.js: -------------------------------------------------------------------------------- 1 | import { Link } from "react-router-dom"; 2 | import { Avatar, Box, Grid, Typography } from "@mui/material"; 3 | // react toastify 4 | import { ToastContainer, toast } from "react-toastify"; 5 | import "react-toastify/dist/ReactToastify.css"; 6 | // query to fetch blogs 7 | import { useQuery } from "@apollo/client/react"; 8 | import { GET_AUTHORS_INFO } from "../../graphql/queries"; 9 | // preloader component 10 | import PreLoader from "../common/PreLoader"; 11 | 12 | const Author = () => { 13 | const { loading, error, data } = useQuery(GET_AUTHORS_INFO); 14 | 15 | if (loading) return ; 16 | if (error) { 17 | toast.error("Something went wrong!", { 18 | position: "top-center", 19 | autoClose: 1500, 20 | hideProgressBar: false, 21 | closeOnClick: true, 22 | pauseOnHover: true, 23 | draggable: true, 24 | progress: undefined, 25 | theme: "dark", 26 | }); 27 | } 28 | 29 | return ( 30 | 31 | {data.authors.map((item) => ( 32 | 33 | 34 | 42 | 43 | 44 | {item.name} 45 | 46 | 47 | 48 | 49 | ))} 50 | 51 | 52 | ); 53 | }; 54 | 55 | export default Author; -------------------------------------------------------------------------------- /src/components/authors/AuthorPage.js: -------------------------------------------------------------------------------- 1 | // sanitize html 2 | import sanitizeHtml from "sanitize-html"; 3 | // react router dom 4 | import { useParams } from "react-router-dom"; 5 | // query to fetch author info 6 | import { GET_AUTHOR } from "../../graphql/queries"; 7 | import { useQuery } from "@apollo/client"; 8 | // mui components 9 | import Container from "@mui/material/Container"; 10 | import Grid from "@mui/material/Grid"; 11 | import { Avatar, Chip, Typography } from "@mui/material"; 12 | import CardItems from "../common/CardItems"; 13 | // icons 14 | import LightbulbIcon from "@mui/icons-material/Lightbulb"; 15 | // preloader component 16 | import PreLoader from "../common/PreLoader"; 17 | 18 | const AuthorPage = () => { 19 | const { slug } = useParams(); 20 | const { loading, error, data } = useQuery(GET_AUTHOR, { 21 | variables: { slug }, 22 | }); 23 | if (loading) return ; 24 | if (error) return

Error :

; 25 | // destructuring data 26 | const { 27 | author: { 28 | name, 29 | field, 30 | avatar: { url }, 31 | posts, 32 | description: { html }, 33 | }, 34 | } = data; 35 | 36 | return ( 37 | 38 | 39 | 46 | 47 | 54 | {name} 55 | 56 | 57 | 58 | 59 | 60 | 61 |
62 |
63 | 64 | 65 | 71 | {name} Articles: 72 | 73 | 80 | {posts.map((item) => ( 81 | 82 | 87 | 88 | ))} 89 | 90 | 91 |
92 |
93 | ); 94 | }; 95 | 96 | export default AuthorPage; 97 | -------------------------------------------------------------------------------- /src/components/authors/Authors.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { Divider, Grid } from "@mui/material"; 3 | // query to fetch authors 4 | import { useQuery } from "@apollo/client"; 5 | import { GET_AUTHORS_INFO } from "../../graphql/queries"; 6 | // components 7 | import AuthorItems from "../common/AuthorItems"; 8 | // preloader component 9 | import PreLoader from "../common/PreLoader"; 10 | 11 | const Authors = () => { 12 | const { loading, error, data } = useQuery(GET_AUTHORS_INFO); 13 | 14 | if (loading) return ; 15 | if (error) return

Error :

; 16 | 17 | return ( 18 | 19 | {data.authors.map((item, index) => ( 20 | 21 | 22 | 23 | 24 | {index !== data.authors.length - 1 && ( 25 | 26 | 27 | 28 | )} 29 | 30 | ))} 31 | 32 | ); 33 | }; 34 | 35 | export default Authors; -------------------------------------------------------------------------------- /src/components/blogs/Blog.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { Link } from "react-router-dom"; 3 | import { 4 | Avatar, 5 | Button, 6 | Card, 7 | CardActions, 8 | CardContent, 9 | CardHeader, 10 | CardMedia, 11 | Container, 12 | Divider, 13 | Grid, 14 | Typography, 15 | } from "@mui/material"; 16 | 17 | // query to fetch blogs 18 | import { useQuery } from "@apollo/client/react"; 19 | import { GET_BLOGS_INFO } from "../../graphql/queries"; 20 | // preloader component 21 | import PreLoader from "../common/PreLoader"; 22 | 23 | const Blog = () => { 24 | const { loading, error, data } = useQuery(GET_BLOGS_INFO); 25 | 26 | if (loading) return ; 27 | if (error) return

Error :

; 28 | 29 | return ( 30 | 31 | 32 | {data.posts.map((item) => ( 33 | 41 | 45 | 52 | } 53 | title={ 54 | 60 | {item.author.name} 61 | 62 | } 63 | sx={{ padding: "10px" }} 64 | /> 65 | 71 | 72 | 78 | {item.title} 79 | 80 | 81 | 82 | 83 | 84 | 96 | 97 | 98 | 99 | 100 | ))} 101 | 102 | 103 | ); 104 | }; 105 | 106 | export default Blog; 107 | -------------------------------------------------------------------------------- /src/components/blogs/Blogs.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import Grid from "@mui/material/Grid"; 3 | // query to fetch blogs 4 | import { useQuery } from "@apollo/client/react"; 5 | import { GET_BLOGS_INFO } from "../../graphql/queries"; 6 | // components 7 | import CardItems from "../common/CardItems"; 8 | // preloader component 9 | import PreLoader from "../common/PreLoader"; 10 | 11 | const Blogs = () => { 12 | const { loading, error, data } = useQuery(GET_BLOGS_INFO); 13 | 14 | if (loading) return ; 15 | if (error) return

Error :

; 16 | 17 | return ( 18 | 23 | {data.posts.map((item) => ( 24 | 25 | 26 | 27 | ))} 28 | 29 | ); 30 | }; 31 | 32 | export default Blogs; 33 | -------------------------------------------------------------------------------- /src/components/blogs/BlogsPage.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | // sanitize html 3 | import sanitizeHtml from "sanitize-html"; 4 | // react toastify 5 | import { ToastContainer, toast } from "react-toastify"; 6 | import "react-toastify/dist/ReactToastify.css"; 7 | // react router dom 8 | import { useParams, useNavigate } from "react-router-dom"; 9 | // query to fetch author info 10 | import { GET_BLOG } from "../../graphql/queries"; 11 | import { useQuery } from "@apollo/client"; 12 | // mui components 13 | import Container from "@mui/material/Container"; 14 | import Grid from "@mui/material/Grid"; 15 | import { Avatar, Box, Typography } from "@mui/material"; 16 | import CommentForm from "../comments/CommentForm"; 17 | // icons 18 | import ArrowBackIosIcon from "@mui/icons-material/ArrowBackIos"; 19 | // preloader component 20 | import PreLoader from "../common/PreLoader"; 21 | import Comments from "../comments/Comments"; 22 | 23 | const BlogsPage = () => { 24 | const { slug } = useParams(); 25 | const navigate = useNavigate(); 26 | const { loading, error, data } = useQuery(GET_BLOG, { 27 | variables: { slug }, 28 | }); 29 | if (loading) return ; 30 | if (error) { 31 | return toast.error("Something went wrong!", { 32 | position: "top-center", 33 | autoClose: 1500, 34 | hideProgressBar: false, 35 | closeOnClick: true, 36 | pauseOnHover: true, 37 | draggable: true, 38 | progress: undefined, 39 | theme: "dark", 40 | }); 41 | } 42 | // destructuring data 43 | const { 44 | author: { 45 | name, 46 | field, 47 | avatar: { url }, 48 | }, 49 | title, 50 | coverPhoto, 51 | content: { html }, 52 | } = data.post; 53 | 54 | return ( 55 | 56 | 57 | 65 | 71 | {title} 72 | 73 | navigate(-1)} /> 74 | 75 | 76 | 77 | {slug} 84 | 85 | 86 | 87 | 92 | 93 | 99 | {name} 100 | 101 | 102 | {field} 103 | 104 | 105 | 106 | 107 | 108 |
109 |
110 | {/* comments */} 111 | 112 | 113 | 114 | {/* comments */} 115 | 116 | 117 | 118 |
119 | 120 |
121 | ); 122 | }; 123 | 124 | export default BlogsPage; 125 | -------------------------------------------------------------------------------- /src/components/comments/CommentForm.js: -------------------------------------------------------------------------------- 1 | import React, { useState } from "react"; 2 | // react toastify 3 | import { ToastContainer, toast } from "react-toastify"; 4 | import "react-toastify/dist/ReactToastify.css"; 5 | // mutation to post comments to the server 6 | import { useMutation } from "@apollo/client"; 7 | import { SEND_COMMENT } from "../../graphql/mutations"; 8 | // mui components 9 | import Grid from "@mui/material/Grid"; 10 | import Typography from "@mui/material/Typography"; 11 | import { Button, TextField } from "@mui/material"; 12 | // icons 13 | import SendIcon from "@mui/icons-material/Send"; 14 | import HourglassTopIcon from "@mui/icons-material/HourglassTop"; 15 | // formik 16 | import { useFormik } from "formik"; 17 | import * as Yup from "yup"; 18 | 19 | // initial values 20 | const initialValues = { 21 | name: "", 22 | email: "", 23 | text: "", 24 | }; 25 | // validate function 26 | const validationSchema = Yup.object({ 27 | name: Yup.string() 28 | .trim() 29 | .required("Name Required!") 30 | .max(50, "your name can't be more than 50 chars!"), 31 | email: Yup.string() 32 | .matches( 33 | /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,3}$/i, 34 | "invalid Email address" 35 | ) 36 | .required("Required"), 37 | text: Yup.string() 38 | .trim() 39 | .min(5, "your comment must be at least 5 or more chars!") 40 | .max(500, "your comment can't be more than 500 chars!") 41 | .required("Text Required!"), 42 | }); 43 | // submit 44 | const onSubmit = (values) => { 45 | console.log(values); 46 | }; 47 | 48 | const Test = ({ slug }) => { 49 | let finalValue = {}; 50 | const formik = useFormik({ initialValues, validationSchema, onSubmit }); 51 | const { values } = formik; 52 | values.slug = slug; 53 | // destructuring values 54 | finalValue = values; 55 | const { name, email, text } = finalValue; 56 | // post comment to the server 57 | const [sendComment, { loading, error }] = useMutation(SEND_COMMENT, { 58 | variables: { name, email, text, slug }, 59 | }); 60 | // validation inputs before sending comment 61 | const senderHanlde = () => { 62 | if ( 63 | !Object.keys(formik.errors).length && 64 | formik.values.name && 65 | formik.values.email && 66 | formik.values.text 67 | ) { 68 | sendComment(); 69 | // clear inputs after sending comments 70 | formik.values.name = ""; 71 | formik.values.email = ""; 72 | formik.values.text = ""; 73 | // set touch to false 74 | formik.touched.name = false; 75 | formik.touched.email = false; 76 | formik.touched.text = false; 77 | // success alert 78 | toast.success( 79 | "your comment sent successfully & will be display after reviewing!", 80 | { 81 | position: "top-center", 82 | autoClose: 2000, 83 | hideProgressBar: false, 84 | closeOnClick: true, 85 | pauseOnHover: true, 86 | draggable: true, 87 | progress: undefined, 88 | theme: "dark", 89 | } 90 | ); 91 | } else { 92 | toast.error("something went wrong!", { 93 | position: "top-center", 94 | autoClose: 2000, 95 | hideProgressBar: false, 96 | closeOnClick: true, 97 | pauseOnHover: true, 98 | draggable: true, 99 | progress: undefined, 100 | theme: "dark", 101 | }); 102 | } 103 | }; 104 | 105 | return ( 106 | 115 | 116 | 117 | Comments: 118 | 119 |
120 | 133 | 134 | 147 | 148 | 161 | 162 | 172 | 173 |
174 | 175 |
176 | ); 177 | }; 178 | 179 | export default Test; 180 | -------------------------------------------------------------------------------- /src/components/comments/Comments.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | // query to fetch blogs comments 3 | import { useQuery } from "@apollo/client"; 4 | import { GET_COMMENTS } from "../../graphql/queries"; 5 | // react toastify 6 | import { ToastContainer, toast } from "react-toastify"; 7 | import "react-toastify/dist/ReactToastify.css"; 8 | // mui components 9 | import { Avatar, Grid, Typography } from "@mui/material"; 10 | import { Box } from "@mui/system"; 11 | 12 | const Comments = ({ slug }) => { 13 | const { loading, data, error } = useQuery(GET_COMMENTS, { 14 | variables: { slug }, 15 | }); 16 | 17 | if (loading) return

Loading...

; 18 | if (error) { 19 | toast.error("Failed to load comments!", { 20 | position: "top-center", 21 | autoClose: 1500, 22 | hideProgressBar: false, 23 | closeOnClick: true, 24 | pauseOnHover: true, 25 | draggable: true, 26 | progress: undefined, 27 | theme: "dark", 28 | }); 29 | } 30 | 31 | return ( 32 | 41 | 42 | 43 | Comment list: 44 | 45 | {data.comments.map((item) => ( 46 | 55 | 56 | {item.name[0]} 57 | 64 | {item.name} 65 | 66 | 67 | 74 | {item.text} 75 | 76 | 77 | ))} 78 | 79 | 80 | 81 | ); 82 | }; 83 | 84 | export default Comments; 85 | -------------------------------------------------------------------------------- /src/components/common/AuthorItems.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | // react router dom 3 | import { Link } from "react-router-dom"; 4 | // mui components 5 | import { Avatar, Box, Typography } from "@mui/material"; 6 | 7 | const AuthorItems = ({ name, slug, avatar }) => { 8 | return ( 9 | 10 | 11 | 12 | 18 | {name} 19 | 20 | 21 | 22 | ); 23 | }; 24 | 25 | export default AuthorItems; 26 | -------------------------------------------------------------------------------- /src/components/common/CardItems.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { Link } from "react-router-dom"; 3 | import { 4 | Card, 5 | CardHeader, 6 | Avatar, 7 | CardMedia, 8 | CardContent, 9 | CardActions, 10 | Typography, 11 | Divider, 12 | Button, 13 | } from "@mui/material"; 14 | 15 | const CardItems = ({ author, id, slug, title, coverPhoto }) => { 16 | return ( 17 | 18 | {author && ( 19 | 26 | } 27 | title={ 28 | 34 | {author.name} 35 | 36 | } 37 | sx={{ padding: "10px" }} 38 | /> 39 | )} 40 | {coverPhoto.url ? ( 41 | 47 | ) : ( 48 | 49 | )} 50 | 51 | 57 | {title} 58 | 59 | 60 | 61 | 62 | 63 | 75 | 76 | 77 | 78 | ); 79 | }; 80 | 81 | export default CardItems; 82 | -------------------------------------------------------------------------------- /src/components/common/CustomScrollToTop.js: -------------------------------------------------------------------------------- 1 | import { useEffect } from "react"; 2 | import { useLocation } from "react-router-dom"; 3 | 4 | export default function CustomScrollToTop() { 5 | const { pathname } = useLocation(); 6 | 7 | useEffect(() => { 8 | window.scrollTo(0, 0); 9 | }, [pathname]); 10 | 11 | return null; 12 | } 13 | -------------------------------------------------------------------------------- /src/components/common/PreLoader.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { Rings } from "react-loader-spinner"; 3 | 4 | const PreLoader = () => { 5 | return ( 6 |
15 | 21 |
22 | ); 23 | }; 24 | 25 | export default PreLoader; 26 | -------------------------------------------------------------------------------- /src/components/home/HomePage.js: -------------------------------------------------------------------------------- 1 | import { Container, Grid, Typography } from "@mui/material"; 2 | import { Link } from "react-router-dom"; 3 | // components 4 | import Blogs from "../blogs/Blogs"; 5 | import Authors from "../authors/Authors"; 6 | 7 | const HomePage = () => { 8 | return ( 9 | 10 | 11 | 12 | 13 | 20 | Authors 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 35 | Blogs 36 | 37 | 38 | 39 | 40 | 41 | 42 | ); 43 | }; 44 | 45 | export default HomePage; -------------------------------------------------------------------------------- /src/components/layout/Footer.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | // mui components 3 | import Typography from "@mui/material/Typography"; 4 | 5 | const Footer = () => { 6 | return ( 7 | 16 | Made with 17 | 18 | {" "} 19 | ❤{" "} 20 | 21 | by 22 | 29 | {" "} 30 | Parham Abolghasemi{" "} 31 | 32 | 33 | ); 34 | }; 35 | 36 | export default Footer; 37 | -------------------------------------------------------------------------------- /src/components/layout/Header.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | // react-router-dom 3 | import { Link } from "react-router-dom"; 4 | // mui components 5 | import { AppBar, Toolbar, Typography, Container } from "@mui/material"; 6 | // icons 7 | import IconButton from "@mui/material/IconButton"; 8 | import DescriptionIcon from "@mui/icons-material/Description"; 9 | 10 | const Header = () => { 11 | return ( 12 | 13 | 14 | 15 | 16 | 23 | 24 | 25 | 26 | 27 | Blogs Project 28 | 29 | 30 | 31 | 32 | ); 33 | }; 34 | 35 | export default Header; 36 | -------------------------------------------------------------------------------- /src/components/layout/index.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | // components 3 | import Footer from "./Footer"; 4 | import Header from "./Header"; 5 | 6 | const LayOut = ({ children }) => { 7 | return ( 8 | <> 9 |
10 | {children} 11 |