From 42eb0188896a8475a7fbb894775e5500ca8b7d35 Mon Sep 17 00:00:00 2001
From: satnaing
Date: Wed, 28 Dec 2022 19:18:50 +0630
Subject: [PATCH] fix: hide social links section if no link is active
fix #16
---
src/pages/index.astro | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/src/pages/index.astro b/src/pages/index.astro
index 66de80a4d..d2169517c 100644
--- a/src/pages/index.astro
+++ b/src/pages/index.astro
@@ -9,6 +9,7 @@ import getSortedPosts from "@utils/getSortedPosts";
import slugify from "@utils/slugify";
import type { Frontmatter } from "src/types";
import Socials from "@components/Socials.astro";
+import { SOCIALS } from "@config";
const posts = await Astro.glob("../contents/**/*.md");
@@ -16,6 +17,8 @@ const sortedPosts = getSortedPosts(posts);
const featuredPosts = sortedPosts.filter(
({ frontmatter }) => frontmatter.featured
);
+
+const socialCount = SOCIALS.filter(social => social.active).length;
---
@@ -54,10 +57,15 @@ const featuredPosts = sortedPosts.filter(
README
for more info.
-
+ {
+ // only display if at least one social link is enabled
+ socialCount > 0 && (
+
+ )
+ }
@@ -117,7 +125,7 @@ const featuredPosts = sortedPosts.filter(