feat: provide sitemap

closes #287
This commit is contained in:
Danny Koppenhagen
2023-01-07 15:21:53 +01:00
committed by Bastian
parent 9a8bb235a4
commit caff3640a2
5 changed files with 271 additions and 5 deletions

View File

@@ -36,8 +36,12 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var fs_1 = require("fs");
var xml_sitemap_1 = __importDefault(require("xml-sitemap"));
var radar_1 = require("./generateJson/radar");
// Do this as the first thing so that any code reading it knows the right env.
process.env.BABEL_ENV = "production";
@@ -49,7 +53,7 @@ process.on("unhandledRejection", function (err) {
throw err;
});
var createStaticFiles = function () { return __awaiter(void 0, void 0, void 0, function () {
var radar, rawConf, config;
var radar, rawConf, config, sitemap;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
@@ -68,9 +72,15 @@ var createStaticFiles = function () { return __awaiter(void 0, void 0, void 0, f
(0, fs_1.mkdirSync)(destFolder);
}
});
sitemap = new xml_sitemap_1.default();
radar.items.forEach(function (item) {
(0, fs_1.copyFileSync)("build/index.html", "build/".concat(item.quadrant, "/").concat(item.name, ".html"));
sitemap.add("".concat(process.env.PUBLIC_URL, "/").concat(item.quadrant, "/").concat(item.name, ".html"), {
lastmod: 'now',
changefreq: 'weekly'
});
});
(0, fs_1.writeFileSync)("build/sitemap.xml", sitemap.xml);
return [2 /*return*/];
}
});