diff --git a/shipixen/components/shared/InteractiveStatCard.tsx b/shipixen/components/shared/InteractiveStatCard.tsx index 25357afb..70d36428 100644 --- a/shipixen/components/shared/InteractiveStatCard.tsx +++ b/shipixen/components/shared/InteractiveStatCard.tsx @@ -1,4 +1,5 @@ import clsx from 'clsx'; +import Link from 'next/link'; const Wrapper = ({ children, @@ -14,11 +15,7 @@ const Wrapper = ({ } return ( - +
{children}
-
+ ); }; diff --git a/shipixen/layouts/ProductLayout.tsx b/shipixen/layouts/ProductLayout.tsx index 5e46d180..2640530d 100644 --- a/shipixen/layouts/ProductLayout.tsx +++ b/shipixen/layouts/ProductLayout.tsx @@ -1,7 +1,12 @@ import { cn } from '@/lib/utils'; import { ReactNode } from 'react'; import { ExternalLinkIcon } from 'lucide-react'; -import { CoreContent } from '@shipixen/pliny/utils/contentlayer'; +import { + CoreContent, + allCoreContent, +} from '@shipixen/pliny/utils/contentlayer'; +import { allBlogs } from 'shipixen-contentlayer/generated'; + import type { Blog, Authors } from 'shipixen-contentlayer/generated'; import Link from '@/components/shared/Link'; import Header from '@/components/shared/Header'; @@ -11,6 +16,7 @@ import { siteConfig } from '@/data/config/site.settings'; import ScrollTop from '@/components/shared/ScrollTop'; import { hashStringToColor } from '@/components/shared/util/hash-string-color'; import clsx from 'clsx'; +import { PostItem } from '@/components/blog/home/PostItem'; // Import PostItem const postDateTemplate: Intl.DateTimeFormatOptions = { weekday: 'long', @@ -23,8 +29,6 @@ interface LayoutProps { className?: string; content: CoreContent; authorDetails: CoreContent[]; - next?: { path: string; title: string }; - prev?: { path: string; title: string }; children: ReactNode; } @@ -32,15 +36,33 @@ export default function PostLayout({ className, content, authorDetails, - next, - prev, children, }: LayoutProps) { - const { path, slug, date, title, tags, logo, website } = content; + const { path, slug, date, title, tags, logo, website, category } = content; const firstImage = content.images?.[0]; const tintColor = hashStringToColor(title); const fallbackImage = '/static/images/logo.png'; + const allProducts = allCoreContent(allBlogs); + + const getRecommendedProducts = () => { + const sameCategoryProducts = allProducts.filter( + (product) => product.category === category && product.slug !== slug, + ); + const otherProducts = allProducts.filter( + (product) => product.category !== category && product.slug !== slug, + ); + + const recommendations = [ + ...sameCategoryProducts.slice(0, 5), + ...otherProducts.slice(0, 10 - sameCategoryProducts.length), + ]; + + return recommendations; + }; + + const recommendedProducts = getRecommendedProducts(); + return (
@@ -154,30 +176,20 @@ export default function PostLayout({
)} - {(next || prev) && ( -
- {prev && prev.path && ( -
-

- Previous Deal -

-
- {prev.title} -
-
- )} - {next && next.path && ( -
-

- Next Deal -

-
- {next.title} -
+ +
+

+ Recommended Products +

+
+ {recommendedProducts.map((product) => ( +
+ {' '} + {/* Use PostItem */}
- )} + ))}
- )} +