blog page recent blog filter update
This commit is contained in:
parent
bfe28f01ba
commit
d32dadc8b8
@ -40,7 +40,7 @@ export default function Blog() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="row clearfix">
|
<div className="row clearfix">
|
||||||
{Blogs.map((blog) => (
|
{Blogs.sort((a, b) => new Date(b.date) - new Date(a.date)).map((blog) => (
|
||||||
<div
|
<div
|
||||||
key={blog.id}
|
key={blog.id}
|
||||||
className="col-lg-4 col-md-6 col-sm-12 mb-4"
|
className="col-lg-4 col-md-6 col-sm-12 mb-4"
|
||||||
|
|||||||
@ -9,55 +9,55 @@ const truncateWords = (text, limit) => {
|
|||||||
|
|
||||||
const stripHtml = (html) => {
|
const stripHtml = (html) => {
|
||||||
if (!html) return "";
|
if (!html) return "";
|
||||||
return html.replace(/<[^>]*>/g, "");
|
return html.replace(/<[^>]*>/g, "");
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function Blog() {
|
export default function Blog() {
|
||||||
return (
|
return (
|
||||||
<div className="sidebar-page-container">
|
<div className="sidebar-page-container">
|
||||||
<div className="auto-container">
|
<div className="auto-container">
|
||||||
<div className="row clearfix">
|
<div className="row clearfix">
|
||||||
{Blogs.slice(0, 3).map((blog) => (
|
{Blogs.sort((a, b) => new Date(b.date) - new Date(a.date)).slice(0, 3).map((blog) => (
|
||||||
<div
|
<div
|
||||||
key={blog.id}
|
key={blog.id}
|
||||||
className="col-lg-4 col-md-6 col-sm-12 mb-4"
|
className="col-lg-4 col-md-6 col-sm-12 mb-4"
|
||||||
>
|
>
|
||||||
<div className="blog-card rounded shadow-sm overflow-hidden">
|
<div className="blog-card rounded shadow-sm overflow-hidden">
|
||||||
{/* Blog Image */}
|
{/* Blog Image */}
|
||||||
<div className="blog-image">
|
<div className="blog-image">
|
||||||
<img
|
<img
|
||||||
src={blog.imageDetail}
|
src={blog.imageDetail}
|
||||||
alt={blog.title}
|
alt={blog.title}
|
||||||
className="img-fluid w-100"
|
className="img-fluid w-100"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Blog Title */}
|
{/* Blog Title */}
|
||||||
<div className="blog-content p-3">
|
<div className="blog-content p-3">
|
||||||
<h3 className="mb-2 text-lg font-semibold blog-title-hover">
|
<h3 className="mb-2 text-lg font-semibold blog-title-hover">
|
||||||
<Link href={`/blog/${blog.slug}`} className="blog-title-link">
|
<Link href={`/blog/${blog.slug}`} className="blog-title-link">
|
||||||
{truncateWords(stripHtml(blog.title), 6)}
|
{truncateWords(stripHtml(blog.title), 6)}
|
||||||
</Link>
|
|
||||||
</h3>
|
|
||||||
|
|
||||||
{/* Blog Excerpt */}
|
|
||||||
<p className="text-gray-700 mb-3">
|
|
||||||
{truncateWords(stripHtml(blog.para), 28)}
|
|
||||||
</p>
|
|
||||||
|
|
||||||
{/* Read More Button */}
|
|
||||||
<Link
|
|
||||||
href={`/blog/${blog.slug}`}
|
|
||||||
className="font-medium blog-title-link"
|
|
||||||
>
|
|
||||||
Read More
|
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</h3>
|
||||||
|
|
||||||
|
{/* Blog Excerpt */}
|
||||||
|
<p className="text-gray-700 mb-3">
|
||||||
|
{truncateWords(stripHtml(blog.para), 28)}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
{/* Read More Button */}
|
||||||
|
<Link
|
||||||
|
href={`/blog/${blog.slug}`}
|
||||||
|
className="font-medium blog-title-link"
|
||||||
|
>
|
||||||
|
Read More
|
||||||
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
))}
|
</div>
|
||||||
</div>
|
))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user