Skip to content

Commit 9340808

Browse files
te-sitemap.js
1 parent d5beaa1 commit 9340808

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

.github/workflows/actions.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ jobs:
2525
- name: Install Dependencies
2626
run: npm i
2727

28+
- name: Generate Sitemap
29+
run: node generate-sitemap.js
30+
2831
- name: Deploy with gh-pages
2932
run: |
3033
git config --global user.name $user_name

generate-sitemap.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const fs = require("fs");
2+
const path = require("path");
3+
4+
const urls = ["https://vrushabhgawas14.github.io/"];
5+
6+
// current timestamp in ISO 8601 format
7+
const now = new Date().toISOString();
8+
9+
const sitemap = `<?xml version="1.0" encoding="UTF-8"?>
10+
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
11+
${urls
12+
.map(
13+
(url) => `
14+
<url>
15+
<loc>${url}</loc>
16+
<lastmod>${now}</lastmod>
17+
</url>`
18+
)
19+
.join("")}
20+
</urlset>`;
21+
22+
const sitemapPath = path.join(__dirname, "public", "sitemap.xml");
23+
fs.writeFileSync(sitemapPath, sitemap, "utf8");

0 commit comments

Comments
 (0)