summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/readfile.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/source/readfile.js b/source/readfile.js
index 9310b8c..def56a1 100644
--- a/source/readfile.js
+++ b/source/readfile.js
@@ -1,5 +1,7 @@
const fs = require('fs')
const path = require('path')
+const { SitemapStream, streamToPromise } = require('sitemap')
+const { Readable } = require('stream')
const logger = require('./logger')()
/*
@@ -71,6 +73,23 @@ class ReadFile {
}
}
}
+ async Sitemap(x) {
+ const object = {
+ keys: x.keys,
+ links: [],
+ remove: ['/', '/blog'],
+ stream: new SitemapStream({hostname: x.url})
+ }
+
+ Array.from(object.remove).forEach(url => {
+ object.keys.splice(object.keys.indexOf(url), 1)
+ object.links.push({url: url, changefreq: 'daily', priority: 1})
+ })
+
+ object.keys.forEach(link => object.links.push({url: link, changefreq: 'weekly', priority: 0.8}))
+
+ return streamToPromise(Readable.from(object.links).pipe(object.stream)).then(data => {return data.toString()})
+ }
GetFile(x) {
const path = x.split('/')
const object = {