sitemap collects pages

This commit is contained in:
tmshv committed 2016-11-12 12:19:02 +03:00
1 parent d749e46c53
commit da5823ddf7
1 file changed
+10
+10
View File
@@ -1,6 +1,7 @@
import sitemap from 'sitemap';
import route from 'koa-route';
import {c} from '../core/db';
import {getPageUrls as pages} from '../core/pages';
import {homeUrl, sitemapCacheTime} from '../config';
import menu from '../models/menu';
@@ -9,6 +10,7 @@ export default function () {
return route.get('/sitemap.xml', async ctx => {
let urls = await Promise.all([
getMenuUrls(),
getPageUrls(),
getGalleryUrls(),
getTeacherUrls(),
getEventsUrls(),
@@ -36,6 +38,14 @@ async function getMenuUrls(frequency='daily') {
}));
}
async function getPageUrls(frequency = 'daily') {
const ps = await pages();
return ps.map(i => ({
url: i.url,
changefreq: frequency
}));
}
async function getGalleryUrls() {
let docs = await c('albums')
.find({})