feat: add testimonials within the daily email form

This commit is contained in:
Oliver Davies 2023-10-19 15:46:48 +02:00
parent 7f4358ebf8
commit 51481abd3c
3 changed files with 11 additions and 3 deletions

View file

@ -637,3 +637,5 @@ const { intro } = Astro.props;
</div> </div>
</div> </div>
</form> </form>
<slot />

View file

@ -5,6 +5,7 @@ import _ from "lodash";
interface Props { interface Props {
names: string[]; names: string[];
title?: string; title?: string;
titleClasses?: string[];
} }
const defaultNames = [ const defaultNames = [
@ -27,7 +28,7 @@ const defaultNames = [
'anonymous', 'anonymous',
]; ];
const { title } = Astro.props as Props; const { title, titleClasses } = 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));
@ -38,7 +39,7 @@ const sortedTestimonials = _(names)
--- ---
{testimonials && ( {testimonials && (
<h2>{title ?? 'What others have said'}</h2> <h2 class={titleClasses ? titleClasses.join(' ') : null}>{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 } }) => (

View file

@ -5,6 +5,7 @@ isFront: true
--- ---
import DailyEmailForm from '~/components/DailyEmailForm.astro'; import DailyEmailForm from '~/components/DailyEmailForm.astro';
import Testimonials from '~/components/Testimonials.astro';
import { numberOfYears } from '~/utils'; import { numberOfYears } from '~/utils';
<div class="mb-4 w-32"> <div class="mb-4 w-32">
@ -40,7 +41,11 @@ Book a [1-on-1 consultation call][call] or an [online pair programming session][
Register for my email list and get daily emails about Drupal, PHP and software development. Register for my email list and get daily emails about Drupal, PHP and software development.
<DailyEmailForm /> <DailyEmailForm>
<div class="mt-10">
<Testimonials names={["adam-nuttall"]} titleClasses={["sr-only"]} />
</div>
</DailyEmailForm>
</aside> </aside>
[call]: /call [call]: /call