From 46c1e3244f26aeda06c52640f7315a39755a24b5 Mon Sep 17 00:00:00 2001 From: Akshay Date: Fri, 12 Dec 2025 11:34:05 +0530 Subject: [PATCH] feat: Replace simple loading spinner with a detailed skeleton UI for blog post pages. --- app/blog/[slug]/page.tsx | 128 ++++++++++++++++++++----- app/blog/page.tsx | 195 ++++++++++++++++++++++++++++----------- 2 files changed, 246 insertions(+), 77 deletions(-) diff --git a/app/blog/[slug]/page.tsx b/app/blog/[slug]/page.tsx index 31b181ed..083b6061 100644 --- a/app/blog/[slug]/page.tsx +++ b/app/blog/[slug]/page.tsx @@ -88,7 +88,7 @@ export default function BlogPostPage() { const [likedByUser, setLikedByUser] = useState(false); const [views, setViews] = useState(0); const params = useParams() - + const slug = params?.slug as string useEffect(() => { @@ -115,8 +115,8 @@ export default function BlogPostPage() { tags: Array.isArray(data.tags) ? data.tags : (typeof data.tags === 'string' && data.tags - ? (data.tags as string).split(',').map((t: string) => t.trim()) - : []), + ? (data.tags as string).split(',').map((t: string) => t.trim()) + : []), }) } setIsLoading(false) @@ -195,11 +195,89 @@ export default function BlogPostPage() { if (isLoading) { return ( -
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+ {/* article header skeleton */} +
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+ +
+ {[1, 2, 3, 4, 5].map((i) => ( +
+
+
+ ))} +
+
+ + {/* article image skeleton */} +
+
+
+
+
+ + {/* article content skeleton */} +
+ {[1, 2, 3, 4].map((i) => ( +
+
+
+
+
+
+
+
+
+
+
+ ))} +
+
+
+
) } @@ -207,7 +285,7 @@ export default function BlogPostPage() { if (fetchError) { return (
- {/* header */} -
+
@@ -248,13 +326,13 @@ export default function BlogPostPage() { - -
{/* article header */} - )}
- +

{post?.title}

- +

{post?.excerpt}

- +
@@ -302,10 +380,10 @@ export default function BlogPostPage() {
- {new Date(post?.date || '').toLocaleDateString('en-US', { - year: 'numeric', - month: 'long', - day: 'numeric' + {new Date(post?.date || '').toLocaleDateString('en-US', { + year: 'numeric', + month: 'long', + day: 'numeric' })}
@@ -324,7 +402,7 @@ export default function BlogPostPage() { {/* article image */} - {/* article content */} -
- + {/* tags */}
{post?.tags.map((tag: string) => ( @@ -387,7 +465,7 @@ export default function BlogPostPage() { {post?.content.split('\n\n').slice(0, 3).join('\n\n')}
- + {/* authentication prompt */}
-
+
) } \ No newline at end of file diff --git a/app/blog/page.tsx b/app/blog/page.tsx index e63a45e4..146ef5c1 100644 --- a/app/blog/page.tsx +++ b/app/blog/page.tsx @@ -1,4 +1,4 @@ -"use client" +"use client" import { useState, useEffect } from "react" import { createClient } from "@/lib/supabase/client" @@ -48,8 +48,8 @@ export default function BlogPage() { tags: Array.isArray(post.tags) ? post.tags : (typeof post.tags === 'string' && post.tags - ? (post.tags as string).split(',').map((t) => t.trim()) - : []), + ? (post.tags as string).split(',').map((t) => t.trim()) + : []), })) // Fetch like counts in parallel const likeCounts = await Promise.all( @@ -121,11 +121,102 @@ export default function BlogPage() { if (isLoading) { return ( -
-
-
-
-
+
+
+ {/* Hero Skeleton */} +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + {/* Search & Filter Skeleton */} +
+
+
+
+
+
+
+ {[1, 2, 3, 4, 5].map((i) => ( +
+
+
+ ))} +
+
+
+
+ + {/* Blog Cards Skeleton */} +
+
+
+
+
+
+
+
+
+
+
+ {[1, 2, 3, 4, 5, 6].map((i) => ( +
+ {/* Image placeholder */} +
+
+
+
+
+ {/* Content placeholder */} +
+
+
+
+
+
+
+
+
+
+
+ {[1, 2, 3].map((j) => ( +
+
+
+ ))} +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ))} +
+
+
+
) } @@ -144,7 +235,7 @@ export default function BlogPage() { return (
-
+
{/* Hero Section */}
-
-
- Learn from the{" "} - -
-
- */}
- -
+ {/* Underline glow */} + + +

Editor's Picks @@ -422,7 +513,7 @@ export default function BlogPage() {
- 📖 All Articles */} -
{/* Changed from items-center to items-start */} - -
+ {/* Underline glow */} + + +

Latest Stories @@ -560,7 +651,7 @@ export default function BlogPage() {

{regularPosts.length === 0 && ( - -
) } \ No newline at end of file