Skip to content

Commit

Permalink
chore: changing up var names
Browse files Browse the repository at this point in the history
  • Loading branch information
atepem committed Nov 29, 2024
1 parent e8e214c commit 45427a6
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion common-util/formatDate.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export const formatDate = (date) => {
const newDate = new Date(date);
const options = {
day: '2-digit',
month: 'long',
month: 'short',
year: '2-digit',
};
const formattedDate = newDate.toLocaleDateString('en-GB', options);
Expand Down
6 changes: 4 additions & 2 deletions common-util/useFetchApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ export const useFetchVideos = (limit = 1000) => {
const imageFilename = thumbnailUrl
? `${process.env.NEXT_PUBLIC_API_URL}${thumbnailUrl}`
: '';

const videoUploadedUrl = get(videoUploaded, 'data[0].attributes.url');
const video_url = videoUploadedUrl ? `${process.env.NEXT_PUBLIC_API_URL}${videoUploadedUrl}` : '';
const video_url = videoUploadedUrl
? `${process.env.NEXT_PUBLIC_API_URL}${videoUploadedUrl}`
: '';

return {
id,
Expand Down
14 changes: 9 additions & 5 deletions components/Content/Article.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,27 @@ const Article = ({ article, href, showReadTime, showDate }) => {
return data?.attributes?.formats?.large;
}, [article]);

const { title, datePublished, readTime } = article.attributes;
const {
title,
datePublished: unFormattedDatePublished,
readTime,
} = article.attributes;
const { url, width, height } = image || {};
const formattedDate = formatDate(datePublished);
const datePublished = formatDate(unFormattedDatePublished);

const moreInfo = useMemo(() => {
const moreInfoArray = [];

if (showDate && formattedDate) {
moreInfoArray.push(formattedDate);
if (showDate && datePublished) {
moreInfoArray.push(datePublished);
}

if (showReadTime && readTime) {
moreInfoArray.push(`${readTime} ${readTime === 1 ? 'MIN' : 'MINS'} READ`);
}

return moreInfoArray.join(' • ');
}, [showDate, formattedDate, showReadTime, readTime]);
}, [showDate, datePublished, showReadTime, readTime]);

return (
<Link href={href}>
Expand Down
8 changes: 4 additions & 4 deletions components/HomepageSection/Media.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ import Articles from 'components/Content/Articles';
import { Videos } from 'components/Content/Videos';
import SectionWrapper from 'components/Layout/SectionWrapper';

const limit = 3;
const LIMIT = 3;

const Media = () => {
const { videos, isLoading } = useFetchVideos(limit);
const { videos, isLoading } = useFetchVideos(LIMIT);

return (
<SectionWrapper
backgroundType="SUBTLE_GRADIENT"
customClasses="px-4 md:px-8 py-12 lg:p-24 border-b"
>
<div className="max-w-screen-xl mx-auto flex flex-col gap-10">
<Videos isLoading={isLoading} videos={videos} limit={limit} />
<Articles limit={limit} tagFilter="bonds" showSeeAll />
<Videos isLoading={isLoading} videos={videos} limit={LIMIT} />
<Articles limit={LIMIT} tagFilter="bonds" showSeeAll />
</div>
</SectionWrapper>
);
Expand Down

0 comments on commit 45427a6

Please sign in to comment.