Skip to content

Commit 04bfac7

Browse files
Jay PanchalJay Panchal
authored andcommitted
refactor: Added Component to organize the code, Added blog content section, added css for blog content
1 parent 568b790 commit 04bfac7

File tree

5 files changed

+303
-195
lines changed

5 files changed

+303
-195
lines changed

src/app/[slug]/components/Author.tsx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { AuthorDataType } from '@/data/types'
2+
import Image from 'next/image'
3+
import Link from 'next/link'
4+
import React from 'react'
5+
6+
type AuthorProps = {
7+
authorData: AuthorDataType
8+
}
9+
10+
const Author = ({authorData}: AuthorProps) => {
11+
return (
12+
<div className="container-padding">
13+
<Link className="relative left-0 flex items-center" href="#">
14+
<Image
15+
width={500}
16+
height={500}
17+
className="w-20 h-20 rounded-full mr-5 max-w-full"
18+
src={authorData.imgSrc}
19+
alt={authorData.name}
20+
/>
21+
<div className="">
22+
<h5 className="text-xl font-semibold">{authorData.name}</h5>
23+
<p className="text-sm">{authorData.teamName}</p>
24+
</div>
25+
</Link>
26+
</div>
27+
)
28+
}
29+
30+
export default Author
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import React from 'react'
2+
3+
type LeftSectionProps = {
4+
subHeadings: string[]
5+
content: string
6+
}
7+
8+
const LeftSection = ({subHeadings, content}: LeftSectionProps) => {
9+
return (
10+
<div className="w-full mr-0 mb-12 lg:mb-0 lg:w-[65%] lg:mr-[5%] blog--description">
11+
{subHeadings.map((data, index) => (
12+
<h2 key={index} className="text-xl lg:text-3xl mb-14">
13+
{data}
14+
</h2>
15+
))}
16+
<div dangerouslySetInnerHTML={{ __html: content }}></div>
17+
</div>
18+
)
19+
}
20+
21+
export default LeftSection
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import { PostType, TagsType } from "@/data/types";
2+
import Link from "next/link";
3+
import React from "react";
4+
5+
type RightSectionProps = {
6+
latestPosts: PostType[]
7+
tags: TagsType[]
8+
}
9+
10+
const RightSection = ({latestPosts, tags}: RightSectionProps) => {
11+
return (
12+
<div className="lg:w-[30%] mr-0 pt-5 border-t-0 lg:border-t lg:border-t-black/20">
13+
<h4 className="text-4xl mb-10 mt-5 text-[#505050] font-semibold">
14+
Latest Posts
15+
</h4>
16+
<div className="border-b border-b-black/20 pb-5 mb-10">
17+
{latestPosts.map((post, index) => (
18+
<div key={index} className="mb-10">
19+
<h6 className="text-sm opacity-75 mb-1.5 font-normal">{`${post.date} | ${post.name}`}</h6>
20+
<h5 className="text-xl mb-2.5 text-[#212529] font-medium">
21+
{post.title}
22+
</h5>
23+
<p className="text-sm mb-5 font-light">{post.description}</p>
24+
<Link
25+
className="primary-button bg-white"
26+
href={post.link}
27+
target="_blank"
28+
>
29+
Read
30+
</Link>
31+
</div>
32+
))}
33+
</div>
34+
<h4 className="text-4xl mb-10 mt-5 text-[#505050] font-semibold">
35+
Tag Cloud
36+
</h4>
37+
<div className="flex flex-wrap lg:border-b border-b-black/20 pb-10">
38+
{tags.map((tag) => (
39+
<Link
40+
key={tag.link}
41+
className="py-1.5 px-5 bg-[#D0D0D0] mr-2.5 mb-2.5 rounded-full border-none text-sm relative animation-easein-slow left-0 hover:bg-[rgba(208,208,208,0.3)]"
42+
href={tag.link}
43+
>
44+
{tag.name}
45+
</Link>
46+
))}
47+
</div>
48+
</div>
49+
);
50+
};
51+
52+
export default RightSection;

src/app/[slug]/page.tsx

Lines changed: 21 additions & 174 deletions
Original file line numberDiff line numberDiff line change
@@ -1,128 +1,16 @@
11
import PageNavbar from "@/components/PageNavbar";
2+
import { blogsPageData } from "@/data";
23
import Image from "next/image";
3-
import Link from "next/link";
44
import React from "react";
55
import { twMerge } from "tailwind-merge";
6+
import Author from "./components/Author";
7+
import LeftSection from "./components/LeftSection";
8+
import RightSection from "./components/RightSection";
69

