Permalink
Browse files

Resolve #54 Sitemap.xml is now working correctly for blogs created at…

… Engrave platform
  • Loading branch information...
bgornicki committed Nov 27, 2018
1 parent a7bd713 commit 306eabbf6d1018b7a95386a5f64439ce3b906b30
Showing with 10 additions and 20 deletions.
  1. +3 −3 engrave/.dockerignore
  2. +3 −1 engrave/blog/modules/articles.js
  3. +4 −16 engrave/blog/modules/sitemap.js
@@ -1,4 +1,4 @@
dist
node_modules
npm-debug.log
**/dist
**/node_modules
**/npm-debug.log
**/.env
@@ -5,6 +5,7 @@ let authors = require('../modules/authors');
let CronJob = require('cron').CronJob;
let steem = require('steem');
let cfg = require('../config');
const sitemap = require('../modules/sitemap');

let cachedArticles = [];

@@ -24,7 +25,8 @@ function updateArticleWithPermlink(permlink, article) {
return;
}
}
cachedArticles.unshift(article); // in case we didn't find anything
cachedArticles.unshift(article); // in case we didn't find
sitemap.addUrl(article.permlink, article.image, article.date);
}

function cacheAllArticles() {
@@ -7,34 +7,22 @@ let sitemap = sm.createSitemap({
hostname: 'https://' + cfg.get_config().domain,
cacheTime: 600000, // 600 sec - cache purge period
urls: [
{ url: '/', changefreq: 'daily', priority: 0.9 },
{ url: '/o-nas/', changefreq: 'monthly', priority: 0.5 },
{ url: '/kontakt', changefreq: 'monthly', priority: 0.5 }
{ url: '/', changefreq: 'daily', priority: 0.9 }
]
});

exports.addUrl = (url, image) => {
sitemap.add({ url: "/" + url, img: image, lastmodISO: moment().toISOString(), priority: 0.9});
exports.addUrl = (url, image, created) => {
sitemap.add({ url: "/" + url, img: image, lastmodISO: moment(created).toISOString(), priority: 0.9});
sitemap.clearCache();
};

exports.initialize = () => {
console.log("Sitemap module initialized");

cfg.get_config().categories.forEach(category => {
sitemap.add({ url: "/kategoria/" + category.slug, priority: 0.9});
sitemap.add({ url: "/category/" + category.slug, priority: 0.9});
});

Articles.find({status: "approved"}, function (err, articles) {
if(err) {
console.log(err);
} else if (articles) {
articles.map(function (article) {
sitemap.add({ url: "/" + article.permlink, img: article.image, lastmodISO: moment(article.date).toISOString(), priority: 0.5});
})
}
})

};

exports.sitemap = () => {

0 comments on commit 306eabb

Please sign in to comment.