Skip to content

Commit

Permalink
add sitemap generation (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
devarshishimpi authored Oct 14, 2022
2 parents 012767c + 5c311c1 commit 999f208
Show file tree
Hide file tree
Showing 4 changed files with 220 additions and 0 deletions.
180 changes: 180 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"@uiw/react-md-editor": "^3.18.1",
"aos": "^2.3.4",
"create-reactjs-component": "^1.0.7",
"express-sitemap-xml": "^3.0.1",
"marked": "^4.1.1",
"react": "^18.2.0",
"react-detect-click-outside": "^1.1.7",
Expand All @@ -29,6 +30,7 @@
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"prestart": "node scripts/generate-sitemap.js",
"eject": "react-scripts eject"
},
"eslintConfig": {
Expand Down
21 changes: 21 additions & 0 deletions frontend/public/sitemap.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://noteslify.stonecss.com/</loc>
</url>
<url>
<loc>https://noteslify.stonecss.com/login</loc>
</url>
<url>
<loc>https://noteslify.stonecss.com/signup</loc>
</url>
<url>
<loc>https://noteslify.stonecss.com/notes</loc>
</url>
<url>
<loc>https://noteslify.stonecss.com/contact</loc>
</url>
<url>
<loc>https://noteslify.stonecss.com/myaccount</loc>
</url>
</urlset>
17 changes: 17 additions & 0 deletions frontend/scripts/generate-sitemap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const fs = require('fs');
const { buildSitemaps } = require('express-sitemap-xml');
const SITE_URL = 'https://noteslify.stonecss.com';
// need to find a way to do it dynamically
const routesData = ['/', '/login', '/signup', '/notes', '/contact', '/myaccount'];

const getPages = () => {
return routesData;
}

(async () => {
const pages = getPages();
const sitemap = await buildSitemaps(pages, SITE_URL);

fs.writeFileSync('public/sitemap.xml', sitemap['/sitemap.xml']);
})();

0 comments on commit 999f208

Please sign in to comment.