From f01f5064c43e8f30ad3721c72272cdff5d0569bb Mon Sep 17 00:00:00 2001 From: Ana Gabriela Reyna Date: Tue, 31 Dec 2024 10:19:43 +0000 Subject: [PATCH] Latestblog (#201) --- .../astro-theme/components/BlogPostCard.astro | 11 ++++++++++- .../components/BlogPostCardSet.astro | 12 ++++++++++-- sites/cheerp/src/pages/index.astro | 18 ++++++++++++++++++ sites/cheerpx/src/pages/index.astro | 18 ++++++++++++++++++ 4 files changed, 56 insertions(+), 3 deletions(-) diff --git a/packages/astro-theme/components/BlogPostCard.astro b/packages/astro-theme/components/BlogPostCard.astro index 42538e06..71707fe6 100644 --- a/packages/astro-theme/components/BlogPostCard.astro +++ b/packages/astro-theme/components/BlogPostCard.astro @@ -3,6 +3,9 @@ import { getEntry, type CollectionEntry } from "astro:content"; import FormattedDate from "./FormattedDate.astro"; import { resolveAuthors } from "../lib/blog"; import { Image } from "astro:assets"; +import { productFromUrl } from "../lib/products"; + +const product = productFromUrl(Astro.url); interface Props { post: CollectionEntry<"blog"> | CollectionEntry<"blog">["slug"]; @@ -16,6 +19,9 @@ const post = ? await getEntry("blog", postOrSlug) : postOrSlug; const authors = await resolveAuthors(post.data.authors); + +//choose hover link color based on product +const productName = typeof product === "undefined" ? "Labs" : product.name; --- ): number { let relevancy = @@ -25,10 +28,15 @@ function sortCalc(post: CollectionEntry<"blog">): number { const posts = ( await getCollection("blog", (post) => { - if (post.data.draft || exclude?.includes(post.id)) { + if ( + post.data.draft || + exclude?.includes(post.id) || + !(post.data?.tags?.includes(productName) || productName === "Labs") + ) { return false; + } else { + return true; } - return true; }) ) .sort((a, b) => sortCalc(b) - sortCalc(a)) diff --git a/sites/cheerp/src/pages/index.astro b/sites/cheerp/src/pages/index.astro index cba2ca78..d8ed4283 100644 --- a/sites/cheerp/src/pages/index.astro +++ b/sites/cheerp/src/pages/index.astro @@ -9,6 +9,7 @@ import IconLayers from "../assets/layers.png"; import DrawingSourcerer from "../assets/sourcerer.png"; import { Image } from "astro:assets"; import { DISCORD_URL } from "@leaningtech/astro-theme/consts"; +import BlogPostCardSet from "@leaningtech/astro-theme/components/BlogPostCardSet.astro"; --- @@ -181,6 +182,23 @@ import { DISCORD_URL } from "@leaningtech/astro-theme/consts"; +
+
+
+

Cheerp blog

+

Latest news

+
+ +
+ +
+
+
diff --git a/sites/cheerpx/src/pages/index.astro b/sites/cheerpx/src/pages/index.astro index 4509af04..9d6d29b8 100644 --- a/sites/cheerpx/src/pages/index.astro +++ b/sites/cheerpx/src/pages/index.astro @@ -9,6 +9,7 @@ import Screenshot from "../assets/screenshots.png"; import { Image } from "astro:assets"; import { DISCORD_URL } from "@leaningtech/astro-theme/consts"; import MonitorDoodle from "../assets/hero_illustration.png"; +import BlogPostCardSet from "@leaningtech/astro-theme/components/BlogPostCardSet.astro"; --- @@ -213,6 +214,23 @@ import MonitorDoodle from "../assets/hero_illustration.png";
+
+
+
+

CheerpX blog

+

Latest news

+
+ +
+ +
+
+