From 7825d7b8f8cb32a9fa823d3b592f50480981957d Mon Sep 17 00:00:00 2001 From: Laurie Reynolds Date: Sat, 9 May 2026 19:36:10 -0700 Subject: [PATCH 1/2] create RandomContent component and example demo on BlogLayout --- astro/src/components/RandomContent.astro | 35 ++++++++++++++++++++++++ astro/src/layouts/BlogLayout.astro | 32 ++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 astro/src/components/RandomContent.astro diff --git a/astro/src/components/RandomContent.astro b/astro/src/components/RandomContent.astro new file mode 100644 index 00000000..f5d47231 --- /dev/null +++ b/astro/src/components/RandomContent.astro @@ -0,0 +1,35 @@ +--- +// When rendered on the server this, displays the first child and hides the rest. +// On page load, the client script picks one to show and hides the rest. +--- + +
+ +
+ + + + diff --git a/astro/src/layouts/BlogLayout.astro b/astro/src/layouts/BlogLayout.astro index 7d2f2ace..e18f23a6 100644 --- a/astro/src/layouts/BlogLayout.astro +++ b/astro/src/layouts/BlogLayout.astro @@ -60,6 +60,7 @@ import Branding from "@components/Branding.astro"; import FlexColumn from "@components/FlexColumn.astro"; import ImageHeading from "@components/ImageHeading.astro"; import Layout from "./Layout.astro"; +import RandomContent from "@components/RandomContent.astro"; import TeamVignette from "@components/TeamVignette.astro"; import ThemedSection from "@components/ThemedSection.astro"; --- @@ -87,6 +88,37 @@ import ThemedSection from "@components/ThemedSection.astro"; Blog + {!isEmpty(blogs) && ( + +

Demo: RandomContent Component

+

+ A different blog post is featured at random on each page load. Reload to see another. +

+ + {blogs.slice(0, 5).map((b) => ( + + ))} + +
+ )} + {!isEmpty(authors) && ( + +

Demo: RandomContent with an Author

+

+ A different blog author is featured at random on each page load. +

+ + {authors.slice(0, 5).map((author) => ( +
+ +
+ ))} +
+
+ )}
From 3e72a9a822a1fa236d6de3d69679a2249172d181 Mon Sep 17 00:00:00 2001 From: Brian Montgomery Date: Thu, 4 Jun 2026 12:33:45 -0400 Subject: [PATCH 2/2] Variable amount of Content and other cleanup --- astro/src/components/Hero.astro | 8 ++- astro/src/components/RandomContent.astro | 78 ++++++++++++++++++------ astro/src/layouts/BlogLayout.astro | 32 ---------- 3 files changed, 64 insertions(+), 54 deletions(-) diff --git a/astro/src/components/Hero.astro b/astro/src/components/Hero.astro index 2b98c55f..57d80d54 100644 --- a/astro/src/components/Hero.astro +++ b/astro/src/components/Hero.astro @@ -1,12 +1,14 @@ --- import { getImage } from "astro:assets"; import type { ImageMetadata } from "astro"; +import RandomContent from "./RandomContent.astro"; interface Props { image: ImageMetadata | string; theme?: string; columns?: string; actionBreakpoint?: string; + actionBarItems?: number; } const { @@ -14,6 +16,7 @@ const { theme = "primary", columns = "col-lg-6", actionBreakpoint = "lg", + actionBarItems = 3, } = Astro.props; let heroBgUrl; @@ -39,11 +42,12 @@ if (image) { { Astro.slots.has("action-bar") && (
-
-
+
) } diff --git a/astro/src/components/RandomContent.astro b/astro/src/components/RandomContent.astro index f5d47231..07c4ae6b 100644 --- a/astro/src/components/RandomContent.astro +++ b/astro/src/components/RandomContent.astro @@ -1,35 +1,73 @@ --- -// When rendered on the server this, displays the first child and hides the rest. -// On page load, the client script picks one to show and hides the rest. +// When rendered on the server this, displays the first x children and hides the rest. +// On page load, the client script picks the number given to show and hides the rest. + +import type { HTMLAttributes } from 'astro/types'; +interface Props extends HTMLAttributes<"div"> { + numChildren?: 1 | 2 | 3 | 4 | 5 | 6 | `${1 | 2 | 3 | 4 | 5 | 6}`; +} +const { numChildren = 1, ...attrs } = Astro.props; --- -
+
- diff --git a/astro/src/layouts/BlogLayout.astro b/astro/src/layouts/BlogLayout.astro index e18f23a6..7d2f2ace 100644 --- a/astro/src/layouts/BlogLayout.astro +++ b/astro/src/layouts/BlogLayout.astro @@ -60,7 +60,6 @@ import Branding from "@components/Branding.astro"; import FlexColumn from "@components/FlexColumn.astro"; import ImageHeading from "@components/ImageHeading.astro"; import Layout from "./Layout.astro"; -import RandomContent from "@components/RandomContent.astro"; import TeamVignette from "@components/TeamVignette.astro"; import ThemedSection from "@components/ThemedSection.astro"; --- @@ -88,37 +87,6 @@ import ThemedSection from "@components/ThemedSection.astro"; Blog - {!isEmpty(blogs) && ( - -

Demo: RandomContent Component

-

- A different blog post is featured at random on each page load. Reload to see another. -

- - {blogs.slice(0, 5).map((b) => ( - - ))} - -
- )} - {!isEmpty(authors) && ( - -

Demo: RandomContent with an Author

-

- A different blog author is featured at random on each page load. -

- - {authors.slice(0, 5).map((author) => ( -
- -
- ))} -
-
- )}