diff --git a/src/app/blog/[slug]/page.tsx b/src/app/blog/[slug]/page.tsx
index 29d1e85b..a8caed6b 100644
--- a/src/app/blog/[slug]/page.tsx
+++ b/src/app/blog/[slug]/page.tsx
@@ -1,4 +1,5 @@
import { Container } from '@/components/elements/container';
+import { RelatedPosts } from '@/components/sections/blog/related-posts';
import { SinglePostHero } from '@/components/sections/blog/single-post-hero';
import { getPostBySlug, getAllPostsMeta } from '@/lib/mdx';
@@ -21,7 +22,7 @@ export default async function BlogPostPage({ params }: BlogPostPageProps) {
return (
-
+
{/* {post.content}
*/}
);
diff --git a/src/components/modules/blog-card/blog-card.styles.ts b/src/components/modules/blog-card/blog-card.styles.ts
index 1e7925cb..0f5bd299 100644
--- a/src/components/modules/blog-card/blog-card.styles.ts
+++ b/src/components/modules/blog-card/blog-card.styles.ts
@@ -1,6 +1,7 @@
'use client';
-import { styled } from '@/styles';
+import { Image } from '@/components/elements/image';
+import { screens, styled } from '@/styles';
export const StyledBlogCardWrapper = styled.article`
display: flex;
@@ -19,15 +20,18 @@ export const StyledBlogCardWrapper = styled.article`
`;
export const StyledBlogCardFigure = styled.figure`
- height: 217px;
+ height: 174px;
border-radius: 8px;
overflow: hidden;
position: relative;
+
+ @media (min-width: ${screens.lg}) {
+ height: 217px;
+ }
`;
-export const StyledBlogCardImage = styled.img`
+export const StyledBlogCardImage = styled(Image)`
width: 100%;
- height: 100%;
`;
export const StyledBlogCardTag = styled.span`
diff --git a/src/components/modules/blog-card/index.tsx b/src/components/modules/blog-card/index.tsx
index 272cd2ba..9b65f7ed 100644
--- a/src/components/modules/blog-card/index.tsx
+++ b/src/components/modules/blog-card/index.tsx
@@ -14,11 +14,11 @@ import { ArrowRight } from '@/components/elements/icon';
import { Text } from '@/components/elements/text';
import { formatDateLongMonthYear } from '@/lib/utils/formatMonthYearDate';
-export const BlogCard = ({ title, text, image, date, tag }: BlogCardProps) => {
+export const BlogCard = ({ title, text, image, date, tag, slug }: BlogCardProps) => {
return (
-
+
{tag}
@@ -32,7 +32,14 @@ export const BlogCard = ({ title, text, image, date, tag }: BlogCardProps) => {
{text}
-
diff --git a/src/components/sections/blog/related-posts/index.tsx b/src/components/sections/blog/related-posts/index.tsx
new file mode 100644
index 00000000..fe12927d
--- /dev/null
+++ b/src/components/sections/blog/related-posts/index.tsx
@@ -0,0 +1,42 @@
+import { StyledRelatedPostWrapper, StyledRelatedPostsGrid } from './related-posts.styles';
+
+import Stack from '@/components/elements/stack';
+import { BlogCard } from '@/components/modules/blog-card';
+import { HeadingBlock } from '@/components/modules/heading-block';
+import { getRelatedPosts } from '@/lib/mdx';
+
+interface RelatedPostsProps {
+ tags: string[];
+ currentPostSlug: string;
+}
+
+export const RelatedPosts = async ({ tags, currentPostSlug }: RelatedPostsProps) => {
+ const relatedPosts = await getRelatedPosts({ tags, currentPostSlug });
+
+ if (relatedPosts.length === 0) {
+ return null;
+ }
+
+ return (
+
+
+
+
+ {relatedPosts.length &&
+ relatedPosts.map(post => (
+
+ ))}
+
+
+
+ );
+};
diff --git a/src/components/sections/blog/related-posts/related-posts.styles.ts b/src/components/sections/blog/related-posts/related-posts.styles.ts
new file mode 100644
index 00000000..d5fe36ad
--- /dev/null
+++ b/src/components/sections/blog/related-posts/related-posts.styles.ts
@@ -0,0 +1,27 @@
+'use client';
+
+import { screens, styled } from '@/styles';
+
+export const StyledRelatedPostWrapper = styled.section`
+ padding: 32px 0;
+ margin: 32px 0;
+
+ @media (min-width: ${screens['lg']}) {
+ padding: 48px 0;
+ margin: 48px 0;
+ }
+`;
+
+export const StyledRelatedPostsGrid = styled.div`
+ display: grid;
+ grid-template-columns: 1fr; /* 1 column on mobile */
+ gap: 24px;
+
+ @media (min-width: ${screens['lg']}) {
+ grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
+ }
+
+ & article {
+ max-width: 434px;
+ }
+`;
diff --git a/src/lib/mdx/index.ts b/src/lib/mdx/index.ts
index 7d08d732..6240a2b7 100644
--- a/src/lib/mdx/index.ts
+++ b/src/lib/mdx/index.ts
@@ -65,3 +65,17 @@ export const getAllPostsMeta = async () => {
}
return posts;
};
+
+export const getRelatedPosts = async ({ tags, currentPostSlug }: { tags: string[]; currentPostSlug: string }) => {
+ const allPosts = await getAllPostsMeta();
+
+ const filteredPosts = allPosts
+ .filter(post => post.slug !== currentPostSlug)
+ .filter(post => {
+ return tags.some(tag => post.tags.includes(tag));
+ })
+ .sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime())
+ .slice(0, 3);
+
+ return filteredPosts;
+};