abc abc
import React from ‘react’;
import { Link } from ‘react-router-dom’;
import PropTypes from ‘prop-types’;
const FeaturedBlogCard = ({ post, getCategoryName }) => {
if (!post) {
return (
<div className=”block bg-white rounded-xl overflow-hidden border border-[#022150]”>
<div className=”md:flex”>
<div className=”md:w-1/2 h-64 md:h-80 bg-gray-200″></div>
<div className=”md:w-1/2 p-6″>
<div className=”h-4 bg-gray-300 rounded mb-2 w-1/3″></div>
<div className=”h-6 bg-gray-300 rounded mb-4 w-3/4″></div>
<div className=”h-4 bg-gray-200 rounded mb-2 w-full”></div>
<div className=”h-4 bg-gray-200 rounded mb-4 w-2/3″></div>
<div className=”h-4 bg-gray-300 rounded w-1/4″></div>
</div>
</div>
</div>
);
}
const featuredImage =
post._embedded?.[‘wp:featuredmedia’]?.[0]?.source_url ||
‘/assets/placeholder.png’;
const author =
post._embedded?.author?.[0]?.name ||
‘WrittenlyHub’;
const date = post.date
? new Date(post.date).toLocaleDateString(‘en-US’, {
year: ‘numeric’,
month: ‘short’,
day: ‘numeric’,
})
: ”;
const categoryId = post.wh_category?.[0];
const categoryName = categoryId && getCategoryName ? getCategoryName(categoryId) : ”;
const title = post.title?.rendered || ‘Untitled Post’;
const excerpt = post.excerpt?.rendered || ”;
const slug = post.slug || ”;
const cleanExcerpt = excerpt.replace(/<[^>]*>/g, ”).substring(0, 200) + ‘…’;
return (
<Link
to={`/blog/${slug}`}
className=”block bg-white rounded-xl overflow-hidden border border-[#022150]”
>
<div className=”md:flex”>
<div className=”md:w-1/2″>
<img
src={featuredImage}
alt={title}
className=”w-full h-64 md:h-80 object-cover”
onError={(e) => {
e.target.src = ‘/assets/placeholder.png’;
}}
/>
</div>
<div className=”md:w-1/2 p-6 flex flex-col justify-center”>
{categoryName && (
<span className=”inline-block px-3 py-1 text-xs font-semibold text-orange-500 bg-transparent rounded-full mb-3 w-fit”>
{categoryName}
</span>
)}
<h2
className=”text-2xl md:text-3xl font-bold mb-4 text-[#022150] line-clamp-2″
dangerouslySetInnerHTML={{ __html: title }}
/>
{cleanExcerpt && (
<p className=”text-gray-600 mb-4 line-clamp-3 leading-relaxed”>
{cleanExcerpt}
</p>
)}
<div className=”flex items-center justify-between”>
<div className=”flex items-center text-sm text-gray-500″>
{date && <span>{date}</span>}
{date && author && <span className=”mx-2″>•</span>}
{author && <span>By {author}</span>}
</div>
<span className=”text-orange-500 font-semibold text-sm border border-orange-500 rounded-full px-3 py-1″>
Read More
</span>
</div>
</div>
</div>
</Link>
);
};
FeaturedBlogCard.propTypes = {
post: PropTypes.shape({
id: PropTypes.number,
slug: PropTypes.string,
date: PropTypes.string,
title: PropTypes.shape({
rendered: PropTypes.string
}),
excerpt: PropTypes.shape({
rendered: PropTypes.string
}),
wh_category: PropTypes.array,
_embedded: PropTypes.shape({
author: PropTypes.array,
‘wp:featuredmedia’: PropTypes.array
})
}),
getCategoryName: PropTypes.func
};
export default FeaturedBlogCard;
Creating Engaging Presentations Effortlessly with AI
16 Jan 2024 | By Team WHThe ability to communicate ideas effectively is crucial, and presentations play a pivotal role in this arena. The emergence of AI presentation makers marks a significant evolution in how we approach this task. These innovative tools are reshaping the process of creating presentations, making it not only more efficient but also more accessible to a… Continue reading Creating Engaging Presentations Effortlessly with AI
Are Press Releases Still Good for SEO?
11 Jul 2023 | By Team WHHistorically, press releases have been crucial in generating brand awareness and creating buzz around newly launched products or services. Several marketers in the past have employed this tactic and combined it with SEO elements to achieve higher organic rankings and boost traffic. Unfortunately, this strategy took a backseat when Google announced that links present in… Continue reading Are Press Releases Still Good for SEO?
AI vs Search Engines: What’s the Future of AI Content on SERPs?
07 May 2023 | By Team WHThe debate about AI-generated content is prevalent as ever. While there have been claims that AI does not have the emotional intelligence to pull off personalised and thought-provoking content, a surprising 12% of businesses are using AI for content creation. At the same time, popular search engines like Google have not explicitly mentioned being against AI-generated content.… Continue reading AI vs Search Engines: What’s the Future of AI Content on SERPs?