From 426c227a804298b713c6cd2d1b90e41fac425256 Mon Sep 17 00:00:00 2001 From: Azam khan Date: Fri, 4 Apr 2025 13:15:47 +0530 Subject: [PATCH] dynamic seo and pages --- README.md | 18 ++++- package.json | 10 ++- public/robots.txt | 3 + scripts/generateSitemap.js | 24 ++++++ src/App.js | 16 +++- src/components/DealsSection.js | 29 +++++++ src/components/DestinationsSection.js | 0 src/components/Footer.js | 4 +- src/components/HeroSection.js | 16 ++++ src/components/HotelsSection.js | 30 +++++++ src/components/Navbar.js | 31 ++++++-- src/components/TrendingSearches.js | 0 src/pages/Flights.js | 82 +++++++++++++++---- src/pages/FlightsResults.js | 54 +++++++++++++ src/pages/Home.js | 110 ++++++++++++++++++++++++-- src/pages/Hotels.js | 15 ++-- src/pages/Packages.js | 15 ++-- 17 files changed, 411 insertions(+), 46 deletions(-) create mode 100644 public/robots.txt create mode 100644 scripts/generateSitemap.js create mode 100644 src/components/DealsSection.js create mode 100644 src/components/DestinationsSection.js create mode 100644 src/components/HeroSection.js create mode 100644 src/components/HotelsSection.js create mode 100644 src/components/TrendingSearches.js create mode 100644 src/pages/FlightsResults.js diff --git a/README.md b/README.md index 0ccb02e..4341f09 100644 --- a/README.md +++ b/README.md @@ -1 +1,17 @@ -React js b2c application initial \ No newline at end of file +React js b2c application initial + +/src + ├── /components + │ ├── Navbar.js + │ ├── HeroSection.js + │ ├── DealsSection.js + │ ├── HotelsSection.js + │ ├── DestinationsSection.js + │ ├── TrendingSearches.js + │ ├── Footer.js + ├── /pages + │ ├── Home.js + ├── /config + │ ├── api.js (for Sabre API calls) + ├── App.js + ├── index.js \ No newline at end of file diff --git a/package.json b/package.json index 3ce8873..1348d06 100644 --- a/package.json +++ b/package.json @@ -5,10 +5,11 @@ "description": "React js b2c application initial", "main": "index.js", "scripts": { - "start": "PORT=8080 react-scripts start", + "dev": "PORT=8080 react-scripts start", "build": "react-scripts build", "test": "react-scripts test", - "eject": "react-scripts eject" + "eject": "react-scripts eject", + "generate-sitemap": "node scripts/generateSitemap.js" }, "repository": { "type": "git", @@ -20,10 +21,13 @@ "dependencies": { "axios": "^1.8.4", "bootstrap": "^5.3.3", + "fs": "^0.0.1-security", "react": "^19.1.0", "react-dom": "^19.1.0", + "react-helmet": "^6.1.0", "react-router-dom": "^7.4.1", - "react-scripts": "^5.0.1" + "react-scripts": "^5.0.1", + "sitemap": "^8.0.0" }, "browserslist": { "production": [ diff --git a/public/robots.txt b/public/robots.txt new file mode 100644 index 0000000..4cec90c --- /dev/null +++ b/public/robots.txt @@ -0,0 +1,3 @@ +User-agent: * +Allow: / +Sitemap: https://www.uat.hlafly.com/sitemap.xml diff --git a/scripts/generateSitemap.js b/scripts/generateSitemap.js new file mode 100644 index 0000000..9490029 --- /dev/null +++ b/scripts/generateSitemap.js @@ -0,0 +1,24 @@ +import { createWriteStream } from "fs"; +import { SitemapStream, streamToPromise } from "sitemap"; + +const generateSitemap = async () => { + const sitemap = new SitemapStream({ hostname: "https://www.hlafly.com" }); + + const pages = [ + { url: "/", changefreq: "daily", priority: 1.0 }, + { url: "/flights", changefreq: "weekly", priority: 0.8 }, + { url: "/hotels", changefreq: "weekly", priority: 0.8 }, + { url: "/packages", changefreq: "weekly", priority: 0.7 }, + ]; + + const writeStream = createWriteStream("public/sitemap.xml"); + sitemap.pipe(writeStream); + + pages.forEach((page) => sitemap.write(page)); + sitemap.end(); + + await streamToPromise(sitemap); + console.log("✅ Sitemap successfully generated!"); +}; + +generateSitemap(); diff --git a/src/App.js b/src/App.js index 1eb4e6c..9a23a6e 100644 --- a/src/App.js +++ b/src/App.js @@ -8,15 +8,22 @@ import Hotels from "./pages/Hotels.js"; import Packages from "./pages/Packages.js"; import Navbar from "./components/Navbar.js"; import Footer from "./components/Footer.js"; +import FlightsResults from "./pages/FlightsResults.js"; // results page + function App() { return ( <> - Chalpado - Best Travel Deals - + hlafly - Best Travel Deals + + + + + +
@@ -25,11 +32,12 @@ function App() { } /> } /> } /> + } />