From eebe7972e0b05094aaaacf96ec7fc3238c6967ba Mon Sep 17 00:00:00 2001 From: Marc Mintel Date: Fri, 27 Feb 2026 18:34:06 +0100 Subject: [PATCH] style: update recent posts layout to 4 columns matching product categories and fix payload cms text typography styling --- components/PayloadRichText.tsx | 86 ++++++++++++++++- components/home/RecentPosts.tsx | 160 ++++++++++++++------------------ 2 files changed, 152 insertions(+), 94 deletions(-) diff --git a/components/PayloadRichText.tsx b/components/PayloadRichText.tsx index ce7f5d34..a8c471ef 100644 --- a/components/PayloadRichText.tsx +++ b/components/PayloadRichText.tsx @@ -123,11 +123,87 @@ const jsxConverters: JSXConverters = { return {text}; }, // Use div instead of p for paragraphs to allow nested block elements (like the lists above) - paragraph: ({ children }: any) =>
{children}
, - // Scale headings to prevent multiple H1s (H1 -> H2, etc) - h1: ({ children }: any) =>

{children}

, - h2: ({ children }: any) =>

{children}

, - h3: ({ children }: any) =>

{children}

, + paragraph: ({ children }: any) => ( +
{children}
+ ), + // Scale headings to prevent multiple H1s (H1 -> H2, etc) and style natively + heading: ({ node, children }: any) => { + const tag = node?.tag; + if (tag === 'h1') + return ( +

{children}

+ ); + if (tag === 'h2') + return ( +

{children}

+ ); + if (tag === 'h3') + return ( +

{children}

+ ); + if (tag === 'h4') + return ( +
{children}
+ ); + if (tag === 'h5') + return ( +
{children}
+ ); + return
{children}
; + }, + list: ({ node, children }: any) => { + if (node?.listType === 'number') { + return ( +
    + {children} +
+ ); + } + if (node?.listType === 'check') { + return ; + } + return ( + + ); + }, + listitem: ({ node, children }: any) => { + if (node?.checked != null) { + return ( +
  • + + {children} +
  • + ); + } + return
  • {children}
  • ; + }, + quote: ({ children }: any) => ( +
    + {children} +
    + ), + link: ({ node, children }: any) => { + // Handling Payload CMS link nodes + const href = node?.fields?.url || node?.url || '#'; + const newTab = node?.fields?.newTab || node?.newTab; + return ( + + {children} + + ); + }, blocks: { // ... preserved existing blocks ... diff --git a/components/home/RecentPosts.tsx b/components/home/RecentPosts.tsx index 578ae707..0b66ef60 100644 --- a/components/home/RecentPosts.tsx +++ b/components/home/RecentPosts.tsx @@ -3,7 +3,7 @@ import Image from 'next/image'; import Link from 'next/link'; import { getAllPosts } from '@/lib/blog'; import { getTranslations } from 'next-intl/server'; -import { Section, Container, Heading, Card, Badge } from '../../components/ui'; +import { Section, Container, Heading } from '../../components/ui'; interface RecentPostsProps { locale: string; @@ -13,7 +13,7 @@ interface RecentPostsProps { export default async function RecentPosts({ locale, data }: RecentPostsProps) { const t = await getTranslations('Blog'); const posts = await getAllPosts(locale); - const recentPosts = posts.slice(0, 3); + const recentPosts = posts.slice(0, 4); if (recentPosts.length === 0) return null; @@ -21,9 +21,9 @@ export default async function RecentPosts({ locale, data }: RecentPostsProps) { const subtitle = data?.subtitle || t('latestNews'); return ( -
    - -
    +
    + +
    {title} @@ -35,91 +35,73 @@ export default async function RecentPosts({ locale, data }: RecentPostsProps) {
    - -
      - {recentPosts.map((post, idx) => ( -
    • - - - {post.frontmatter.featuredImage && ( - <> - {post.frontmatter.title} -
      - - )} - -
      -
      - {post.frontmatter.category && ( - - {post.frontmatter.category} - - )} - {(new Date(post.frontmatter.date) > new Date() || - post.frontmatter.public === false) && ( - - Draft Preview - - )} -
      - -
      - -
      - -

      - {post.frontmatter.title} -

      - -
      - - {t('readMore')} - -
      - - - -
      -
      -
      - - -
    • - ))} -
    + +
      + {recentPosts.map((post, idx) => ( +
    • + + {post.frontmatter.featuredImage && ( + <> + {post.frontmatter.title} +
      + + )} + +
      +
      +
      + {post.frontmatter.category && ( + + {post.frontmatter.category} + + )} + + {(new Date(post.frontmatter.date) > new Date() || + post.frontmatter.public === false) && ( + + Draft Preview + + )} +
      +

      + {post.frontmatter.title} +

      +
      +
      + {t('readMore')}{' '} + + → + +
      +
      + +
    • + ))} +
    ); }