feat(testimonials): allow for ordering by name

This commit is contained in:
Oliver Davies 2023-09-20 13:00:00 +01:00
parent a6e691e442
commit 59b82c330f
4 changed files with 16 additions and 33 deletions

View file

@ -7,23 +7,29 @@ interface Props {
} }
const defaultNames = [ const defaultNames = [
'adam-cuddihy',
'brian-hartwell',
'anonymous',
'huw-davies',
'joe-howell', 'joe-howell',
'michael-itkoff', 'michael-itkoff',
'mick-felton', 'mick-felton',
'duncan-davidson',
'adam-cuddihy',
'huw-davies',
'scott-euser', 'scott-euser',
'brian-hartwell',
'alan-hatch',
'holly-ross',
'josh-mitchell',
'brian-healy',
'chris-jarvis',
'daniel-easterbrook',
'anonymous',
]; ];
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));
const sortedTestimonials = _(testimonials) const sortedTestimonials = _(names)
.sort((a, b) => new Date(a.date) < new Date(b.date)) .flatMap(name => testimonials.filter(testimonial => testimonial.id === name))
.reverse()
.value(); .value();
--- ---

View file

@ -4,8 +4,8 @@ title: Book a 1-on-1 consulting call
link: https://savvycal.com/opdavies/consulting-call link: https://savvycal.com/opdavies/consulting-call
price: £350 price: £350
testimonials: testimonials:
- michael-itkoff2
- tom-evans - tom-evans
- michael-itkoff2
--- ---
import Button from "~/components/Button.astro"; import Button from "~/components/Button.astro";

View file

@ -53,7 +53,7 @@ An upgrade roadmap is a personalised audit of your Drupal website and includes d
{/* Social proof */} {/* Social proof */}
<Testimonials names={frontmatter.testimonials} /> <Testimonials />
{/* Overcome objections */} {/* Overcome objections */}

View file

@ -5,27 +5,4 @@ title: Testimonials
import Testimonials from "~/components/Testimonials.astro"; import Testimonials from "~/components/Testimonials.astro";
<Testimonials names={[ <Testimonials />
'adam-cuddihy',
'alan-hatch',
'anonymous',
'brian-hartwell',
'brian-healy',
'chris-jarvis',
'chris-knox',
'daniel-easterbrook',
'duncan-davidson',
'holly-ross',
'huw-davies',
'james-chapman',
'joe-howell',
'jon-hallett',
'josh-mitchell',
'leonie-watson',
'marlon-duncanson',
'michael-itkoff',
'mick-felton',
'owen-phillips',
'scott-euser',
'tom-evans',
]} />