-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsitemap.js
37 lines (33 loc) · 1016 Bytes
/
sitemap.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const sm = require('sitemap');
const firebase = require('firebase');
const { firebaseConfig } = require('./config');
!firebase.apps.length ? firebase.initializeApp(firebaseConfig) : null;
const createSitemap = (res) => {
let urlRoutes = [];
let sitemap = sm.createSitemap({
hostname: 'https://aninf.com',
cacheTime: 60
})
firebase.firestore().collection("knowledges").get()
.then(knowledges => {
firebase.firestore().collection("labels").get()
.then(labels => {
labels.docs.map(label => {
sitemap.add({
url: `etiket/${label.data().title}`,
changeFreq: 'daily',
priority: 0.8
})
})
knowledges.docs.map(knowledge => {
sitemap.add({
url: `anlatim/${knowledge.data().title.split(" ").join("-")}-${knowledge.id}`,
changeFreq: 'daily',
priority: 0.8
})
})
res.send(sitemap.toString());
})
})
}
module.exports = { createSitemap }