mirror of
https://github.com/empayre/fleet.git
synced 2024-11-07 09:18:59 +00:00
f713668390
* articles page * update articles route to handle category urls * update articles page * add articleImageUrl meta tags to article pages * basic empty state, add comments * Update view-articles.js * Update articles.less * add articles, update styles and image url validation * lint fix * Update routes.js * Update articles.ejs * Update articles.page.js Updated article category descriptions. * migrated more articles I migrated more articles so that all categories are populated. * Added thumbnails to new posts * Some style tweaks - Tweaked a couple of styles - Added cursor: pointer to filters - Changed "Blog" to "Articles" in the navigation - Changed /blog to /articles in the navigation Co-authored-by: Mike Thomas <mthomas@fleetdm.com>
65 lines
1.6 KiB
JavaScript
Vendored
65 lines
1.6 KiB
JavaScript
Vendored
module.exports = {
|
|
|
|
|
|
friendlyName: 'View articles',
|
|
|
|
|
|
description: 'Display "Articles" page.',
|
|
|
|
inputs: {
|
|
category: {
|
|
type: 'string',
|
|
required: false,
|
|
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 ({category}) {
|
|
|
|
if (!_.isObject(sails.config.builtStaticContent) || !_.isArray(sails.config.builtStaticContent.markdownPages) || !sails.config.builtStaticContent.compiledPagePartialsAppPath) {
|
|
throw {badConfig: 'builtStaticContent.markdownPages'};
|
|
}
|
|
let articles = [];
|
|
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')) {
|
|
return page;
|
|
}
|
|
});
|
|
// setting the category to all
|
|
category = 'all';
|
|
} 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;
|
|
}
|
|
});
|
|
}
|
|
|
|
return {
|
|
path: require('path'),
|
|
articles,
|
|
category,
|
|
markdownPages: sails.config.builtStaticContent.markdownPages,
|
|
compiledPagePartialsAppPath: sails.config.builtStaticContent.compiledPagePartialsAppPath,
|
|
};
|
|
|
|
}
|
|
|
|
|
|
};
|