From 87182583f8e5683452e80a4e05cee06f3cea7427 Mon Sep 17 00:00:00 2001
From: Calum Muir
Date: Sun, 7 Jun 2026 13:19:45 +0000
Subject: [PATCH] Wire home page content into Sanity CMS with hardcoded
fallbacks
Adds homePage singleton document type (hero headline/mission, video section,
CTA cards, sponsors). Home page fetches from Sanity when configured and
falls back to the existing hardcoded values when not.
Co-Authored-By: Claude Sonnet 4.6
---
src/lib/sanity.ts | 52 ++++++++++++++++++
src/pages/index.astro | 84 ++++++++++++++++--------------
studio/schemaTypes/homePageType.ts | 83 +++++++++++++++++++++++++++++
studio/schemaTypes/index.ts | 3 +-
4 files changed, 183 insertions(+), 39 deletions(-)
create mode 100644 studio/schemaTypes/homePageType.ts
diff --git a/src/lib/sanity.ts b/src/lib/sanity.ts
index 182ab26..3948b16 100644
--- a/src/lib/sanity.ts
+++ b/src/lib/sanity.ts
@@ -76,6 +76,58 @@ function toNewsArticle(post: SanityPost): NewsArticle {
};
}
+// ── Home page ─────────────────────────────────────────────────────────────────
+
+export interface SanityCtaCard {
+ label: string;
+ title: string;
+ description: string;
+ image?: string | null;
+ href: string;
+}
+
+export interface SanitySponsor {
+ name: string;
+ logo?: string | null;
+ url?: string | null;
+}
+
+export interface HomePageData {
+ heroHeadline: string;
+ heroMission: string;
+ videoHeading: string;
+ videoBody: string;
+ videoYoutubeId: string;
+ ctaCards: SanityCtaCard[];
+ sponsorHeading: string;
+ sponsors: SanitySponsor[];
+}
+
+const HOME_PAGE_QUERY = /* groq */ `*[_type == "homePage"][0]{
+ heroHeadline,
+ heroMission,
+ videoHeading,
+ videoBody,
+ videoYoutubeId,
+ ctaCards[]{
+ label,
+ title,
+ description,
+ "image": image.asset->url,
+ href,
+ },
+ sponsorHeading,
+ sponsors[]{
+ name,
+ "logo": logo.asset->url,
+ url,
+ }
+}`;
+
+export async function getSanityHomePage(): Promise {
+ return sanityClient.fetch(HOME_PAGE_QUERY);
+}
+
// ── Public API ────────────────────────────────────────────────────────────────
export async function getSanityPosts(): Promise {
diff --git a/src/pages/index.astro b/src/pages/index.astro
index c5a4797..b9cd768 100644
--- a/src/pages/index.astro
+++ b/src/pages/index.astro
@@ -3,6 +3,7 @@ import BaseLayout from "../layouts/BaseLayout.astro";
import SiteHeader from "../components/SiteHeader.astro";
import SiteFooter from "../components/SiteFooter.astro";
import { navigationItems } from "../lib/navigation";
+import { isSanityConfigured, getSanityHomePage } from "../lib/sanity";
const pageSeo = {
title: "Highland Group RDA",
@@ -13,32 +14,34 @@ const pageSeo = {
canonicalPath: "/",
};
-const ctaCards = [
- {
- label: "Fundraising",
- title: "Sponsor a pony",
- sub: "Your support keeps our ponies healthy and our sessions running — from hoof trimming to hay bales.",
- img: "/alineofponies-1920w.webp",
- objectPos: "50% 50%",
- href: "/support-us",
- },
- {
- label: "Get involved",
- title: "Apply to volunteer",
- sub: "No horse experience needed. Sidestep walkers, groomers, fundraisers — all roles make a real difference.",
- img: "/Vols5-2880w-1024x768.avif",
- objectPos: "50% 30%",
- href: "/volunteer-application",
- },
- {
- label: "Riding sessions",
- title: "Apply to participate",
- sub: "We welcome riders and carriage drivers with a wide range of physical and mental disabilities.",
- img: "/Samantha-and-Connolly-1280.webp",
- objectPos: "50% 38%",
- href: "/participant-application",
- },
-];
+// ── Fallback content (used when Sanity is not configured or document is empty) ─
+const DEFAULTS = {
+ heroHeadline: "Enriching lives through horses in the Highlands.",
+ heroMission: "Our mission is to bring about meaningful and positive changes in the health and well-being of people with physical or mental disabilities through activities with our horses and ponies.",
+ videoHeading: "What is Riding for the Disabled?",
+ videoBody: "Across the Highlands, we provide riding sessions for people with a wide range of physical and mental disabilities — connecting them with our ponies in a way that's therapeutic, joyful, and life-changing.",
+ videoYoutubeId: "IX2DGd6m8BU",
+ sponsorHeading: "We are grateful for the generous support of our sponsors.",
+ ctaCards: [
+ { label: "Fundraising", title: "Sponsor a pony", description: "Your support keeps our ponies healthy and our sessions running — from hoof trimming to hay bales.", image: "/alineofponies-1920w.webp", href: "/support-us" },
+ { label: "Get involved", title: "Apply to volunteer", description: "No horse experience needed. Sidestep walkers, groomers, fundraisers — all roles make a real difference.", image: "/Vols5-2880w-1024x768.avif", href: "/volunteer-application" },
+ { label: "Riding sessions",title: "Apply to participate", description: "We welcome riders and carriage drivers with a wide range of physical and mental disabilities.", image: "/Samantha-and-Connolly-1280.webp", href: "/participant-application" },
+ ],
+ sponsors: [
+ { name: "Ffordes", logo: "/sponsors/ffordes_logo.png", url: null },
+ ],
+};
+
+const cms = isSanityConfigured() ? (await getSanityHomePage()) : null;
+
+const heroHeadline = cms?.heroHeadline || DEFAULTS.heroHeadline;
+const heroMission = cms?.heroMission || DEFAULTS.heroMission;
+const videoHeading = cms?.videoHeading || DEFAULTS.videoHeading;
+const videoBody = cms?.videoBody || DEFAULTS.videoBody;
+const videoYoutubeId = cms?.videoYoutubeId || DEFAULTS.videoYoutubeId;
+const sponsorHeading = cms?.sponsorHeading || DEFAULTS.sponsorHeading;
+const ctaCards = cms?.ctaCards?.length ? cms.ctaCards : DEFAULTS.ctaCards;
+const sponsors = cms?.sponsors?.length ? cms.sponsors : DEFAULTS.sponsors;
---
@@ -242,7 +245,7 @@ const ctaCards = [
- Enriching lives through horses in the Highlands.
+ {heroHeadline}
@@ -253,7 +256,7 @@ const ctaCards = [
>
- Our mission is to bring about meaningful and positive changes in the health and well-being of people with physical or mental disabilities through activities with our horses and ponies.
+ {heroMission}
@@ -289,14 +292,14 @@ const ctaCards = [
Our Story
- What is Riding for the Disabled?
+ {videoHeading}
- Across the Highlands, we provide riding sessions for people with a wide range of physical and mental disabilities — connecting them with our ponies in a way that's therapeutic, joyful, and life-changing.
+ {videoBody}