feat: make testimonials title configurable
This commit is contained in:
parent
95049a8711
commit
16d6c97821
|
@ -4,6 +4,7 @@ import _ from "lodash";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
names: string[];
|
names: string[];
|
||||||
|
title?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultNames = [
|
const defaultNames = [
|
||||||
|
@ -26,6 +27,7 @@ const defaultNames = [
|
||||||
'anonymous',
|
'anonymous',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const { title } = Astro.props as Props;
|
||||||
const names = _(Astro.props.names || defaultNames);
|
const names = _(Astro.props.names || defaultNames);
|
||||||
|
|
||||||
const testimonials = await getCollection('testimonial', ({ id }) => names.includes(id));
|
const testimonials = await getCollection('testimonial', ({ id }) => names.includes(id));
|
||||||
|
@ -36,7 +38,7 @@ const sortedTestimonials = _(names)
|
||||||
---
|
---
|
||||||
|
|
||||||
{testimonials && (
|
{testimonials && (
|
||||||
<h2>What others have said</h2>
|
<h2>{title ?? 'What others have said'}</h2>
|
||||||
|
|
||||||
<div class="mt-6 space-y-14">
|
<div class="mt-6 space-y-14">
|
||||||
{_(sortedTestimonials).map(({ data: { image, name, tagline, text, url } }) => (
|
{_(sortedTestimonials).map(({ data: { image, name, tagline, text, url } }) => (
|
||||||
|
|
|
@ -25,7 +25,7 @@ import Testimonials from "~/components/Testimonials.astro";
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<Testimonials names={frontmatter.testimonials} />
|
<Testimonials title={"What subscribers have said"} names={frontmatter.testimonials} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -5,4 +5,4 @@ title: Testimonials
|
||||||
|
|
||||||
import Testimonials from "~/components/Testimonials.astro";
|
import Testimonials from "~/components/Testimonials.astro";
|
||||||
|
|
||||||
<Testimonials />
|
<Testimonials title={"What people have said"} />
|
||||||
|
|
Loading…
Reference in a new issue