Skip to content

Commit

Permalink
Merge pull request #849 from prezly/feature/care-2257-sonys-press-cen…
Browse files Browse the repository at this point in the history
…tre-landing-pages-set-to-noindexnofollow-so

[CARE-2257] Disable indexing for Vercel deployments
  • Loading branch information
kudlajz authored Aug 16, 2023
2 parents d614b3e + 508d8da commit 75002a7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
9 changes: 5 additions & 4 deletions modules/Layout/Layout.tsx
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -34,12 +34,13 @@ const CookieConsentBar = dynamic(() => import('./CookieConsentBar'), {
ssr: false,
});

const noIndex = process.env.VERCEL === '1';

function Layout({ children, description, imageUrl, title, hasError }: PropsWithChildren<Props>) {
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/');
Expand Down Expand Up @@ -88,11 +89,11 @@ function Layout({ children, description, imageUrl, title, hasError }: PropsWithC
<Analytics />
<Branding newsroom={newsroom} />
<PageSeo
noindex={noIndex}
nofollow={noIndex}
title={title}
description={description}
imageUrl={imageUrl}
noindex={!isAnalyticsEnabled}
nofollow={!isAnalyticsEnabled}
/>
<NotificationsBar notifications={displayedNotifications} />
<CookieConsentBar />
Expand Down
6 changes: 3 additions & 3 deletions modules/Story/Story.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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;
Expand All @@ -36,7 +36,7 @@ function Story({ story }: Props) {

return (
<Layout>
<StorySeo story={story} noindex={!isAnalyticsEnabled} />
<StorySeo story={story} noindex={noIndex} />
<article className={styles.story}>
<div className={styles.container}>
{isEmbargoStory(story) && <Embargo story={story} />}
Expand Down

3 comments on commit 75002a7

@vercel
Copy link

@vercel vercel bot commented on 75002a7 Aug 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 75002a7 Aug 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 75002a7 Aug 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.