-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(blog): reorder the default navigation items, introduce a 'Lates…
…t' component to display the most recent blog posts, 'New' flag to indicate recent posts (#545)
- Loading branch information
Showing
8 changed files
with
198 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import Link from 'next/link' | ||
|
||
import { Thumb } from '@duyet/components/Thumb' | ||
import type { Post } from '@duyet/interfaces' | ||
import { getAllPosts } from '@duyet/libs/getPost' | ||
import { cn } from '@duyet/libs/utils' | ||
|
||
export interface LatestProps { | ||
className?: string | ||
} | ||
|
||
async function getPosts(limit = 3) { | ||
return getAllPosts( | ||
[ | ||
'date', | ||
'slug', | ||
'title', | ||
'excerpt', | ||
'thumbnail', | ||
'category', | ||
'category_slug', | ||
], | ||
limit, | ||
) | ||
} | ||
|
||
export async function Latest({ className }: LatestProps) { | ||
const posts = await getPosts() | ||
|
||
if (!posts.length) { | ||
return null | ||
} | ||
|
||
return ( | ||
<div className={cn('flex justify-stretch gap-4', className)}> | ||
{posts.map((post: Post) => ( | ||
<Link | ||
as={post.slug} | ||
key={post.slug} | ||
className="text-md basis-1/3 overflow-hidden truncate" | ||
href="/[...slug]" | ||
> | ||
<article className="flex h-full flex-col items-center gap-2 overflow-hidden"> | ||
<span className="w-full truncate text-wrap font-bold text-muted-foreground"> | ||
{post.title} | ||
</span> | ||
{post.thumbnail ? ( | ||
<Thumb | ||
url={post.thumbnail} | ||
alt={post.title} | ||
className="h-auto w-auto object-cover transition-all hover:scale-105" | ||
unoptimized | ||
/> | ||
) : null} | ||
</article> | ||
</Link> | ||
))} | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
003ac3e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
blog – ./apps/blog
data-eng.vercel.app
blog-duyet-team.vercel.app
duyetblog.vercel.app
blog-git-master-duyet-team.vercel.app
duyet.vercel.app
blog.duyet.net
003ac3e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
insights – ./apps/insights
insights-git-master-duyet-team.vercel.app
insights-duyet-team.vercel.app
duyet-insights.vercel.app
insights.duyet.net
003ac3e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
cv – ./apps/cv
duyet-cv.vercel.app
cv-duyet-team.vercel.app
cv-git-master-duyet-team.vercel.app
cv.duyet.net