import { allBlogs } from "@/utlis/constant.utils"; import React from "react"; import Image from "next/image"; import Link from "next/link"; import AnimatedText from "@/components/common/AnimatedText"; function truncateWords(text, wordLimit) { const words = text.split(" "); return words.length > wordLimit ? words.slice(0, wordLimit).join(" ") + "..." : text; } export default function Blogs() { const [leftBlog, ...rightBlogs] = allBlogs.slice(0, 3); return (
img
img
Blog & News

{leftBlog && (
  • {leftBlog.author.name}
  • {leftBlog.category}

{truncateWords(leftBlog.title.replace(/<[^>]+>/g, ""), 12) .split("
") .map((line, index) => ( {line}
))}

{truncateWords(leftBlog.description.replace(/<[^>]+>/g, ""), 25)}

)}
{rightBlogs.map((item) => (
  • {item.author.name}
  • {item.category}

{truncateWords(item.title.replace(/<[^>]+>/g, ""), 8)}

{truncateWords(item.description.replace(/<[^>]+>/g, ""), 10)}

Read More
img
))}
); }