fix sitemap

This commit is contained in:
Anton Maisak 2021-06-09 17:38:05 +03:00
parent 481ac067f2
commit 2c80a78cf1
2 changed files with 1042 additions and 1392 deletions

File diff suppressed because it is too large Load Diff

View File

@ -53,26 +53,22 @@ Date.prototype.toW3CString = function () {
offsetSign + offsetHours + ':' + offsetMinutes; offsetSign + offsetHours + ':' + offsetMinutes;
} }
const dataItems = []; let dataItems = [];
dataItems.push(` dataItems.push(`<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">`);
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
`);
require('fs').readFileSync('docs/_sidebar.md', 'utf-8').split(/\r?\n/).forEach(function (line) { require('fs').readFileSync('docs/_sidebar.md', 'utf-8').split(/\r?\n/).forEach(function (line) {
const data = line.split(']')[1]; const data = line.split(']')[1];
if (data) { if (data) {
const result = data.replace('(', '').replace(')', ''); const result = data.replace('(', '').replace(')', '');
const url = `${urlBase}${result}`; const url = `${urlBase}${result}`;
const urlItem = ` const urlItem = `<url>
<url>
<loc>${url}</loc> <loc>${url}</loc>
<lastmod>${new Date().toW3CString()}</lastmod> <lastmod>${new Date().toW3CString()}</lastmod>
<changefreq>monthly</changefreq> <changefreq>monthly</changefreq>
<priority>0.25</priority> <priority>0.25</priority>
</url> </url>`;
`;
console.log(urlItem); console.log(urlItem);
dataItems.push(urlItem); dataItems.push(urlItem);
} }