diff --git a/frontend/generate-sitemap.js b/frontend/generate-sitemap.js new file mode 100644 index 0000000..71f7c52 --- /dev/null +++ b/frontend/generate-sitemap.js @@ -0,0 +1,27 @@ +import { SitemapStream, streamToPromise } from 'sitemap'; +import { createWriteStream } from 'fs'; +import { fileURLToPath } from 'url'; +import path from 'path'; + +// Create __dirname for ES modules +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); + +// Resolve the path to sitemap.xml +const sitemapPath = path.resolve(__dirname, 'public', 'sitemap.xml'); + +const sitemap = new SitemapStream({ hostname: 'https://capusify.site' }); + +const links = [ + { url: '/', changefreq: 'daily', priority: 1.0 }, + { url: '/about', changefreq: 'weekly', priority: 0.8 }, + { url: '/contact', changefreq: 'monthly', priority: 0.5 } +]; + +links.forEach(link => sitemap.write(link)); +sitemap.end(); + +// Create the sitemap and handle errors +streamToPromise(sitemap.pipe(createWriteStream(sitemapPath))) + .then(() => console.log('Sitemap created successfully!')) + .catch(err => console.error('Error generating sitemap:', err)); diff --git a/frontend/index.html b/frontend/index.html index 472277a..bf89e78 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -5,6 +5,32 @@ Campus Chatter + + + + + + + + + + + +
diff --git a/frontend/package.json b/frontend/package.json index bbe8e5e..33b6659 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -7,7 +7,8 @@ "dev": "vite", "build": "vite build", "lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0", - "preview": "vite preview" + "preview": "vite preview", + "generate-sitemap": "node generate-sitemap.js" }, "dependencies": { "@chakra-ui/react": "^2.8.2", @@ -21,11 +22,13 @@ "react": "^18.3.1", "react-autosuggest": "^10.1.0", "react-dom": "^18.3.1", + "react-helmet-async": "^2.0.5", "react-icons": "^5.3.0", "react-infinite-scroll-component": "^6.1.0", "react-loader-spinner": "^6.1.6", "react-router-dom": "^6.26.2", "react-use-websocket": "^4.8.1", + "sitemap": "^8.0.0", "zod": "^3.23.8" }, "devDependencies": { diff --git a/frontend/public/404.png b/frontend/public/404.png old mode 100644 new mode 100755 diff --git a/frontend/public/logo.png b/frontend/public/logo.png old mode 100644 new mode 100755 diff --git a/frontend/src/robots.txt b/frontend/public/sitemap.xml old mode 100644 new mode 100755 similarity index 100% rename from frontend/src/robots.txt rename to frontend/public/sitemap.xml diff --git a/frontend/public/vite.svg b/frontend/public/vite.svg old mode 100644 new mode 100755 diff --git a/frontend/robots.txt b/frontend/robots.txt new file mode 100755 index 0000000..c5d5e26 --- /dev/null +++ b/frontend/robots.txt @@ -0,0 +1,4 @@ +User-agent: * +Disallow: + +Sitemap: https://capusify.site/sitemap.xml \ No newline at end of file diff --git a/frontend/src/components/homePage/HomePage.jsx b/frontend/src/components/homePage/HomePage.jsx index 0fd8985..bc93b5d 100644 --- a/frontend/src/components/homePage/HomePage.jsx +++ b/frontend/src/components/homePage/HomePage.jsx @@ -49,6 +49,23 @@ export const Header = () => { return (
+ + +