Skip to content

Commit

Permalink
amend latest blogs
Browse files Browse the repository at this point in the history
  • Loading branch information
seanjermey committed Oct 17, 2023
1 parent 8a7ea81 commit 8d17353
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 21 deletions.
26 changes: 10 additions & 16 deletions src/components/LatestBlogs/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,26 @@ import classes from "./styles.module.scss";
import ChevronRight from "@/assets/ChevronRight.svg";
import { LatestBlogCard, Title } from "@/ui";
import { getRoute } from "@/getters/getRoute";
import { blog_helper } from "@/helpers/blog_helper";
import { trimText } from "@/functions/trimText";

export default function LatestBlogs({ className, title, button }) {
const items = blog_helper.fetch({ limit: 3 });

export default function LatestBlogs({ className, title, items, button }) {
return (
<div className={clsx(className, classes.blogs)}>
<Container className="mw-xxl">
<Title title={title} />
<Row className="mb-4">
{items.map(({ title, description, img, published_at, tags }, k) => (
{items.map(({ title, body, image, publish_date, url_slug }, k) => (
<Col key={k} xs={12} md={4}>
<LatestBlogCard
className="h-100"
title={title}
description={description}
img={img}
published_at={published_at}
tags={tags}
description={trimText(body)}
img={image}
published_at={publish_date}
href={getRoute("blogPost", { url_slug })}
/>
</Col>
))}
Expand All @@ -41,7 +45,6 @@ export default function LatestBlogs({ className, title, items, button }) {
LatestBlogs.defaultProps = {
className: "py-5",
title: null,
items: [],
button: {
label: "View more blogs",
href: getRoute("blog"),
Expand All @@ -51,15 +54,6 @@ LatestBlogs.defaultProps = {
LatestBlogs.propTypes = {
className: PropTypes.string,
title: PropTypes.string,
items: PropTypes.arrayOf(
PropTypes.shape({
className: PropTypes.string,
title: PropTypes.string,
description: PropTypes.string,
img: PropTypes.string,
published_at: PropTypes.string,
})
),
button: PropTypes.shape({
label: PropTypes.string,
href: PropTypes.string,
Expand Down
2 changes: 0 additions & 2 deletions src/pages/career-advice/index.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Content } from "@/ui";
import { getRoute } from "@/getters/getRoute";
import { generateDescription } from "@/faker/generateDescription";
import { generateArrayOf } from "@/faker/generateArrayOf";
import { generatePromoItem } from "@/faker/generatePromoItem";
import { generateNarrativePanel } from "@/faker/generateNarrativePanel";
import { generateArticle } from "@/faker/generateArticle";
import { career_advice_helper } from "@/helpers/career_advice_helper";
Expand Down Expand Up @@ -66,7 +65,6 @@ export async function getStaticProps() {
component: "LatestBlogs",
props: {
title: { path: "page.careerAdvice.component.LatestBlogs.title", placeholder: "Latest Blogs" },
items: generateArrayOf(generateArticle, { count: 3 }),
},
},
],
Expand Down
6 changes: 3 additions & 3 deletions src/ui/LatestBlogCard/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import clsx from "classnames";
import { format } from "date-fns";
import { trimText } from "@/functions/trimText";

export default function LatestBlogCard({ className, title, description, img, published_at }) {
export default function LatestBlogCard({ className, title, description, img, published_at, href }) {
return (
<article className={clsx(className, classes.card)}>
<a href={href} className={clsx(className, classes.card)}>
<figure className="ratio ratio-1x1">
<SourceFlowImage src={img} size="373x220" alt={title} />
</figure>
Expand All @@ -16,7 +16,7 @@ export default function LatestBlogCard({ className, title, description, img, pub
<time>{format(new Date(published_at), "dd/MM/yyyy")}</time>
<p>{trimText(description, 180)}</p>
</div>
</article>
</a>
);
}

Expand Down
2 changes: 2 additions & 0 deletions src/ui/LatestBlogCard/styles.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
overflow: hidden;
display: flex;
flex-direction: column;
text-decoration: none;
color: inherit;
@include card-hover-rise;

figure {
Expand Down

0 comments on commit 8d17353

Please sign in to comment.