710
export const dynamicParams = false;
8-
type PagesDataType = {
9-
heroSection: {
10-
heading: string;
11-
description: string;
12-
images: {
13-
desktop: string;
14-
mobile: string;
15-
};
16-
date: string;
17-
name: string;
18-
};
19-
subHeadings: string[];
20-
latestPosts: {
21-
date: string;
22-
name: string;
23-
imgSrc: string;
24-
title: string;
25-
description: string;
26-
link: string;
27-
imgClassName: string;
28-
}[];
29-
tags: {
30-
name: string;
31-
link: string;
32-
}[];
33-
author: {
34-
imgSrc: string;
35-
name: string;
36-
teamName: string;
37-
};
38-
};
39-
40-
const pagesData: { [key: string]: PagesDataType } = {
41-
"frontend-performance-testing-best-practices": {
42-
heroSection: {
43-
heading: "Frontend Performance Testing: Best Practices",
44-
description:
45-
"Our complete suite of technology services to deliver better products, create stronger brands, new markets, and greater profitability through digital capabilities.",
46-
images: {
47-
desktop:
48-
"https://procedure.tech/wp-content/uploads/2022/11/blog1-banner.webp",
49-
mobile:
50-
"https://procedure.tech/wp-content/uploads/2022/11/mob-blog1-banner.webp",
51-
},
52-
date: "November 30, 2022",
53-
name: "Rizwan Memon",
54-
},
55-
subHeadings: [
56-
"You have been working hard to deliver all the features on the project, and suddenly one fine day the company’s Slack goes off with messages like “Our bundle is around 17MB”or “Our website is lacking speed”. You are scratching your head as to why you even got here in the first place. What did you miss?",
57-
"This blog will walk you through some best practices for Frontend Performance and Testing. It will walk you through metrics you can calculate on your CI/CD pipelines to avoid those surprise attacks related to performance issues and React best practices for an optimized bundle.",
58-
],
59-
latestPosts: [
60-
{
61-
date: "May 26, 2022",
62-
name: "Rucheta Gogte",
63-
imgSrc:
64-
"https://i0.wp.com/procedure.tech/wp-content/uploads/2022/05/resources-blog3.webp?fit=800%2C800&ssl=1",
65-
title: "Why Robot Framework",
66-
description:
67-
"If you are trying to identify what are the best automation frameworks out there, we…",
68-
link: "https://procedure.tech/why-robot-framework/",
69-
imgClassName: "rounded-r-none rounded-bl-full rounded-br-full",
70-
},
71-
{
72-
date: "January 3, 2022",
73-
name: "Sreeraj Rajan",
74-
imgSrc:
75-
"https://i0.wp.com/procedure.tech/wp-content/uploads/2022/01/resources-blog4.webp?fit=800%2C800&ssl=1",
76-
title: "Reducing our Deployment times by 87%",
77-
description:
78-
"You can streamline your deployment process, decreasing deploy times significantly and enabling faster rollbacks with…",
79-
link: "https://procedure.tech/reducing-our-deployment-times-by-87/",
80-
imgClassName: "rounded-r-none rounded-tr-full rounded-tl-full",
81-
},
82-
{
83-
date: "June 10, 2021",
84-
name: "Sreeraj Rajan",
85-
imgSrc:
86-
"https://i0.wp.com/procedure.tech/wp-content/uploads/2021/06/resources-blog2.webp?fit=800%2C800&ssl=1",
87-
title: "Connecting Django to RDS via pgbouncer using IAM auth",
88-
description:
89-
"To connect Django to RDS via using IAM, you'll need an OIDC provider and a…",
90-
link: "https://procedure.tech/connecting-django-to-rds-via-pgbouncer-using-iam-auth/",
91-
imgClassName: "rounded-r-none rounded-bl-full rounded-tl-full",
92-
},
93-
],
94-
tags: [
95-
{
96-
name: "Pipelines",
97-
link: "https://procedure.tech/tag/pipelines/",
98-
},
99-
{
100-
name: "react",
101-
link: "https://procedure.tech/tag/react/",
102-
},
103-
{
104-
name: "Slack",
105-
link: "https://procedure.tech/tag/slack/",
106-
},
107-
{
108-
name: "Frontend",
109-
link: "https://procedure.tech/tag/frontend/",
110-
},
111-
{
112-
name: "CI/CD",
113-
link: "https://procedure.tech/tag/ci-cd/",
114-
},
115-
],
116-
author: {
117-
imgSrc: "https://procedure.tech/wp-content/uploads/2022/11/rizwan.jpg",
118-
name: "Rizwan Memon",
119-
teamName: "Tech@Procedure",
120-
},
121-
},
122-
};
12311

