fleet/website/api/controllers/articles/view-basic-webinar.js

67 lines
1.3 KiB
JavaScript
Raw Normal View History

module.exports = {
friendlyName: 'View basic webinar',
description: 'Display "Basic webinar" page.',
inputs: {
slug: {
type: 'string',
description: 'The slug of the webinar that will be displayed to the user',
required: true,
}
},
exits: {
success: {
viewTemplatePath: 'pages/articles/basic-webinar'
},
badConfig: {
responseType: 'badConfig'
},
notFound: {
responseType: 'notFound'
},
},
fn: async function ({slug}) {
if (!_.isObject(sails.config.builtStaticContent) || !_.isArray(sails.config.builtStaticContent.markdownPages) || !sails.config.builtStaticContent.markdownPages) {
throw {badConfig: 'builtStaticContent.markdownPages'};
}
let thisPage = _.find(sails.config.builtStaticContent.markdownPages, { url: '/webinars/'+encodeURIComponent(slug) });
if (!thisPage) {
throw 'notFound';
}
let pageTitleForMeta;
let pageDescriptionForMeta;
if(thisPage.meta.articleTitle) {
pageTitleForMeta = thisPage.meta.articleTitle;
}
if(thisPage.meta.description) {
pageDescriptionForMeta = thisPage.meta.description;
}
// Respond with view.
return {
pageTitleForMeta,
pageDescriptionForMeta,
path: require('path'),
thisPage: thisPage,
};
}
};