From 631d4a893cf17fed55fcb8984c6dace966a1f834 Mon Sep 17 00:00:00 2001 From: kudlajz Date: Wed, 16 Aug 2023 10:42:21 +0200 Subject: [PATCH 1/3] Disable indexing in non-production environment --- modules/Layout/Layout.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/Layout/Layout.tsx b/modules/Layout/Layout.tsx index b7fa7a2fb..14e05c953 100644 --- a/modules/Layout/Layout.tsx +++ b/modules/Layout/Layout.tsx @@ -1,4 +1,4 @@ -import { Analytics, useAnalyticsContext } from '@prezly/analytics-nextjs'; +import { Analytics } from '@prezly/analytics-nextjs'; import { Notification, Story } from '@prezly/sdk'; import { PageSeo, @@ -34,12 +34,13 @@ const CookieConsentBar = dynamic(() => import('./CookieConsentBar'), { ssr: false, }); +const isProduction = process.env.NODE_ENV === 'production'; + function Layout({ children, description, imageUrl, title, hasError }: PropsWithChildren) { const [isLoadingPage, setIsLoadingPage] = useState(false); const newsroom = useNewsroom(); const story = useCurrentStory(); const { contacts, notifications } = useNewsroomContext(); - const { isEnabled: isAnalyticsEnabled } = useAnalyticsContext(); const { query, pathname } = useRouter(); const isSecretUrl = pathname.startsWith('/s/'); @@ -91,8 +92,8 @@ function Layout({ children, description, imageUrl, title, hasError }: PropsWithC title={title} description={description} imageUrl={imageUrl} - noindex={!isAnalyticsEnabled} - nofollow={!isAnalyticsEnabled} + noindex={!isProduction} + nofollow={!isProduction} /> From 58dd7117d5b0a7cc6d384389eacafe6db8cd3a3b Mon Sep 17 00:00:00 2001 From: kudlajz Date: Wed, 16 Aug 2023 10:53:19 +0200 Subject: [PATCH 2/3] Let PageSeo decide on indexing --- modules/Layout/Layout.tsx | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/modules/Layout/Layout.tsx b/modules/Layout/Layout.tsx index 14e05c953..063b86dff 100644 --- a/modules/Layout/Layout.tsx +++ b/modules/Layout/Layout.tsx @@ -34,8 +34,6 @@ const CookieConsentBar = dynamic(() => import('./CookieConsentBar'), { ssr: false, }); -const isProduction = process.env.NODE_ENV === 'production'; - function Layout({ children, description, imageUrl, title, hasError }: PropsWithChildren) { const [isLoadingPage, setIsLoadingPage] = useState(false); const newsroom = useNewsroom(); @@ -88,13 +86,7 @@ function Layout({ children, description, imageUrl, title, hasError }: PropsWithC <> - +
From 508d8da69e51168127e9ddbe23af4a17c4041f85 Mon Sep 17 00:00:00 2001 From: kudlajz Date: Wed, 16 Aug 2023 11:00:00 +0200 Subject: [PATCH 3/3] Do not index the site if deployed on Vercel --- modules/Layout/Layout.tsx | 10 +++++++++- modules/Story/Story.tsx | 6 +++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/modules/Layout/Layout.tsx b/modules/Layout/Layout.tsx index 063b86dff..f936cfd34 100644 --- a/modules/Layout/Layout.tsx +++ b/modules/Layout/Layout.tsx @@ -34,6 +34,8 @@ const CookieConsentBar = dynamic(() => import('./CookieConsentBar'), { ssr: false, }); +const noIndex = process.env.VERCEL === '1'; + function Layout({ children, description, imageUrl, title, hasError }: PropsWithChildren) { const [isLoadingPage, setIsLoadingPage] = useState(false); const newsroom = useNewsroom(); @@ -86,7 +88,13 @@ function Layout({ children, description, imageUrl, title, hasError }: PropsWithC <> - +
diff --git a/modules/Story/Story.tsx b/modules/Story/Story.tsx index 66f451477..c0d0533cd 100644 --- a/modules/Story/Story.tsx +++ b/modules/Story/Story.tsx @@ -1,4 +1,3 @@ -import { useAnalyticsContext } from '@prezly/analytics-nextjs'; import type { ExtendedStory } from '@prezly/sdk'; import { isEmbargoStory } from '@prezly/theme-kit-core'; import { StorySeo } from '@prezly/theme-kit-nextjs'; @@ -22,9 +21,10 @@ type Props = { story: ExtendedStory; }; +const noIndex = process.env.VERCEL === '1'; + function Story({ story }: Props) { const { showDate } = useThemeSettings(); - const { isEnabled: isAnalyticsEnabled } = useAnalyticsContext(); if (!story) { return null; @@ -36,7 +36,7 @@ function Story({ story }: Props) { return ( - +
{isEmbargoStory(story) && }