12412
export async function generateStaticParams() {
125-
return Object.keys(pagesData).map((pageName) => ({
13+
return Object.keys(blogsPageData).map((pageName) => ({
12614
slug: pageName,
12715
}));
12816
}
@@ -133,7 +21,7 @@ export default async function Page({
13321
params: Promise<{ slug: string }>;
13422
}) {
13523
const slug = (await params).slug;
136-
const pageData = pagesData[slug];
24+
const pageData = blogsPageData[slug];
13725

13826
return (
13927
<>
@@ -181,68 +69,27 @@ export default async function Page({
18169
<section className="">
18270
<div className="container-padding">
18371
<div className="mt-[7vw] flex flex-wrap pb-7 lg:border-b lg:border-b-black/20">
184-
<div className="w-full mr-0 mb-12 lg:mb-0 lg:w-[65%] lg:mr-[5%]">
185-
{pageData.subHeadings.map((data, index) => (
186-
<h2 key={index} className="text-xl lg:text-3xl mb-14">
187-
{data}
188-
</h2>
189-
))}
190-
</div>
191-
<div className="lg:w-[30%] mr-0 pt-5 border-none lg:border-t border-t-black/20">
192-
<h4 className="text-4xl mb-10 mt-5 text-[#505050] font-semibold">
193-
Latest Posts
194-
</h4>
195-
<div className="border-b border-b-black/20 pb-5 mb-10">
196-
{pageData.latestPosts.map((post, index) => (
197-
<div key={index} className="mb-10">
198-
<h6 className="text-sm opacity-75 mb-1.5 font-normal">{`${post.date} | ${post.name}`}</h6>
199-
<h5 className="text-xl mb-2.5 text-[#212529] font-medium">{post.title}</h5>
200-
<p className="text-sm mb-5 font-light">
201-
{post.description}
202-
</p>
203-
<Link
204-
className="primary-button bg-white"
205-
href={post.link}
206-
target="_blank"
207-
>
208-
Read
209-
</Link>
210-
</div>
211-
))}
212-
</div>
213-
<h4 className="text-4xl mb-10 mt-5 text-[#505050] font-semibold">
214-
Tag Cloud
215-
</h4>
216-
<div className="flex flex-wrap lg:border-b border-b-black/20 pb-10">
217-
{pageData.tags.map((tag) => (
218-
<Link
219-
key={tag.link}
220-
className="py-1.5 px-5 bg-[#D0D0D0] mr-2.5 mb-2.5 rounded-full border-none text-sm relative animation-easein-slow left-0 hover:bg-[rgba(208,208,208,0.3)]"
221-
href={tag.link}
222-
>
223-
{tag.name}
224-
</Link>
225-
))}
226-
</div>
72+
<LeftSection
73+
subHeadings={pageData.subHeadings}
74+
content={pageData.content}
75+
/>
76+
<div className="block lg:hidden ml-[calc(-7vw)] pt-5 pb-16 -mt-10 mx-auto cursor-default pointer-events-none">
77+
<Author
78+
authorData={pageData.author}
79+
/>
22780
</div>
81+
<RightSection
82+
latestPosts={pageData.latestPosts}
83+
tags={pageData.tags}
84+
/>
22885
</div>
22986
</div>
23087
</section>
23188
<div className="hidden my-0 mx-auto py-16 px-0 cursor-default pointer-events-none lg:block">
23289
<div className="container-padding">
233-
<Link className="relative left-0 flex items-center" href="#">
234-
<Image
235-
width={500}
236-
height={500}
237-
className="w-20 h-20 rounded-full mr-5 max-w-full"
238-
src={pageData.author.imgSrc}
239-
alt={pageData.author.name}
240-
/>
241-
<div className="">
242-
<h5 className="text-xl font-semibold">{pageData.author.name}</h5>
243-
<p className="text-sm">{pageData.author.teamName}</p>
244-
</div>
245-
</Link>
90+
<Author
91+
authorData={pageData.author}
92+
/>
24693
</div>
24794
</div>
24895
</>

0 commit comments

Comments
 (0)