Hi community,
I currently have a piece of code that replicates multiple road ( 3 total - posts). Do you know if it is possible to create a specific function on Meteor ( in a helper ? ) Which I could not duplicate my code ?
`
// Home page
Router.route(’/’, {
name: ‘home’,
itemName: ‘Accueil’,
data: function(){
// Si l'utilisateur n'est pas connecté
if (!Meteor.user()) {
// On affiche les articles non draftés
var posts = Posts.find({
draft: false
});
} else {
// Sinon, les drafts sont affichés
var posts = Posts.find();
}
return {
posts: posts
};
},
onAfterAction: function() {
SEO.set({
title: appSEO.seoSuffix,
meta: {
'description': 'une description'
}
});
}
});
// Blog
Router.route('/blog', {
name: 'blog',
parent: 'home',
itemName: 'Le blog',
data: function(){
// Si l'utilisateur n'est pas connecté
if (!Meteor.user()) {
// On affiche les articles non draftés
var posts = Posts.find({
draft: false
});
} else {
// Sinon, les drafts sont affichés
var posts = Posts.find();
}
return {
posts: posts
};
},
onAfterAction: function() {
SEO.set({
title: 'Le blog - ' + appSEO.seoSuffix,
meta: {
'description': 'une description'
}
});
}
});`
Thank you !