Load testimonials by tag instead of by name

- Allow loading testimonials by tag instead of name.
- Remove the code to load testimonials by name.
- Add a `limit` and `offset` to create different lists on the same page
  - e.g. on the team coaching page where I have two testimonial
  sections.
This commit is contained in:
Oliver Davies 2024-01-15 17:39:59 +00:00
parent 59bb9af6d1
commit fc3e30eddd
9 changed files with 46 additions and 78 deletions

View file

@ -1,36 +1,19 @@
{% set defaultNames = [
"Matthieu Scarset",
"Mike Karthauser",
"Tawny Bartlett",
"Joe Howell",
"Jon Hallett",
"Michael Itkoff",
"Mick Felton",
"Duncan Davidson",
"Adam Cuddihy",
"Huw Davies",
"Scott Euser",
"Brian Hartwell",
"Alan Hatch",
"Holly Ross",
"Josh Mitchell",
"Brian Healy",
"Chris Jarvis",
"Daniel Easterbrook",
"Anonymous",
] %}
{% set limit = limit ?? 10 %}
{% set offset = offset ?? 0 %}
{% if not merge %}
{% set names = names|default(defaultNames) %}
{% else %}
{% set names = names|merge(defaultNames) %}
{% set testimonials = site.testimonials %}
{% if tag is not null %}
{% set testimonials = testimonials|filter(testimonial => tag in testimonial.tags) %}
{% endif %}
{% set testimonials = testimonials|slice(offset, limit) %}
<section>
<h2 class="text-xl font-bold">{{ title|default('Testimonials') }}</h2>
<div class="mt-4 space-y-12">
{% for testimonial in site.testimonials|filter(testimonial => names is null or testimonial.name in names) %}
{% for testimonial in testimonials %}
<div>
<div class="italic prose prose-p:text-black prose-a:font-light prose-a:text-blue-primary prose-p:text-lg prose-blockquote:border-blue-primary dark:marker:text-white prose-li:my-1 prose-li:text-lg prose-figcaption:text-white prose-li:text-black marker:text-black dark:prose-p:text-white dark:prose-invert dark:prose-a:text-blue-400 dark:prose-blockquote:border-blue-400 dark:prose-li:text-white hover:prose-a:no-underline prose-h2:text-xl prose-code:font-normal prose-h2:mb-4 prose-ul:my-3 dark:prose-hr:border-grey-400 prose-code:before:content-[''] prose-code:after:content-['']">
<blockquote>

View file

@ -20,14 +20,7 @@ Learn to test things like:
{% block content_bottom %}
<div class="space-y-12">
{% include 'testimonials.html.twig' with {
names: [
"Matthieu Scarset",
"Mike Karthauser",
"Tawny Bartlett",
"Scott Euser",
]
} %}
{% include 'testimonials' with { tag: 'subscription' } %}
{{ parent() }}
</div>

View file

@ -2,10 +2,6 @@
title: Book a 1-on-1 consulting call
link: https://savvycal.com/opdavies/consulting-call
price: 350
testimonials:
- Tawny Bartlett
- Tom Evans
- Michael Itkoff
faqs:
-
- What happens after I pay?
@ -62,9 +58,7 @@ faqs:
{# Social proof #}
{% include 'testimonials' with {
names: page.testimonials,
} %}
{% include 'testimonials' with { tag: 'call' } %}
{# Overcome objections #}

View file

@ -10,14 +10,7 @@ title: Register for daily software development emails
{% block content_bottom %}
{% include 'testimonials.html.twig' with {
names: [
'Alexander Carr',
'Adam Nuttall',
'Mike Karthauser',
'Marcos Duran',
'Stephen Mulvihill',
'Patty O\'Callaghan',
],
tag: 'daily',
title: 'What subscribers have said',
} %}

View file

@ -45,6 +45,4 @@ Seats are available at <span class="font-bold">{{ page.is_early_bird ? 'an early
<hr />
{% include 'testimonials.html.twig' with {
names: page.testimonials,
} %}
{% include 'testimonials' with { tag: 'testing' } %}

View file

@ -31,10 +31,8 @@ Here are [all my products and services][pricing]. If you still can't find what y
{% endblock %}
{% block content_bottom %}
{% include 'testimonials.html.twig' with {
{% include 'testimonials' with {
title: 'Kind words from clients, subscribers, and past colleagues',
merge: true,
names: ["Matthieu Scarset"],
} %}
{% include 'daily-email-form.html.twig' with {

View file

@ -182,23 +182,7 @@ And we'll figure out what's best for you.
---
{% include 'testimonials.html.twig' with {
names: [
'Joe Howell',
'Jon Hallett',
'Michael Itkoff',
'Mick Felton',
'Duncan Davidson',
'Adam Cuddihy',
'Huw Davies',
'Brian Hartwell',
'Holly Ross',
'Josh Mitchell',
'Brian Healy',
'Daniel Easterbrook',
'Anonymous',
],
} %}
{% include 'testimonials' with { tag: 'subscription' } %}
{% endblock %}

View file

@ -88,9 +88,10 @@ meta:
<p>If you need lighter-touch guidance and advice, I also offer one-time consulting calls and pair programming sessions.</p>
</section>
{% include 'testimonials.html.twig' with {
names: ['Mike Karthauser', 'Tawny Bartlett', 'Joe Howell', 'Scott Euser', 'Mick Felton'],
title: 'More that others have said',
{% include 'testimonials' with {
tag: 'coaching',
limit: 5,
title: 'What others have said',
} %}
{# Uniqueness #}
@ -130,8 +131,9 @@ meta:
} %}
</div>
{% include 'testimonials.html.twig' with {
names: ['Duncan Davidson', 'Adam Cuddihy', 'Alan Hatch', 'Anonymous'],
{% include 'testimonials' with {
tag: 'coaching',
offset: 5,
title: 'More that others have said',
} %}