Skip to content

Commit

Permalink
update blog page
Browse files Browse the repository at this point in the history
  • Loading branch information
seanjermey committed Oct 13, 2023
1 parent eb6fe65 commit a47202c
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 16 deletions.
16 changes: 13 additions & 3 deletions src/components/BlogFeed/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,25 @@ import PropTypes from "prop-types";
import clsx from "classnames";
import { Col, Container, Row } from "react-bootstrap";
import { BlogFeedCard } from "@/ui";
import { blogHelper } from "@/helpers/blogHelper";
import { getRoute } from "@/getters/getRoute";

export default function BlogArticleFeed({ className }) {
const items = blogHelper.fetch();

export default function BlogArticleFeed({ className, items }) {
return (
<div className={clsx(className)}>
<Container className="mw-xl">
<Row>
{items.map(({ title, description, img, published_at, href }, k) => (
{items.map(({ title, image, publish_date, url_slug }, k) => (
<Col key={k} xs={12} md={4} className="mb-4">
<BlogFeedCard className="h-100" title={title} img={img} published_at={published_at} href={href} />
<BlogFeedCard
className="h-100"
title={title}
img={image}
published_at={publish_date}
href={getRoute("blogPost", { url_slug })}
/>
</Col>
))}
</Row>
Expand Down
4 changes: 0 additions & 4 deletions src/getters/getArticles.js

This file was deleted.

4 changes: 4 additions & 0 deletions src/helpers/blogHelper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import data from "../../.sourceflow/blog.json";
import CollectionHelper from "@/helpers/CollectionHelper";

export const blogHelper = new CollectionHelper(data);
5 changes: 1 addition & 4 deletions src/pages/blog/index.page.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Content } from "@/ui";
import { getArticles } from "@/getters/getArticles";
import { getRoute } from "@/getters/getRoute";

export default function BlogsPage({ content }) {
Expand Down Expand Up @@ -39,9 +38,7 @@ export async function getStaticProps() {
},
{
component: "BlogFeed",
props: {
items: getArticles(),
},
props: {},
},
],
},
Expand Down
16 changes: 11 additions & 5 deletions src/ui/BlogFeedCard/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@ import classes from "./styles.module.scss";
import PropTypes from "prop-types";
import SourceFlowImage from "@sourceflow-uk/sourceflowimage";
import { Time } from "@/ui";
import { getAsset } from "@/getters/getAsset";

export default function BlogFeedCard({ className, title, published_at, img, href }) {
return (
<a className={clsx(className, classes.card)} href={href}>
<SourceFlowImage className={classes.card__img} src={img} size="300x300" alt={title} />
<SourceFlowImage
className={classes.card__img}
src={img ?? getAsset("_theme.blog.card.img.fallback")}
size="300x300"
alt={title}
/>
<div className={classes.card__body}>
<h4>{title}</h4>
<Time date={published_at} icon={false} className="text-white" />
Expand All @@ -18,10 +24,10 @@ export default function BlogFeedCard({ className, title, published_at, img, href

BlogFeedCard.defaultProps = {
className: "",
title: "",
description: "",
img: "",
href: "#",
title: null,
published_at: null,
img: null,
href: null,
};

BlogFeedCard.propTypes = {
Expand Down
4 changes: 4 additions & 0 deletions src/ui/Time/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import PropTypes from "prop-types";
import { Detail } from "@/ui";

export default function Time({ className, icon, date, format }) {
if (!date) {
return null;
}

return (
<Detail
className={className}
Expand Down

0 comments on commit a47202c

Please sign in to comment.