Skip to content

Commit

Permalink
generate site map
Browse files Browse the repository at this point in the history
  • Loading branch information
nyagami committed Jun 23, 2024
1 parent 2dae3a9 commit 878ee21
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions generateRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import path from "path";
import fs from "fs";

const indexPage = fs.readFileSync("./dist/index.html", "utf-8");
const BASE_URL = "https://lnreader.github.io/";
let siteMapContent = "";
for (const route of routes) {
const routePage = indexPage
.replace(/<title>.+<\/title>/, `<title>${route.title}</title>`)
Expand All @@ -16,4 +18,6 @@ for (const route of routes) {
fs.mkdirSync(dir, { recursive: true });
}
fs.writeFileSync(filePath, routePage, "utf-8");
siteMapContent += `${BASE_URL}${route.path}\n`;
}
fs.writeFileSync("./dist/sitemap.txt", siteMapContent, "utf-8");

0 comments on commit 878ee21

Please sign in to comment.