fleet/website/api/controllers/view-testimonials.js
Eric 82ec1d8e16
Website: update article links on /testimonials page (#24850)
Closes: #24746

Changes:
- Replaced the hard-coded links to articles on the /testimonials page
with server-side rendered generated links to articles. These links are
now built using the website's markdown articles configuration.
- Added support for a new meta tag on articles:
`showOnTestimonialsPageWithEmoji` If provided and set to one of the four
supported emoji (🥀, 🔌, 🚪, or 🪟), a link to the article will be added to
the /testimonials page. Example: `<meta
name="showOnTestimonialsPageWithEmoji" value="🥀">`.
- Updated the build-static-content script to throw an error if an
article has an invalid `showOnTestimonialsPageWithEmoji` meta tag value.
- Updated recent case study articles to have a
`showOnTestimonialsPageWithEmoji` meta tag.


@Drew-P-drawers When this PR is merged, you can add links to the new
case studies articles to the /testimonials page with a
`showOnTestimonialsPageWithEmoji` meta tag. The definitions for each of
the supported emoji are in this [google
doc](https://docs.google.com/document/d/1-KWQa3uMIJzeitzDRmzT3SnUoFCfcFCb6K2lyVt-Gy0/edit?tab=t.0#heading=h.oskipmb8530l)
2024-12-17 18:08:25 -05:00

126 lines
4.1 KiB
JavaScript
Vendored

module.exports = {
friendlyName: 'View testimonials',
description: 'Display "Testimonials" page.',
exits: {
success: {
viewTemplatePath: 'pages/testimonials'
}
},
fn: async function () {
if (!_.isObject(sails.config.builtStaticContent) || !_.isArray(sails.config.builtStaticContent.testimonials) || !sails.config.builtStaticContent.compiledPagePartialsAppPath) {
throw {badConfig: 'builtStaticContent.testimonials'};
}
// Get testimonials for the page contents
let testimonials = _.clone(sails.config.builtStaticContent.testimonials);
// Filter the testimonials by product category
let testimonialOrderForMdm = [
'Scott MacVicar',
'Chandra Majumdar',
'Nico Waisman',
'Kenny Botelho',
'Eric Tan',
'Dan Grzelak',
'Erik Gomez',
'Matt Carr',
];
let testimonialsForMdm = _.filter(testimonials, (testimonial)=>{
return _.contains(testimonial.productCategories, 'Device management') && _.contains(testimonialOrderForMdm, testimonial.quoteAuthorName);
});
testimonialsForMdm.sort((a, b)=>{
if(testimonialOrderForMdm.indexOf(a.quoteAuthorName) === -1){
return 1;
} else if(testimonialOrderForMdm.indexOf(b.quoteAuthorName) === -1) {
return -1;
}
return testimonialOrderForMdm.indexOf(a.quoteAuthorName) - testimonialOrderForMdm.indexOf(b.quoteAuthorName);
});
let testimonialOrderForSoftwareManagement = [
'Wes Whetstone',
'Erik Gomez',
'Chandra Majumdar',
'Kenny Botelho',
'Arsenio Figueroa',
'Andre Shields',
'Nico Waisman',
'Eric Tan',
'Dan Grzelak',
];
let testimonialsForSoftwareManagement = _.filter(testimonials, (testimonial)=>{
return _.contains(testimonial.productCategories, 'Software management') && _.contains(testimonialOrderForSoftwareManagement, testimonial.quoteAuthorName);
});
testimonialsForSoftwareManagement.sort((a, b)=>{
if(testimonialOrderForSoftwareManagement.indexOf(a.quoteAuthorName) === -1){
return 1;
} else if(testimonialOrderForSoftwareManagement.indexOf(b.quoteAuthorName) === -1) {
return -1;
}
return testimonialOrderForSoftwareManagement.indexOf(a.quoteAuthorName) - testimonialOrderForSoftwareManagement.indexOf(b.quoteAuthorName);
});
let testimonialOrderForObservability = [
'Eric Tan',
'Arsenio Figueroa',
'Scott MacVicar',
'Chandra Majumdar',
'Kenny Botelho',
'Brendan Shaklovitz',
'Erik Gomez',
'Charles Zaffery',
'Ahmed Elshaer',
'Andre Shields',
'Mike Arpaia',
'Tom Larkin',
];
let testimonialsForObservability = _.filter(testimonials, (testimonial)=>{
return _.contains(testimonial.productCategories, 'Observability') && _.contains(testimonialOrderForObservability, testimonial.quoteAuthorName);
});
testimonialsForObservability.sort((a, b)=>{
if(testimonialOrderForObservability.indexOf(a.quoteAuthorName) === -1){
return 1;
} else if(testimonialOrderForObservability.indexOf(b.quoteAuthorName) === -1) {
return -1;
}
return testimonialOrderForObservability.indexOf(a.quoteAuthorName) - testimonialOrderForObservability.indexOf(b.quoteAuthorName);
});
let testimonialsWithVideoLinks = _.filter(testimonials, (testimonial)=>{
return testimonial.youtubeVideoUrl;
});
// Get articles with a showOnTestimonialsPageWithEmoji meta tag to display on this page.
let articles = sails.config.builtStaticContent.markdownPages.filter((page)=>{
if(_.startsWith(page.htmlId, 'articles')) {
return page;
}
});
let articlesForThisPage = _.filter(articles, (article)=>{
return article.meta.showOnTestimonialsPageWithEmoji;
});
// Sort the articles by their publish date.
articlesForThisPage = _.sortBy(articlesForThisPage, 'meta.publishedOn');
return {
testimonialsForMdm,
testimonialsForSoftwareManagement,
testimonialsForObservability,
testimonialsWithVideoLinks,
articlesForThisPage,
};
}
};