sitemap collects pages
This commit is contained in:
1 parent
d749e46c53
commit
da5823ddf7
1 file changed
+10
@@ -1,6 +1,7 @@
|
|||||||
import sitemap from 'sitemap';
|
import sitemap from 'sitemap';
|
||||||
import route from 'koa-route';
|
import route from 'koa-route';
|
||||||
import {c} from '../core/db';
|
import {c} from '../core/db';
|
||||||
|
import {getPageUrls as pages} from '../core/pages';
|
||||||
|
|
||||||
import {homeUrl, sitemapCacheTime} from '../config';
|
import {homeUrl, sitemapCacheTime} from '../config';
|
||||||
import menu from '../models/menu';
|
import menu from '../models/menu';
|
||||||
@@ -9,6 +10,7 @@ export default function () {
|
|||||||
return route.get('/sitemap.xml', async ctx => {
|
return route.get('/sitemap.xml', async ctx => {
|
||||||
let urls = await Promise.all([
|
let urls = await Promise.all([
|
||||||
getMenuUrls(),
|
getMenuUrls(),
|
||||||
|
getPageUrls(),
|
||||||
getGalleryUrls(),
|
getGalleryUrls(),
|
||||||
getTeacherUrls(),
|
getTeacherUrls(),
|
||||||
getEventsUrls(),
|
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() {
|
async function getGalleryUrls() {
|
||||||
let docs = await c('albums')
|
let docs = await c('albums')
|
||||||
.find({})
|
.find({})
|
||||||
|
|||||||
Reference in new issue
Block a user