Update src/app/blog/page.tsx

This commit is contained in:
2026-01-21 11:10:37 +00:00
parent cd9d509626
commit 91333faa66

View File

@@ -2,42 +2,34 @@
import { useEffect, useState } from "react";
import ReactLenis from "lenis/react";
import BlogCardEleven from '@/components/sections/blog/BlogCardEleven';
import TestimonialCardTwo from '@/components/sections/testimonial/TestimonialCardTwo';
import FooterCard from '@/components/sections/footer/FooterCard';
import { ThemeProvider } from "@/providers/themeProvider/ThemeProvider";
import NavbarStyleApple from '@/components/navbar/NavbarStyleApple/NavbarStyleApple';
import { PawPrint } from 'lucide-react';
import { PawPrint, Facebook, Instagram, Twitter } from 'lucide-react';
type BlogPost = {
id: string;
title: string;
author: string;
description: string;
tags: string[];
name: string;
role: string;
testimonial: string;
imageSrc?: string;
imageAlt?: string;
videoSrc?: string;
videoAriaLabel?: string;
onBlogClick?: () => void;
};
const defaultPosts: BlogPost[] = [
{
id: "1", title: "Finding Forever Homes: Success Stories from Happy Paws", author: "Sarah Mitchell", description: "Heartwarming stories of rescued animals finding their perfect families through our adoption program.", tags: ["Adoption", "Success Stories"],
imageSrc: "/placeholders/placeholder3.avif", imageAlt: "Happy dog with new family", onBlogClick: () => console.log("Blog 1 clicked"),
id: "1", name: "Finding Forever Homes", role: "Success Stories from Happy Paws", testimonial: "Heartwarming stories of rescued animals finding their perfect families through our adoption program. Discover how love transforms lives.", imageSrc: "/placeholders/placeholder1.webp", imageAlt: "Happy dog with new family"
},
{
id: "2", title: "Pet Care Tips: Keeping Your Furry Friends Healthy", author: "Dr. Michael Chen", description: "Essential health and wellness tips from our veterinary team to ensure your pets live their best lives.", tags: ["Health", "Tips"],
imageSrc: "/placeholders/placeholder4.webp", imageAlt: "Veterinarian examining a cat", onBlogClick: () => console.log("Blog 2 clicked"),
id: "2", name: "Pet Care Tips", role: "Keeping Your Furry Friends Healthy", testimonial: "Essential health and wellness tips from our veterinary team to ensure your pets live their best lives. Expert advice for new pet parents.", imageSrc: "/placeholders/placeholder1.webp", imageAlt: "Veterinarian examining a cat"
},
{
id: "3", title: "Volunteer Spotlight: Making a Difference Together", author: "Emma Rodriguez", description: "Meet our amazing volunteers who dedicate their time to helping animals in need find loving homes.", tags: ["Volunteers", "Community"],
imageSrc: "/placeholders/placeholder3.avif", imageAlt: "Volunteers playing with shelter dogs", onBlogClick: () => console.log("Blog 3 clicked"),
id: "3", name: "Volunteer Spotlight", role: "Making a Difference Together", testimonial: "Meet our amazing volunteers who dedicate their time to helping animals in need find loving homes. Community heroes making an impact.", imageSrc: "/placeholders/placeholder1.webp", imageAlt: "Volunteers playing with shelter dogs"
},
{
id: "4", title: "Understanding Animal Behavior: A Guide for New Pet Parents", author: "Lisa Thompson", description: "Learn to decode your pet's behavior and build a stronger bond with your new four-legged family member.", tags: ["Behavior", "New Owners"],
imageSrc: "/placeholders/placeholder4.webp", imageAlt: "Dog trainer working with a puppy", onBlogClick: () => console.log("Blog 4 clicked"),
},
id: "4", name: "Animal Behavior Guide", role: "Understanding Your New Pet", testimonial: "Learn to decode your pet's behavior and build a stronger bond with your new four-legged family member. Professional training insights.", imageSrc: "/placeholders/placeholder1.webp", imageAlt: "Dog trainer working with a puppy"
}
];
export default function BlogPage() {
@@ -59,7 +51,8 @@ export default function BlogPage() {
const url = `${apiUrl}/posts/${projectId}`;
const response = await fetch(url, {
method: "GET", headers: {
"Content-Type": "application/json"},
"Content-Type": "application/json"
},
});
if (response.ok) {
@@ -67,9 +60,7 @@ export default function BlogPage() {
if (Array.isArray(data) && data.length > 0) {
const mappedPosts = data.map((post: any) => ({
id: post.id || String(Math.random()),
title: post.title || "Untitled", author: post.author?.name || "Anonymous", description: post.excerpt || post.content?.slice(0, 100) || "", tags: post.tags || ["General"],
imageSrc: post.imageUrl || "/placeholders/placeholder3.avif", imageAlt: post.imageAlt || post.title || "", videoSrc: post.videoUrl,
videoAriaLabel: post.videoAriaLabel || post.title || "", onBlogClick: () => console.log(`Blog ${post.id} clicked`),
name: post.title || "Untitled", role: post.author?.name || "Happy Paws Story", testimonial: post.excerpt || post.content?.slice(0, 150) || "", imageSrc: post.imageUrl || "/placeholders/placeholder1.webp", imageAlt: post.imageAlt || post.title || ""
}));
setPosts(mappedPosts);
}
@@ -104,21 +95,21 @@ export default function BlogPage() {
<NavbarStyleApple
brandName="Happy Paws"
navItems={[
{"name":"Home","id":"hero"},
{"name":"About","id":"about"},
{"name":"Adopt","id":"featured"},
{"name":"FAQ","id":"faq"},
{"name":"Contact","id":"contact"}
{ name: "Home", id: "hero" },
{ name: "About", id: "about" },
{ name: "Adopt", id: "featured" },
{ name: "FAQ", id: "faq" },
{ name: "Contact", id: "contact" }
]}
/>
{isLoading ? (
<div className="w-content-width mx-auto py-20 text-center">
<p className="text-foreground">Loading posts...</p>
<p className="text-foreground">Loading stories...</p>
</div>
) : (
<BlogCardEleven
blogs={posts}
<TestimonialCardTwo
testimonials={posts}
animationType="slide-up"
title="Happy Paws Stories"
description="Discover heartwarming tales of rescue, care, and forever homes from our animal shelter community."
@@ -133,9 +124,9 @@ export default function BlogPage() {
logoText="Happy Paws"
copyrightText="© 2025 Happy Paws Shelter | Helping animals find forever homes"
socialLinks={[
{"icon":"Facebook","href":"https://facebook.com/happypaws","ariaLabel":"Facebook"},
{"icon":"Instagram","href":"https://instagram.com/happypaws","ariaLabel":"Instagram"},
{"icon":"Twitter","href":"https://twitter.com/happypaws","ariaLabel":"Twitter"}
{ icon: Facebook, href: "https://facebook.com/happypaws", ariaLabel: "Facebook" },
{ icon: Instagram, href: "https://instagram.com/happypaws", ariaLabel: "Instagram" },
{ icon: Twitter, href: "https://twitter.com/happypaws", ariaLabel: "Twitter" }
]}
/>
</div>