Skip to content

Commit

Permalink
added production check & robots rules
Browse files Browse the repository at this point in the history
  • Loading branch information
bdbch committed Jun 27, 2024
1 parent 2df55a6 commit 0980f0e
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/twelve-bugs-develop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'tiptap-docs': patch
---

Added production check to disallow robots on non-production pages
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ NEXT_PUBLIC_DEMO_URL_PRO="https://embed-pro.tiptap.dev/preview"
NEXT_PUBLIC_BASE_PATH=""
NEXT_PUBLIC_DOMAIN=""
NEXT_PUBLIC_GTM_ID=""
NEXT_PUBLIC_ENVIRONMENT="development"

BASE_PATH=""
2 changes: 2 additions & 0 deletions src/server/createMetadata.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Metadata } from 'next'
import { FULL_DOMAIN } from '@/utils/constants'
import { isProductionSite } from '@/utils/isProductionSite'

export async function createMetadata({
title,
Expand All @@ -17,6 +18,7 @@ export async function createMetadata({
return {
title,
description,
robots: isProductionSite() ? 'index, follow' : 'noindex, nofollow',
openGraph: {
title,
description,
Expand Down
1 change: 1 addition & 0 deletions src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ export const DOMAIN = process.env.NEXT_PUBLIC_DOMAIN || 'http://localhost:3000'
export const FULL_DOMAIN = `${DOMAIN}${BASE_PATH}`

export const GTM_ID = process.env.NEXT_PUBLIC_GTM_ID || null
export const ENVIRONMENT = process.env.NEXT_PUBLIC_ENVIRONMENT || 'development'
8 changes: 8 additions & 0 deletions src/utils/isProductionSite.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { ENVIRONMENT } from './constants'
/**
* Checks if the site is in production
* @returns boolean
*/
export const isProductionSite = () => {
return ENVIRONMENT === 'production'
}

0 comments on commit 0980f0e

Please sign in to comment.