summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorMhykol <mchaeldonald62@pm.me>2024-10-13 02:51:51 -0400
committerMhykol <mchaeldonald62@pm.me>2024-10-13 02:51:51 -0400
commit611aa084110b24dc00757bc02f647f1675df8dda (patch)
treefa34014f84210a33727d06f6d108084518345e41 /source
parente8996373a6dad0bdd6fc6926386b4262730ac279 (diff)
Added sitemap
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 = {