Skip to content

Commit 5fd0d33

Browse files
committed
CRUD of the blog is completed
1 parent bfe3044 commit 5fd0d33

File tree

8 files changed

+24
-16
lines changed

8 files changed

+24
-16
lines changed

app/(profile)/create-post/[[...blogid]]/page.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ const CreateBlog = ({ params }: CreateBlogProps) => {
222222
)}
223223
</div>
224224
<p className='label mb-3'>Tags&nbsp;<span className='asterik'>*</span></p>
225-
<div className="myBorder rounded-lg h-24 p-3 gap-2 items-center cursor-pointer mb-5 flex flex-wrap justify-start">
225+
<div className="myBorder rounded-lg min-h-24 h-auto p-3 gap-2 items-center cursor-pointer mb-5 flex flex-wrap justify-start">
226226
{['Design', 'Research', 'Technology', 'Politics','Development'].map((tag) => (
227227
<span
228228
key={tag}
@@ -246,9 +246,9 @@ const CreateBlog = ({ params }: CreateBlogProps) => {
246246
)}
247247

248248
<div className="flex justify-between mt-10">
249-
<button type="submit" onClick={() => setAction('cancel')} className="transparentBtn">
249+
{/* <button type="submit" onClick={() => setAction('cancel')} className="transparentBtn">
250250
Cancel
251-
</button>
251+
</button> */}
252252
<div className="flex gap-7">
253253
<button type="submit" onClick={() => setAction('draft')} className="secondaryBtn">
254254
Save as Draft

app/(profile)/dashboard/page.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { format } from 'date-fns';
55
import DeleteBlogBtn from '@/components/DeleteBlogBtn';
66
import EditBlogBtn from '@/components/EditBlogBtn';
77
import Link from 'next/link';
8+
import Image from 'next/image';
89

910
interface Blog {
1011
id: string;
@@ -58,12 +59,13 @@ const Dashboard = async() => {
5859
<td className="tableBorder px-4 py-2">
5960
<div className="flex gap-4 items-center text-sm">
6061
<div className="w-8 h-8">
61-
<img
62+
<Image
6263
src={blog.blogCover}
6364
alt="Blog Image"
6465
width={40}
6566
height={40}
6667
className="w-full h-full object-cover"
68+
priority
6769
/>
6870
</div>
6971
<Link href={`/blog/${blog.id}`} className="truncate max-w-xs hover:underline">{blog.blogName}</Link>

app/(profile)/layout.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ const layout = ({
66
children: React.ReactNode;
77
}>) => {
88
return (
9-
<main className='flex'>
9+
<main className='flex overflow-x-hidden'>
1010
<SideMenu/>
11-
<section className="sectionBg p-4 ml-14 sm:ml-0 w-screen min-h-screen">{children}</section>
11+
<section className="sectionBg p-4 ml-14 sm:ml-0 w-[95%] min-h-screen sm:w-screen">
12+
{children}
13+
</section>
1214
</main>
1315
)
1416
}

app/globals.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ h1, h2, h3, h4, h5, h6 {
207207
@apply myBorder bg-transparent p-2 rounded-md value outline-none focus:inputFocus
208208
}
209209
.tags{
210-
@apply flex gap-1 sm:flex-wrap
210+
@apply flex gap-1 flex-wrap
211211
}
212212

213213
.tag{

components/HeroPage.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
const HeroPage = () => {
33
return (
44
<div className="flex flex-col justify-center items-center w-11/12 max-w-5xl mx-auto h-[50vh]">
5-
<h1 className="heading text-2xl sm:text-3xl">Empower Voices, Share Stories</h1>
5+
<h1 className="heading text-center text-2xl sm:text-3xl">Empower Voices, Share Stories</h1>
66
<p className="para text-center max-w-2xl text-sm my-4 sm:text-base">Create, share, and explore a community-driven blog platform where everyone has a voice. Join today and start publishing your ideas in a collaborative space.</p>
7-
<form className="myBorder mt-3 rounded-lg p-1">
7+
<form className="myBorder mt-3 rounded-lg p-1 flex flex-wrap justify-center gap-2">
88
<input type="text" className="input border-0" placeholder="search..."/>
99
<input type="submit" value={"Search"} className="primaryBtn primaryBtnText" />
1010
</form>

components/RecentBlogs.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ import { Blog } from "@/utils/types";
55

66
const RecentBlogs = ({recent}:{recent:Blog[]}) => {
77
return <>
8-
<div className="w-full max-w-7xl mx-auto px-8 sm:px-8">
8+
<div className="w-full max-w-7xl mx-auto px-4 sm:px-8 mb-20">
99
<h1 className="text-xl mb-4">Recent blog posts</h1>
10-
<div className="w-full grid gap-5 md:grid-cols-6 md:h-screen mx-auto">
10+
<div className="w-full grid gap-5 md:grid-cols-6 h-auto mx-auto">
1111
<div className="w-full col-span-3 mb-11 md:mb-0">
1212
<BlogCard blog={recent[0]}/>
1313
</div>
14-
<div className="col-span-3 w-full">
14+
<div className="col-span-3 w-full flex flex-col gap-2">
1515
<VerticalCard blog={recent[1]}/>
1616
<VerticalCard blog={recent[2]}/>
1717
<VerticalCard blog={recent[3]}/>

components/SingleCard.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import Tags from "@/components/Tags";
33
import { format, isValid } from "date-fns";
44
import { MdOutlineArrowOutward } from "react-icons/md";
55
import { Blog } from "@/utils/types";
6+
import Image from 'next/image';
67

78
const SingleCard = ({ blog }: { blog: Blog }) => {
89
const createdAt = new Date(blog?.createdAt);
@@ -26,12 +27,13 @@ const SingleCard = ({ blog }: { blog: Blog }) => {
2627
return (
2728
<Link href={`/blog/${blog?.id}`} className="w-full grid grid-cols-6 gap-2 h-auto max-w-full">
2829
<div className="w-full overflow-hidden col-span-6">
29-
<img
30+
<Image
3031
src={imageSrc}
3132
className="w-full h-full object-cover max-h-96"
3233
width={800}
3334
height={300}
3435
alt={`${blog?.blogName}`}
36+
priority
3537
/>
3638
</div>
3739
<div className="col-span-6">

components/verticalCard.tsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import Tags from "@/components/Tags"
33
import { format, isValid } from "date-fns";
44
import { MdOutlineArrowOutward } from "react-icons/md";
55
import { Blog } from "@/utils/types";
6+
import Image from 'next/image';
67

78
const VerticalCard = ({blog}:{blog:Blog}) => {
89
const createdAt = new Date(blog?.createdAt);
@@ -22,14 +23,15 @@ const VerticalCard = ({blog}:{blog:Blog}) => {
2223
const imageSrc = isValidUrl(blog?.blogCover) ? blog?.blogCover : "";
2324
return (
2425
<div className="w-full">
25-
<Link href={`/blog/${blog?.id}`} className="w-full grid grid-cols-6 gap-2 h-40">
26-
<div className="w-full overflow-y-hidden mb-4 col-span-2">
27-
<img
26+
<Link href={`/blog/${blog?.id}`} className="w-full grid grid-cols-6 gap-2 h-auto min-h-40">
27+
<div className="w-full h-full overflow-y-hidden mb-4 col-span-2">
28+
<Image
2829
src={imageSrc}
2930
className="w-full h-full object-cover"
3031
width={800}
3132
height={300}
3233
alt={`${blog?.blogName}`}
34+
priority
3335
/>
3436
</div>
3537
<div className="col-span-4">

0 commit comments

Comments
 (0)