forked from leerob/site
-
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.
- Loading branch information
Showing
32 changed files
with
899 additions
and
457 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import Link from 'next/link'; | ||
import useSWR from 'swr'; | ||
import cn from 'classnames'; | ||
|
||
import fetcher from 'lib/fetcher'; | ||
import { Views } from 'lib/types'; | ||
|
||
export default function BlogPostCard({ title, slug, gradient }) { | ||
const { data } = useSWR<Views>(`/api/views/${slug}`, fetcher); | ||
const views = data?.total; | ||
|
||
return ( | ||
<Link href={`/blog/${slug}`}> | ||
<a | ||
className={cn( | ||
'transform hover:scale-[1.01] transition-all', | ||
'rounded-xl w-full md:w-1/3 bg-gradient-to-r p-1', | ||
gradient | ||
)} | ||
> | ||
<div className="flex flex-col justify-between h-full bg-white dark:bg-gray-900 rounded-lg p-4"> | ||
<div className="flex flex-col md:flex-row justify-between"> | ||
<h4 className="text-lg md:text-lg font-medium mb-6 sm:mb-10 w-full text-gray-900 dark:text-gray-100 tracking-tight"> | ||
{title} | ||
</h4> | ||
</div> | ||
<div className="flex items-center text-gray-800 dark:text-gray-200"> | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
className="h-6 w-6" | ||
fill="none" | ||
viewBox="0 0 24 24" | ||
stroke="currentColor" | ||
> | ||
<path | ||
strokeLinecap="round" | ||
strokeLinejoin="round" | ||
strokeWidth={2} | ||
d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" | ||
/> | ||
<path | ||
strokeLinecap="round" | ||
strokeLinejoin="round" | ||
strokeWidth={2} | ||
d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z" | ||
/> | ||
</svg> | ||
<span className="ml-2 align-baseline"> | ||
{views ? new Number(views).toLocaleString() : '–––'} | ||
</span> | ||
</div> | ||
</div> | ||
</a> | ||
</Link> | ||
); | ||
} |
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
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.