summaryrefslogtreecommitdiff
path: root/src/components/blog/RelatedPosts.astro
diff options
context:
space:
mode:
authorDawid Rycerz <dawid@rycerz.xyz>2025-07-22 15:08:37 +0300
committerDawid Rycerz <dawid@rycerz.xyz>2025-07-22 15:08:37 +0300
commitfcc2f4704e39b0e69b377cc138f75027721dac22 (patch)
tree732fc94b354a26c08fba9cc9059f9c6c900182be /src/components/blog/RelatedPosts.astro
Initial template
Diffstat (limited to 'src/components/blog/RelatedPosts.astro')
-rw-r--r--src/components/blog/RelatedPosts.astro31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/components/blog/RelatedPosts.astro b/src/components/blog/RelatedPosts.astro
new file mode 100644
index 0000000..f4036e9
--- /dev/null
+++ b/src/components/blog/RelatedPosts.astro
@@ -0,0 +1,31 @@
+---
+import { APP_BLOG } from 'astrowind:config';
+
+import { getRelatedPosts } from '~/utils/blog';
+import BlogHighlightedPosts from '../widgets/BlogHighlightedPosts.astro';
+import type { Post } from '~/types';
+import { getBlogPermalink } from '~/utils/permalinks';
+
+export interface Props {
+ post: Post;
+}
+
+const { post } = Astro.props;
+
+const relatedPosts = post.tags ? await getRelatedPosts(post, 4) : [];
+---
+
+{
+ APP_BLOG.isRelatedPostsEnabled ? (
+ <BlogHighlightedPosts
+ classes={{
+ container:
+ 'pt-0 lg:pt-0 md:pt-0 intersect-once intersect-quarter motion-safe:md:opacity-0 motion-safe:md:intersect:animate-fade',
+ }}
+ title="Related Posts"
+ linkText="View All Posts"
+ linkUrl={getBlogPermalink()}
+ postIds={relatedPosts.map((post) => post.id)}
+ />
+ ) : null
+}