fleet/website/api/controllers/articles/view-articles.js
Eric 46bc7dc880
Website: add whitepaper article template page (#41405)
Changes:
- Updated `build-static-content` to support a new article category:
`whitepaper`
- Added a new article template page: `basic-whitepaper.ejs`.
- Added `deliver-whitepaper-download-request`, an action that
creates/updates a contact and account in the CRM and creates a
historical event when a user submits a form to download a whitepaper.
- Updated the "News" link in the website's header navigation to be
"Resources / Blog", and changed the link to /articles
- Added a link to the whitepapers category page (/whitepapers) to the
side bar navigation on article category pages
- Added a whitepaper article: "Modern endpoint management: Managing
devices as code"
2026-03-11 12:37:23 -05:00

125 lines
4.6 KiB
JavaScript
Vendored

module.exports = {
friendlyName: 'View articles',
description: 'Display "Articles" page.',
inputs: {
category: {
type: 'string',
description: 'The category of article to display.',
defaultsTo: '',
}
},
exits: {
success: { viewTemplatePath: 'pages/articles/articles' },
badConfig: { responseType: 'badConfig' },
notFound: { responseType: 'notFound' },
redirect: { responseType: 'redirect' },
},
fn: async function () {
if (!_.isObject(sails.config.builtStaticContent) || !_.isArray(sails.config.builtStaticContent.markdownPages) || !sails.config.builtStaticContent.compiledPagePartialsAppPath) {
throw {badConfig: 'builtStaticContent.markdownPages'};
}
let articles = [];
let category = this.req.path.split('/')[1];
if (category === 'articles') {
// If the category is `/articles` we'll show all articles
articles = sails.config.builtStaticContent.markdownPages.filter((page)=>{
if(_.startsWith(page.htmlId, 'articles') && !_.startsWith(page.url, '/guides')) {
return page;
}
});
} else {
// if the user navigates to a URL for a specific category, we'll only display articles in that category
articles = sails.config.builtStaticContent.markdownPages.filter((page)=>{
if(_.startsWith(page.url, '/'+category)) {
return page;
}
});
}
// Sort articles in descending order by publish date.
articles = _.sortByOrder(articles, 'meta.publishedOn', 'DESC');
let pageTitleForMeta = 'Fleet blog';
let pageDescriptionForMeta = 'Read the latest articles written by Fleet.';
// Create a currentSection variable, this will be used to highlight the header dropdown that this article category lives under.
// There are three possible values for this (documentation, community, and platform), so we'll default to the one with the most article categories (community) and set the value to another section if needed.
// If the category is deploy, guides, or releases, currentSection will be set to 'documentation', and if the category is 'success-stories', currentSection will be set to 'platform'.
let currentSection = 'community';
// Set a pageTitleForMeta, pageDescriptionForMeta, and currentSection variable based on the article category.
switch(category) {
case 'success-stories':
pageTitleForMeta = 'Success stories';
pageDescriptionForMeta = 'Read about how others are using Fleet and osquery.';
currentSection = 'platform';
break;
case 'deploy':
pageTitleForMeta = 'Deployment guides';
pageDescriptionForMeta = 'Learn how to deploy Fleet on a variety of production environments.';
currentSection = 'documentation';
break;
case 'releases':
pageTitleForMeta = 'Releases';
pageDescriptionForMeta = 'Fleet releases new and updated features every three weeks. Read about the latest product improvements here.';
currentSection = 'documentation';
break;
case 'guides':
pageTitleForMeta = 'Guides';
pageDescriptionForMeta = 'A collection of how-to guides for Fleet and osquery.';
currentSection = 'documentation';
break;
case 'securing':
pageTitleForMeta = 'Security articles';
pageDescriptionForMeta = 'Learn more about how we secure Fleet.';
break;
case 'engineering':
pageTitleForMeta = 'Engineering articles';
pageDescriptionForMeta = 'Read about engineering at Fleet and beyond.';
break;
case 'announcements':
pageTitleForMeta = 'Announcements';
pageDescriptionForMeta = 'Read the latest news from Fleet.';
break;
case 'podcasts':
pageTitleForMeta = 'Podcasts';
pageDescriptionForMeta = 'Listen to the Future of Device Management podcast.';
break;
case 'articles':
pageTitleForMeta = 'Blog';
pageDescriptionForMeta = 'Read the latest articles from the Fleet team and community.';
break;
case 'whitepapers':
pageTitleForMeta = 'Whitepapers';
pageDescriptionForMeta = 'Browse our whitepapers to learn how modern teams manage and secure their devices.';
break;
}
return {
path: require('path'),
articles,
category,
markdownPages: sails.config.builtStaticContent.markdownPages,
compiledPagePartialsAppPath: sails.config.builtStaticContent.compiledPagePartialsAppPath,
currentSection,
pageTitleForMeta,
pageDescriptionForMeta,
algoliaPublicKey: sails.config.custom.algoliaPublicKey,
};
}
};