Added sitemap

This commit is contained in:
vjrj 2018-02-09 11:02:21 +01:00
parent c3bc4e604a
commit 346016b5c4
7 changed files with 78 additions and 1 deletions

View file

@ -8,3 +8,4 @@ import './migrations';
import './notificationsObserver';
import './facts';
import '../common/comments';
import './sitemaps';

View file

@ -0,0 +1,40 @@
/* global sitemaps Comments */
/* eslint-disable import/no-absolute-path */
import Fires from '/imports/api/Fires/Fires';
// import Comments from '/imports/api/Comments/Comments';
sitemaps.add('/sitemap.xml', () => {
const today = new Date();
const out = [];
out.push({ page: '/fires', lastmod: today });
out.push({ page: '/login', lastmod: today });
out.push({ page: '/signup', lastmod: today });
out.push({ page: '/recover-password', lastmod: today });
out.push({ page: '/credits', lastmod: today });
out.push({ page: '/terms', lastmod: today });
out.push({ page: '/license', lastmod: today });
out.push({ page: '/privacy', lastmod: today });
// When user has public page
/* const users = Meteor.users.find().fetch();
_.each(users, function(user) {
out.push({
page: '/persona/' + user.username,
lastmod: user.updatedAt
});
}); */
Fires.find().fetch().forEach((fire) => {
// Search the last comment of tha fire
const lastComment = Comments.getCollection().findOne({ referenceId: `fire-${fire._id}` }, { sort: { createdAt: -1 } });
out.push({
page: `/fire/archive/${fire._id._str}`,
lastmod: lastComment ? lastComment.createdAt : fire.updatedAt
});
});
return out;
});