Skip to content

Commit 59c6c95

Browse files
committed
refactor: update Articles and Loading components for improved layout and loading states, enhance metadata for Posts page
1 parent 56829dc commit 59c6c95

File tree

4 files changed

+105
-28
lines changed

4 files changed

+105
-28
lines changed

app/posts/[title]/page.tsx

Lines changed: 52 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import SocialSharing from "@/components/SocialSharing";
55
import Subheading from "@/components/Subheading";
66
import Link from "next/link";
77

8+
import { RiInstagramLine, RiTwitterFill, RiYoutubeFill, RiGithubFill, RiTiktokFill, RiPatreonFill } from "react-icons/ri";
9+
10+
811
interface Article {
912
id: string;
1013
title: string;
@@ -91,7 +94,15 @@ export default async function ArticleDetails({
9194
content: articleData.content.map(contentItem => ({
9295
...contentItem,
9396
...(contentItem.date && { date: contentItem.date.toDate() })
94-
}))
97+
})),
98+
title: "",
99+
slug: "",
100+
read: "",
101+
label: "",
102+
img: "",
103+
imgAlt: "",
104+
description: "",
105+
authorUID: ""
95106
};
96107

97108
// Get latest articles (excluding current)
@@ -111,6 +122,13 @@ export default async function ArticleDetails({
111122
...data,
112123
date: data.date?.toDate(),
113124
authorName: data.authorName || "Unknown Author",
125+
label: data.label || "No Label",
126+
slug: data.slug,
127+
img: data.img || "/default-image.png",
128+
imgAlt: data.imgAlt || "Article image",
129+
title: data.title || "Untitled",
130+
description: data.description || "No description available",
131+
read: data.read || "Unknown",
114132
};
115133
})
116134
.filter(article => article.id !== processedArticle.id)
@@ -188,27 +206,39 @@ export default async function ArticleDetails({
188206
<div className="flex flex-wrap justify-between">
189207
<p className="flex font-semibold">Share</p>
190208
<SocialSharing
191-
links={[
192-
{
193-
href: "#",
194-
ariaLabel: "Share on Instagram",
195-
src: "/icons/ri_instagram-line.svg",
196-
alt: "Instagram",
197-
},
198-
{
199-
href: "#",
200-
ariaLabel: "Share on Twitter",
201-
src: "/icons/ri_twitter-fill.svg",
202-
alt: "Twitter",
203-
},
204-
{
205-
href: "#",
206-
ariaLabel: "Share on YouTube",
207-
src: "/icons/ri_youtube-fill.svg",
208-
alt: "YouTube",
209-
},
210-
]}
211-
/>
209+
links={[
210+
{
211+
href: "https://www.youtube.com/@lap-tutorials",
212+
ariaLabel: "Visit our YouTube channel",
213+
Icon: RiYoutubeFill,
214+
},
215+
{
216+
href: "https://github.com/LAP-Tutorials",
217+
ariaLabel: "Visit our GitHub page",
218+
Icon: RiGithubFill,
219+
},
220+
{
221+
href: "https://www.instagram.com/lap.mgmt.team/",
222+
ariaLabel: "Visit our Instagram page",
223+
Icon: RiInstagramLine,
224+
},
225+
{
226+
href: "https://x.com/lap_mgmt",
227+
ariaLabel: "Visit our X page",
228+
Icon: RiTwitterFill,
229+
},
230+
{
231+
href: "https://www.tiktok.com/@lap_mgmt",
232+
ariaLabel: "Visit our TikTok page",
233+
Icon: RiTiktokFill,
234+
},
235+
{
236+
href: "http://patreon.com/lap_mgmt",
237+
ariaLabel: "Visit our GitHub page",
238+
Icon: RiPatreonFill,
239+
},
240+
]}
241+
/>
212242
</div>
213243
</div>
214244
</div>

app/posts/page.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ import Loading from "@/components/Articles/loading";
33
import PageTitle from "@/components/PageTitle";
44
import { Suspense } from "react";
55

6+
67
export const metadata = {
7-
title: "Articles | Fyrre Magazine",
8-
description: "Articles from our team of writers, editors and artists",
8+
title: "Posts | L.A.P",
9+
description: "Posts from our dedicated team.",
910
};
1011

1112
export default function MagazinePage() {

components/Articles/Articles.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Button } from "../ui/button";
55
import { useState, useEffect } from "react";
66
import { collection, getDocs, query, orderBy } from "firebase/firestore";
77
import Link from "next/link";
8+
import Loading from "./loading"
89

910
interface Article {
1011
id: string;
@@ -53,6 +54,7 @@ export default function Articles() {
5354
const authorsSnapshot = await getDocs(collection(db, "authors"));
5455
const authors = authorsSnapshot.docs.map(doc => ({
5556
uid: doc.id,
57+
name: doc.data().name,
5658
...doc.data(),
5759
}));
5860

@@ -83,7 +85,7 @@ export default function Articles() {
8385
: articles.filter(article => article.label === selectedLabel);
8486

8587
if (loading) {
86-
return <div className="text-center p-8">Loading articles...</div>;
88+
return <Loading />;
8789
}
8890

8991
return (
@@ -114,15 +116,15 @@ export default function Articles() {
114116
<p className="uppercase">{article.label}</p>
115117
</span>
116118
</div>
117-
<Link href={`magazine/${article.slug}`}>
119+
<Link href={`posts/${article.slug}`}>
118120
<img
119121
className="w-full my-8 hover:scale-105 transition"
120122
src={article.img}
121123
alt={article.imgAlt}
122124
/>
123125
</Link>
124126
<h2 className="heading3-title mb-3">
125-
<Link href={`/magazine/${article.slug}`}>
127+
<Link href={`/posts/${article.slug}`}>
126128
{article.title}
127129
</Link>
128130
</h2>

components/Articles/loading.tsx

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,47 @@
1+
import { Skeleton } from "../ui/skeleton";
2+
13
export default function Loading() {
2-
return <div>Test</div>;
4+
return (
5+
<div className="max-w-[95rem] w-full mx-auto py-8 lg:pt-24 lg:pb-48">
6+
{/* Categories Filter Skeleton */}
7+
<div className="flex justify-end gap-4 mb-6">
8+
{[...Array(4)].map((_, index) => (
9+
<Skeleton key={index} className="bg-[#a1a1a1] h-10 w-20 rounded-md" />
10+
))}
11+
</div>
12+
13+
{/* Grid layout for the post cards */}
14+
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
15+
{[...Array(9)].map((_, index) => (
16+
<div key={index} className="bg-[#a1a1a1] p-6 flex flex-col gap-4">
17+
{/* Date & Category */}
18+
<div className="flex justify-between items-center">
19+
<Skeleton className="bg-[#a1a1a1] h-4 w-28 rounded-md" />
20+
<Skeleton className="bg-[#a1a1a1] h-6 w-12 rounded-md" />
21+
</div>
22+
23+
{/* Image Skeleton */}
24+
<Skeleton className="w-full h-60 bg-[#a1a1a1] rounded-md" />
25+
26+
{/* Title */}
27+
<Skeleton className="h-6 w-3/4 bg-[#a1a1a1] rounded-md" />
28+
29+
{/* Description */}
30+
<Skeleton className="h-4 w-full bg-[#a1a1a1] rounded-md" />
31+
<Skeleton className="h-4 w-5/6 bg-[#a1a1a1] rounded-md" />
32+
<Skeleton className="h-4 w-4/5 bg-[#a1a1a1] rounded-md" />
33+
34+
{/* Author & Duration */}
35+
<div className="flex justify-between items-center mt-4">
36+
<div className="flex gap-2">
37+
<Skeleton className="bg-[#a1a1a1] h-4 w-16 rounded-md" />
38+
<Skeleton className="bg-[#a1a1a1] h-4 w-20 rounded-md" />
39+
</div>
40+
<Skeleton className="bg-[#a1a1a1] h-4 w-16 rounded-md" />
41+
</div>
42+
</div>
43+
))}
44+
</div>
45+
</div>
46+
);
347
}

0 commit comments

Comments
 (0)