From 06ced5b37edcb5c859dfdc18f1fb8f7a7075a811 Mon Sep 17 00:00:00 2001 From: Troy Date: Sun, 5 Jan 2025 20:23:22 +0000 Subject: [PATCH] show view all button using consts value --- src/components/Hero.astro | 2 +- src/pages/index.astro | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/components/Hero.astro b/src/components/Hero.astro index 5d6d963..052046b 100644 --- a/src/components/Hero.astro +++ b/src/components/Hero.astro @@ -7,7 +7,7 @@ class="text-pretty font-['Outfit_Variable'] text-8xl font-bold md:text-9xl" > Digital designer based in the United Kingdom. diff --git a/src/pages/index.astro b/src/pages/index.astro index dfabcc3..0250aa1 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -6,12 +6,16 @@ import ShowcaseProject from "@components/ShowcaseProject.astro"; import ShowcasePost from "@components/ShowcasePost.astro"; import Hero from "@components/Hero.astro"; -const posts = (await getCollection("posts")) +const allPosts = await getCollection("posts"); + +const posts = allPosts .filter((post) => !post.data.draft) .sort((a, b) => b.data.date.valueOf() - a.data.date.valueOf()) .slice(0, HOME.HOMESETTINGS?.NUM_POSTS_ON_HOMEPAGE); -const projects = (await getCollection("projects")) +const allProjects = await getCollection("projects"); + +const projects = allProjects .filter((project) => !project.data.draft && project.data.featured) .sort((a, b) => b.data.date.valueOf() - a.data.date.valueOf()) .slice(0, HOME.HOMESETTINGS?.NUM_PROJECTS_ON_HOMEPAGE); @@ -36,9 +40,8 @@ const projects = (await getCollection("projects")) {projects.map((project) => )} { - projects.length > 1 ? ( + allProjects.length > HOME.HOMESETTINGS!.NUM_PROJECTS_ON_HOMEPAGE ? ( - {" "}
View all
@@ -63,7 +66,7 @@ const projects = (await getCollection("projects")) {posts.map((post) => )} { - posts.length > 1 ? ( + allPosts.length > HOME.HOMESETTINGS!.NUM_POSTS_ON_HOMEPAGE ? (
{" "}