feat: added sitemap again, fixed #59 also

This commit is contained in:
Raj Nandan Sharma
2024-11-15 22:52:36 +05:30
parent 28184d2a52
commit 1b8e05ad1f
7 changed files with 76 additions and 3 deletions

View File

@@ -44,6 +44,7 @@ COPY --from=base /usr/local/lib /usr/local/lib
COPY --chown=abc:abc static /app/static
COPY --chown=abc:abc database /app/database
COPY --chown=abc:abc build.js /app/build.js
COPY --chown=abc:abc sitemap.js /app/sitemap.js
COPY --chown=abc:abc src/lib/server /app/src/lib/server
COPY --chown=abc:abc src/lib/helpers.js /app/src/lib/helpers.js

View File

@@ -249,7 +249,7 @@ async function Build() {
}
if (site.github.incidentSince === undefined || site.github.incidentSince === null) {
site.github.incidentSince = 48;
site.github.incidentSince = 720;
}
if (!!site.analytics) {
const providers = {};

View File

@@ -2,6 +2,7 @@ title: "Kener - Open-Source and Modern looking Node.js Status Page for Effortles
siteName: "Kener.ing"
home: "/"
logo: "/logo.png"
siteURL: "https://kener.ing"
favicon: "/logo96.png"
github:
owner: "rajnandan1"

View File

@@ -327,3 +327,11 @@ analytics:
- id: "FKOdsKener"
type: "MIXPANEL"
```
## siteURL
This is required for sitemap generation
```yaml
siteURL: https://kener.ing
```

View File

@@ -26,9 +26,13 @@ description: Kener is an open-source Node.js status page tool, designed to make
#### 👉 Quick Start [here](/docs/quick-start)
Kener: Open-source Node.js status page tool, designed to make service monitoring and incident handling a breeze. It offers a sleek and user-friendly interface that simplifies tracking service outages and improves how we communicate during incidents. And the best part? Kener integrates seamlessly with GitHub, making incident management a team effort—making it easier for us to track and fix issues together in a collaborative and friendly environment.
## What is Kener?
It uses files to store the data. Other adapters are coming soon
Kener: Open-source sveltekit status page tool, designed to make service monitoring and incident handling a breeze. It offers a sleek and user-friendly interface that simplifies tracking service outages and improves how we communicate during incidents. Kener integrates seamlessly with GitHub, making incident management a team effort—making.
It uses files to store the data.
Kener name is derived from the word "Kene" which means "how is it going" in Assamese, then .ing is added to make cooler.
## Features

14
main.js
View File

@@ -2,9 +2,23 @@ import { handler } from "./build/handler.js";
import dotenv from "dotenv";
dotenv.config();
import express from "express";
import sitemap from "./sitemap.js";
const PORT = process.env.PORT || 3000;
const app = express();
app.use((req, res, next) => {
if (req.path.startsWith("/embed")) {
res.setHeader("Content-Security-Policy", "frame-ancestors *");
}
next();
});
app.get("/healthcheck", (req, res) => {
res.end("ok");
});
app.get("/sitemap.xml", (req, res) => {
res.setHeader("Content-Type", "application/xml");
res.end(sitemap);
});
app.use(handler);
app.listen(PORT, () => {

45
sitemap.js Normal file
View File

@@ -0,0 +1,45 @@
//read from process.env.PUBLIC_KENER_FOLDER / site.json
//read from process.env.PUBLIC_KENER_FOLDER / monitors.json
// create sitemap.xml
import fs from "fs-extra";
let siteMap = "";
import dotenv from "dotenv";
dotenv.config();
const site = fs.readJSONSync("./database/site.json", "utf8");
const monitors = fs.readJSONSync("./database/monitors.json", "utf8");
if (site.siteURL !== undefined && site.siteURL !== null && site.siteURL !== "") {
if (monitors.length > 0) {
siteMap = `<?xml version="1.0" encoding="UTF-8"?>
<urlset
xmlns="https://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://www.sitemaps.org/schemas/sitemap/0.9
https://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
${monitors
.map((monitor) => {
return `
<url>
<loc>${site.siteURL}/incident/${monitor.folderName}</loc>
<lastmod>${new Date().toISOString()}</lastmod>
<changefreq>daily</changefreq>
<priority>0.8</priority>
</url>`;
})
.join("\n")}
${monitors
.map((monitor) => {
return `
<url>
<loc>${site.siteURL}/monitor-${encodeURIComponent(monitor.tag)}</loc>
<lastmod>${new Date().toISOString()}</lastmod>
<changefreq>daily</changefreq>
<priority>0.8</priority>
</url>`;
})
.join("\n")}
</urlset>`;
}
}
//export default siteMap
export default siteMap;