feat: make testimonials title configurable

This commit is contained in:
Oliver Davies 2023-10-16 10:25:28 +01:00
parent 95049a8711
commit 16d6c97821
3 changed files with 5 additions and 3 deletions

View file

@ -4,6 +4,7 @@ import _ from "lodash";
interface Props {
names: string[];
title?: string;
}
const defaultNames = [
@ -26,6 +27,7 @@ const defaultNames = [
'anonymous',
];
const { title } = Astro.props as Props;
const names = _(Astro.props.names || defaultNames);
const testimonials = await getCollection('testimonial', ({ id }) => names.includes(id));
@ -36,7 +38,7 @@ const sortedTestimonials = _(names)
---
{testimonials && (
<h2>What others have said</h2>
<h2>{title ?? 'What others have said'}</h2>
<div class="mt-6 space-y-14">
{_(sortedTestimonials).map(({ data: { image, name, tagline, text, url } }) => (

View file

@ -25,7 +25,7 @@ import Testimonials from "~/components/Testimonials.astro";
</div>
<div>
<Testimonials names={frontmatter.testimonials} />
<Testimonials title={"What subscribers have said"} names={frontmatter.testimonials} />
</div>
</div>

View file

@ -5,4 +5,4 @@ title: Testimonials
import Testimonials from "~/components/Testimonials.astro";
<Testimonials />
<Testimonials title={"What people have said"} />