From b63b7730b673346fe861c0e0714aca485c6a7210 Mon Sep 17 00:00:00 2001 From: Tom Blake Date: Fri, 6 Dec 2024 10:09:58 +1300 Subject: [PATCH] Simplify homepage logic Simplify homepage logic by hardcoding the guides we want to display on it. This will ease the transition to Astro v5. Test plan: - Confirm homepage content is unchanged --- src/pages/index.astro | 84 +++++++++++++++++-------------------------- 1 file changed, 32 insertions(+), 52 deletions(-) diff --git a/src/pages/index.astro b/src/pages/index.astro index a61949787..8b8de4e41 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -1,39 +1,11 @@ --- import BaseLayout from '../layouts/BaseLayout.astro'; import FeaturedContentCard from '../components/FeaturedContentCard.astro'; -import { getCollection } from '../utils/getCollection'; +import { getEntryBySlug } from 'astro:content'; -export async function getStaticPaths() { - const guides = await getCollection('guides'); - return guides.map(entry => ({ - params: { slug: entry.slug }, - props: { entry }, - })); -} - -function hydrateGuides(featuredGuides, guides) { - return featuredGuides.map((guide) => { - const hydratedGuide = guides.find((g) => g.slug === guide.slug); - return hydratedGuide; - }); -} - -const guides = await getCollection('guides'); - -const featuredGuides = hydrateGuides([ - { slug: 'payment-flows' }, - { slug: 'farmlands-portal' }, - { slug: 'farmlands-pos-integration' }, -], guides); - -const featuredContent = [ - { - href: 'https://docs.centrapay.com/api', - title: 'API Reference', - description: 'Powerful, Easy-to-use payment APIs', - img: '/api-reference-cover.jpg', - }, -]; +const paymentFlowsGuide = await getEntryBySlug('guides', 'payment-flows'); +const farmlandsPortal = await getEntryBySlug('guides', 'farmlands-portal'); +const farmlandsPosIntegrationGuide = await getEntryBySlug('guides', 'farmlands-pos-integration'); const description = 'Learn to connect with Centrapay experiences.'; const img = '/homepage-preview.png'; @@ -63,26 +35,34 @@ const img = '/homepage-preview.png';

Featured Docs

- { featuredGuides.map((guide) => ( - - )) - } - { featuredContent.map((content, index) => ( - - )) - } + + + +