Skip to content

Commit

Permalink
fix: add blog item placeholder, add key to blog item skeleton, add bu…
Browse files Browse the repository at this point in the history
…n lockfile
  • Loading branch information
ryantanrk committed Apr 3, 2024
1 parent ab0823d commit b1a7a4c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
Binary file added bun.lockb
Binary file not shown.
Binary file added public/asset/blogplaceholder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion src/components/BlogItem/BlogItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ interface BlogItemProps {
}

const BlogItem = ({ title, href, date, imageUrl, style }: BlogItemProps) => {
const placeholderUrl = "/asset/blogplaceholder.png";
return (
<div className="blog-item" style={style}>
<a target="_blank" rel="noreferrer noopener" href={href}>
<img className="blog-item__image" src={imageUrl} alt={title} />
<img className="blog-item__image" src={imageUrl || placeholderUrl} alt={title} />
<div className="blog-item__row">
<div className="blog-item__title">{title}</div>
<div className="blog-item__date">
Expand Down
6 changes: 5 additions & 1 deletion src/pages/home/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ const Home = () => {
}, []);

// blog display will display skeleton of element before load
let blogDisplay: JSX.Element[] = Array(3).fill(<BlogItemSkeleton />);
let blogDisplay: JSX.Element[] = [
<BlogItemSkeleton key="skeleton-1" />,
<BlogItemSkeleton key="skeleton-2" />,
<BlogItemSkeleton key="skeleton-3" />
];

if (isLoaded) {
if (error != null) {
Expand Down

0 comments on commit b1a7a4c

Please sign in to comment.