File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change 25
25
- name : Install Dependencies
26
26
run : npm i
27
27
28
+ - name : Generate Sitemap
29
+ run : node generate-sitemap.js
30
+
28
31
- name : Deploy with gh-pages
29
32
run : |
30
33
git config --global user.name $user_name
Original file line number Diff line number Diff line change
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" ) ;
You can’t perform that action at this time.
0 commit comments