blog page recent blog filter update
This commit is contained in:
parent
b62640738b
commit
f43261be0e
@ -9,6 +9,28 @@ export const metadata = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default function Blog() {
|
export default function Blog() {
|
||||||
|
// Sort blogs by date in descending order (newest first)
|
||||||
|
const sortedBlogs = [...Blogs].sort((a, b) => {
|
||||||
|
// Parse dates in format "DD MMM YYYY" (e.g., "15 Sep 2025")
|
||||||
|
const parseDate = (dateStr) => {
|
||||||
|
const months = {
|
||||||
|
'Jan': 0, 'Feb': 1, 'Mar': 2, 'Apr': 3, 'May': 4, 'Jun': 5,
|
||||||
|
'Jul': 6, 'Aug': 7, 'Sep': 8, 'Oct': 9, 'Nov': 10, 'Dec': 11
|
||||||
|
};
|
||||||
|
const parts = dateStr.split(' ');
|
||||||
|
const day = parseInt(parts[0]);
|
||||||
|
const month = months[parts[1]];
|
||||||
|
const year = parseInt(parts[2]);
|
||||||
|
return new Date(year, month, day);
|
||||||
|
};
|
||||||
|
|
||||||
|
const dateA = parseDate(a.date);
|
||||||
|
const dateB = parseDate(b.date);
|
||||||
|
|
||||||
|
// Sort in descending order (newest first)
|
||||||
|
return dateB - dateA;
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Layout headerStyle={1} footerStyle={1} breadcrumbTitle="Blog" bannerImage="/assets/images/blog/blog-banner.webp">
|
<Layout headerStyle={1} footerStyle={1} breadcrumbTitle="Blog" bannerImage="/assets/images/blog/blog-banner.webp">
|
||||||
<section className="news-section sec-pad">
|
<section className="news-section sec-pad">
|
||||||
@ -18,7 +40,7 @@ export default function Blog() {
|
|||||||
<h2>Stay Updated with <br />Our Recent Blog Posts</h2>
|
<h2>Stay Updated with <br />Our Recent Blog Posts</h2>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<BlogList blogs={Blogs} />
|
<BlogList blogs={sortedBlogs} />
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user