Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions new-branding/src/components/blog/ArticleCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,13 @@ import Image from "next/image";
import "./index.scss";
import { Post } from "@/lib/axios/types";
import { formatPostDate } from "@/lib/date";
import { getMediaUrl } from "@/lib/common";

export const ArticleCard: React.FC<Post> = ({ categoryLabel, source, title, date, thumbnail, sourceUrl, colorTheme }) => {
const thumbnailImage = getMediaUrl(thumbnail?.url);

return (
<article className="article-card" data-color-theme={colorTheme ?? "warm-orange"}>
<div className="article-card__thumbnail">
{thumbnailImage ? (
<Image src={thumbnailImage} alt={title} className="article-card__image" width={600} height={450} />
{thumbnail?.url ? (
<Image src={thumbnail.url} alt={title} className="article-card__image" width={600} height={450} />
) : (
<div className="article-card__placeholder">
<div className="article-card__placeholder__circle" />
Expand Down
4 changes: 1 addition & 3 deletions new-branding/src/components/blog/Info/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,15 @@ import { SkeletonWrapper } from "@/components/common/SkeletonWrapper";
import "react-loading-skeleton/dist/skeleton.css";
import { FeaturedNews } from "@/lib/axios/types";
import { formatPostDate } from "@/lib/date";
import { getMediaUrl } from "@/lib/common";
import { useIsMobile } from "@/lib/hooks/useIsMobile";

export const BlogInfo: React.FC<{ isLoading: boolean; featured: FeaturedNews | undefined }> = ({ isLoading, featured }) => {
const isMobile = useIsMobile();
const thumbnailImage = getMediaUrl(featured?.thumbnail?.url);

return (
<article className="blog-info">
<div className="blog-info__image-wrapper">
{thumbnailImage && <Image className="blog-info__image" src={thumbnailImage} fill sizes="(max-width: 1100px) 100vw, calc(100vw - 446px)" alt="preview image" />}
{featured?.thumbnail?.url && <Image className="blog-info__image" src={featured.thumbnail.url} fill sizes="(max-width: 1100px) 100vw, calc(100vw - 446px)" alt="preview image" />}
</div>
<div className="blog-info__content">
<div className="blog-info__body">
Expand Down
6 changes: 0 additions & 6 deletions new-branding/src/lib/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,4 @@ export const copyToClipboard = async (text: string) => {

export const wordpressUrl = new URL(process.env.CMS_API_URL || "http://localhost:3000");

export const getMediaUrl = (url: string | null | undefined): string | null => {
if (!url) return null;

return `${process.env.NEXT_PUBLIC_CMS_API_URL?.replace(/\/$/, "")}${url}`;
};

export const formatLabel = (count: number, label: string) => (label?.trim() ? `${count} ${label.trim()}` : "");
Loading