Initial commit

This commit is contained in:
DK
2026-01-22 17:14:00 +00:00
commit b20665fcc3
7 changed files with 2339 additions and 0 deletions

163
src/app/blog/page.tsx Normal file
View File

@@ -0,0 +1,163 @@
"use client";
import { useEffect, useState } from "react";
import ReactLenis from "lenis/react";
import BlogCardTwo from '@/components/sections/blog/BlogCardTwo';
import FooterSimple from '@/components/sections/footer/FooterSimple';
import { ThemeProvider } from "@/providers/themeProvider/ThemeProvider";
import NavbarLayoutFloatingInline from '@/components/navbar/NavbarLayoutFloatingInline';
type BlogPost = {
id: string;
category: string | string[];
title: string;
excerpt: string;
imageSrc: string;
imageAlt?: string;
authorName: string;
authorAvatar?: string;
date: string;
onBlogClick?: () => void;
};
const defaultPosts: BlogPost[] = [
{
id: "1", category: ["Coffee", "Brewing"],
title: "The Art of Coffee Brewing", excerpt: "Discover the perfect techniques for brewing exceptional coffee that brings out the best flavors in every cup.", imageSrc: "/placeholders/placeholder3.avif", imageAlt: "Coffee brewing equipment", authorName: "Elena Rodriguez", authorAvatar: "/placeholders/placeholder3.avif", date: "20 Jan 2025", onBlogClick: () => console.log("Blog 1 clicked"),
},
{
id: "2", category: "Roasting", title: "From Bean to Cup: Our Roasting Process", excerpt: "Take a behind-the-scenes look at our meticulous roasting process that creates the perfect coffee experience.", imageSrc: "/placeholders/placeholder4.webp", imageAlt: "Coffee roasting process", authorName: "Marcus Chen", authorAvatar: "/placeholders/placeholder4.webp", date: "18 Jan 2025", onBlogClick: () => console.log("Blog 2 clicked"),
},
{
id: "3", category: ["Origins", "Sustainability"],
title: "Sustainable Coffee Sourcing", excerpt: "Learn about our commitment to ethical sourcing and how we support coffee farmers around the world.", imageSrc: "/placeholders/placeholder3.avif", imageAlt: "Coffee farm landscape", authorName: "Sarah Martinez", authorAvatar: "/placeholders/placeholder3.avif", date: "15 Jan 2025", onBlogClick: () => console.log("Blog 3 clicked"),
},
{
id: "4", category: "Culture", title: "Coffee Culture Around the World", excerpt: "Explore how different cultures celebrate and enjoy coffee, from Italian espresso to Ethiopian ceremonies.", imageSrc: "/placeholders/placeholder4.webp", imageAlt: "Global coffee culture", authorName: "Ahmed Hassan", authorAvatar: "/placeholders/placeholder4.webp", date: "12 Jan 2025", onBlogClick: () => console.log("Blog 4 clicked"),
},
];
export default function BlogPage() {
const [posts, setPosts] = useState<BlogPost[]>(defaultPosts);
const [isLoading, setIsLoading] = useState(true);
useEffect(() => {
const fetchPosts = async () => {
try {
const apiUrl = process.env.NEXT_PUBLIC_API_URL;
const projectId = process.env.NEXT_PUBLIC_PROJECT_ID;
if (!apiUrl || !projectId) {
console.warn("NEXT_PUBLIC_API_URL or NEXT_PUBLIC_PROJECT_ID not configured, using default posts");
setIsLoading(false);
return;
}
const url = `${apiUrl}/posts/${projectId}?status=published`;
const response = await fetch(url, {
method: "GET", headers: {
"Content-Type": "application/json"},
});
if (response.ok) {
const resp = await response.json();
const data = resp.data;
if (Array.isArray(data) && data.length > 0) {
const mappedPosts = data.map((post: any) => ({
id: post.id || String(Math.random()),
category: post.category || "General", title: post.title || "Untitled", excerpt: post.excerpt || post.content.slice(0, 30) || "", imageSrc: post.imageUrl || "/placeholders/placeholder3.avif", imageAlt: post.imageAlt || post.title || "", authorName: post.author?.name || "Anonymous", authorAvatar: post.author?.avatar || "/placeholders/placeholder3.avif", date: post.date || post.createdAt || new Date().toLocaleDateString("en-GB", { day: "numeric", month: "short", year: "numeric" }),
onBlogClick: () => console.log(`Blog ${post.id} clicked`),
}));
setPosts(mappedPosts);
}
} else {
console.warn(`API request failed with status ${response.status}, using default posts`);
}
} catch (error) {
console.error("Error fetching posts:", error);
} finally {
setIsLoading(false);
}
};
fetchPosts();
}, []);
return (
<ThemeProvider
defaultButtonVariant="hover-bubble"
defaultTextAnimation="background-highlight"
borderRadius="soft"
contentWidth="smallMedium"
sizing="large"
background="aurora"
cardStyle="gradient-radial"
primaryButtonStyle="flat"
secondaryButtonStyle="layered"
headingFontWeight="extrabold"
>
<ReactLenis root>
<div className="min-h-screen bg-background">
<NavbarLayoutFloatingInline
brandName="BrewHaven"
navItems={[
{ name: "Home", id: "/home" },
{ name: "About", id: "about" },
{ name: "Menu", id: "products" },
{ name: "Process", id: "features" },
{ name: "Contact", id: "contact" }
]}
button={{ text: "Visit Us", href: "contact" }}
/>
{isLoading ? (
<div className="w-content-width mx-auto py-20 text-center">
<p className="text-foreground">Loading posts...</p>
</div>
) : (
<BlogCardTwo
blogs={posts}
title="Coffee Chronicles"
description="Discover the stories behind every cup, from bean to brew and everything in between"
textboxLayout="default"
useInvertedBackground="noInvert"
animationType="slide-up"
carouselMode="buttons"
tag="Blog"
/>
)}
<FooterSimple
columns={[
{
title: "Navigate", items: [
{ label: "Home", href: "#hero" },
{ label: "About", href: "#about" },
{ label: "Menu", href: "#products" },
{ label: "Contact", href: "#contact" }
]
},
{
title: "Visit Us", items: [
{ label: "123 Coffee Lane, Brew City, BC 45678" },
{ label: "Mon-Fri: 6:30am - 8:00pm" },
{ label: "Sat-Sun: 8:00am - 9:00pm" },
{ label: "(555) 123-4567" }
]
},
{
title: "Follow Us", items: [
{ label: "Instagram", href: "https://instagram.com" },
{ label: "Facebook", href: "https://facebook.com" },
{ label: "Twitter", href: "https://twitter.com" }
]
}
]}
bottomLeftText="© 2025 BrewHaven Coffee. All rights reserved."
bottomRightText="Roasting Excellence, Brewing Passion"
/>
</div>
</ReactLenis>
</ThemeProvider>
);
}