From daf9f6db16f49b4c63c30e09ceb8e8b0b3290b30 Mon Sep 17 00:00:00 2001 From: shabarish-testsigma <83057054+shabarish-testsigma@users.noreply.github.com> Date: Wed, 11 Jan 2023 18:43:40 +0530 Subject: [PATCH 1/3] Update page.jsx --- src/templates/page.jsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/templates/page.jsx b/src/templates/page.jsx index fb7d190..2301803 100644 --- a/src/templates/page.jsx +++ b/src/templates/page.jsx @@ -35,6 +35,10 @@ export default ({ data, pageContext }) => { contextualLinks = ; } + if(window.location.hostname=="website.testsigma.com") { + post.frontmatter.noindex = false; + } + return ( Date: Wed, 11 Jan 2023 18:49:46 +0530 Subject: [PATCH 2/3] Add noIndex true --- src/templates/page.jsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/templates/page.jsx b/src/templates/page.jsx index 2301803..e39f999 100644 --- a/src/templates/page.jsx +++ b/src/templates/page.jsx @@ -35,8 +35,10 @@ export default ({ data, pageContext }) => { contextualLinks = ; } - if(window.location.hostname=="website.testsigma.com") { - post.frontmatter.noindex = false; + const isBrowser = () => typeof window !== "undefined" + + if(isBrowser() && window.location.hostname=="website.testsigma.com") { + post.frontmatter.noindex = true; } return ( From f49b4a365157876067a1bb7d9ab101fd8adff260 Mon Sep 17 00:00:00 2001 From: shabarish-testsigma Date: Fri, 13 Jan 2023 15:51:29 +0530 Subject: [PATCH 3/3] environment check --- .github/workflows/staging-cd.yml | 2 ++ src/environment.ts | 6 ++++++ src/templates/page.jsx | 5 ++--- 3 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 src/environment.ts diff --git a/.github/workflows/staging-cd.yml b/.github/workflows/staging-cd.yml index 8d3a829..893ef4d 100644 --- a/.github/workflows/staging-cd.yml +++ b/.github/workflows/staging-cd.yml @@ -33,6 +33,8 @@ jobs: echo GTAG_TRACKING_ID_FOR_GA4=${{ secrets.STAGING_GTAG_TRACKING_ID_FOR_GA4 }} >> .env echo GTAG_TRACKING_ID_FOR_GTAG=${{ secrets.STAGING_GTAG_TRACKING_ID_FOR_GTAG }} >> .env cat .env + - name: Set environment + run : sed -i 's/localhost/website.testsigma.com/g' src/environment.ts - name: Build run: | PREFIX_PATHS=true npm run build && npm run deploy diff --git a/src/environment.ts b/src/environment.ts new file mode 100644 index 0000000..c6b178c --- /dev/null +++ b/src/environment.ts @@ -0,0 +1,6 @@ +export const environment = { + hostname: "localhost", + isStaging() { + return this.hostname == "website.testsigma.com"; + } +} \ No newline at end of file diff --git a/src/templates/page.jsx b/src/templates/page.jsx index e39f999..70b1410 100644 --- a/src/templates/page.jsx +++ b/src/templates/page.jsx @@ -12,6 +12,7 @@ import {Link} from "../../.cache/gatsby-browser-entry"; import SearchInputBox from "../components/SearchInputBox"; import MobileView from "../components/MobileView"; import Footer from "../components/Footer" +import {environment} from "../environment"; export default ({ data, pageContext }) => { @@ -35,9 +36,7 @@ export default ({ data, pageContext }) => { contextualLinks = ; } - const isBrowser = () => typeof window !== "undefined" - - if(isBrowser() && window.location.hostname=="website.testsigma.com") { + if(environment.isStaging()) { post.frontmatter.noindex = true; }