Skip to content

Commit 4dac230

Browse files
committed
refactor(blog): updated hero-section, blog-related-post section & cta section as per design
- updated changelog.md
1 parent 478e45d commit 4dac230

File tree

8 files changed

+12
-24
lines changed

8 files changed

+12
-24
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
All notable changes to this template will be documented in this file
66

7-
## v1.0.0 (2026-01-20)
7+
## v1.0.0 (2026-01-23)
88

99
### Added
1010

src/components/blocks/blog-component/blog-component.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export type BlogPost = {
2626
description: string
2727
imageUrl: string
2828
imageAlt: string
29-
pubDate: Date
29+
pubDate: string
3030
author: string
3131
avatarUrl: string
3232
category: string
@@ -67,13 +67,7 @@ const BlogGrid = ({ posts, onCategoryClick }: { posts: BlogPost[]; onCategoryCli
6767
<div className='flex items-center justify-between gap-1.5'>
6868
<div className='text-muted-foreground flex items-center gap-1.5'>
6969
<CalendarDaysIcon className='size-6' />
70-
<p className='font-medium'>
71-
{new Date(post.pubDate).toLocaleDateString('en-US', {
72-
year: 'numeric',
73-
month: 'long',
74-
day: 'numeric'
75-
})}
76-
</p>
70+
<p className='font-medium'>{post.pubDate}</p>
7771
</div>
7872
<Badge
7973
className='bg-primary/10 text-primary badge rounded-full border-0 text-sm'

src/components/blocks/blog-related-post/blog-related-post.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ const Blog = ({ relatedPosts }: { relatedPosts: BlogPost[] }) => {
5353
<div className='flex items-center justify-between gap-1.5'>
5454
<div className='text-muted-foreground flex items-center gap-1.5'>
5555
<CalendarDaysIcon className='size-6' />
56-
<span>{post.pubDate.toLocaleDateString()}</span>
56+
<span>{post.pubDate}</span>
5757
</div>
5858
<Badge
5959
className='bg-primary/10 text-primary border-0 text-sm'

src/components/blocks/hero-section/hero-section.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,7 @@ const HeroSection = ({ blogData }: { blogData: BlogPost[] }) => {
5050
<div className='flex items-center gap-1.5 py-1'>
5151
<div className='text-muted-foreground flex grow items-center gap-1.5'>
5252
<CalendarDaysIcon className='size-6' />
53-
<p className='font-medium'>
54-
{new Date(item.pubDate).toLocaleDateString('en-US', {
55-
year: 'numeric',
56-
month: 'long',
57-
day: 'numeric'
58-
})}
59-
</p>
53+
<p className='font-medium'>{item.pubDate}</p>
6054
</div>
6155
<Badge
6256
className='bg-primary/10 text-primary cursor-pointer border-0 text-sm'

src/content.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const blog = defineCollection({
1010
description: z.string(),
1111
imageUrl: z.string().optional(),
1212
imageAlt: z.string().optional(),
13-
pubDate: z.coerce.date(),
13+
pubDate: z.string(),
1414
author: z.string().default('shadcn Studio'),
1515
avatarUrl: z.string().optional(),
1616
category: z.string().default('General'),

src/pages/blog/[slug].astro

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
} from '@/components/ui/breadcrumb'
1414
import DynamicToc from '@/components/astro/DynamicToc.astro'
1515
import { AuthorMetadata } from '@/components/AuthorAvatar'
16-
import { getRelatedPosts, getPostNavigation, calculateReadTime, formatDate } from '@/utils/blog'
16+
import { getRelatedPosts, getPostNavigation, calculateReadTime } from '@/utils/blog'
1717
import { ChevronLeftIcon, ChevronRightIcon } from 'lucide-react'
1818
1919
import { mdxComponents } from '@/components/mdx-components'
@@ -66,7 +66,7 @@ const schema = {
6666
headline: entry.data.title,
6767
description: entry.data.description,
6868
image: entry.data.imageUrl,
69-
datePublished: entry.data.pubDate.toISOString(),
69+
datePublished: entry.data.pubDate,
7070
author: {
7171
'@type': 'Person',
7272
name: entry.data.author
@@ -79,7 +79,7 @@ const schema = {
7979
description={entry.data.description}
8080
image={entry.data.imageUrl}
8181
type='article'
82-
publishedTime={entry.data.pubDate.toISOString()}
82+
publishedTime={entry.data.pubDate}
8383
author={entry.data.author}
8484
schema={schema}
8585
>
@@ -133,7 +133,7 @@ const schema = {
133133
</div>
134134
<div class='flex flex-col gap-1.5'>
135135
<span class='text-muted-foreground text-sm'>Posted on</span>
136-
<span class='text-foreground text-sm font-medium'>{formatDate(entry.data.pubDate)}</span>
136+
<span class='text-foreground text-sm font-medium'>{entry.data.pubDate}</span>
137137
</div>
138138
</div>
139139
</div>

src/pages/index.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const allBlogPosts = publishedPosts
2626
readTime: post.data.readTime || 5,
2727
featured: post.data.featured || false
2828
}))
29-
.sort((a, b) => b.pubDate.getTime() - a.pubDate.getTime())
29+
.sort((a, b) => b.pubDate.localeCompare(a.pubDate))
3030
3131
// Page-specific SEO configuration
3232
const pageTitle = ''

src/utils/blog.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export function getPostNavigation(
4545
currentSlug: string
4646
): { previous: CollectionEntry<'blog'> | null; next: CollectionEntry<'blog'> | null } {
4747
// Sort posts by pubDate (newest first)
48-
const sortedPosts = [...posts].sort((a, b) => b.data.pubDate.valueOf() - a.data.pubDate.valueOf())
48+
const sortedPosts = [...posts].sort((a, b) => b.data.pubDate.localeCompare(a.data.pubDate))
4949
const currentIndex = sortedPosts.findIndex(post => post.id === currentSlug)
5050

5151
if (currentIndex === -1) {

0 commit comments

Comments
 (0)