Skip to content

Commit 0980f0e

Browse files
committed
added production check & robots rules
1 parent 2df55a6 commit 0980f0e

File tree

5 files changed

+17
-0
lines changed

5 files changed

+17
-0
lines changed

Diff for: .changeset/twelve-bugs-develop.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'tiptap-docs': patch
3+
---
4+
5+
Added production check to disallow robots on non-production pages

Diff for: .env.example

+1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ NEXT_PUBLIC_DEMO_URL_PRO="https://embed-pro.tiptap.dev/preview"
1111
NEXT_PUBLIC_BASE_PATH=""
1212
NEXT_PUBLIC_DOMAIN=""
1313
NEXT_PUBLIC_GTM_ID=""
14+
NEXT_PUBLIC_ENVIRONMENT="development"
1415

1516
BASE_PATH=""

Diff for: src/server/createMetadata.ts

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Metadata } from 'next'
22
import { FULL_DOMAIN } from '@/utils/constants'
3+
import { isProductionSite } from '@/utils/isProductionSite'
34

45
export async function createMetadata({
56
title,
@@ -17,6 +18,7 @@ export async function createMetadata({
1718
return {
1819
title,
1920
description,
21+
robots: isProductionSite() ? 'index, follow' : 'noindex, nofollow',
2022
openGraph: {
2123
title,
2224
description,

Diff for: src/utils/constants.ts

+1
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ export const DOMAIN = process.env.NEXT_PUBLIC_DOMAIN || 'http://localhost:3000'
88
export const FULL_DOMAIN = `${DOMAIN}${BASE_PATH}`
99

1010
export const GTM_ID = process.env.NEXT_PUBLIC_GTM_ID || null
11+
export const ENVIRONMENT = process.env.NEXT_PUBLIC_ENVIRONMENT || 'development'

Diff for: src/utils/isProductionSite.ts

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { ENVIRONMENT } from './constants'
2+
/**
3+
* Checks if the site is in production
4+
* @returns boolean
5+
*/
6+
export const isProductionSite = () => {
7+
return ENVIRONMENT === 'production'
8+
}

0 commit comments

Comments
 (0)