-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #101 from sgcarstrends/100-allowdisallow-indexing-…
…based-on-app-environment Allow/disallow indexing based on app environment
- Loading branch information
Showing
4 changed files
with
29 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,22 @@ | ||
import { SITE_URL } from "@/config"; | ||
import { APP_ENV, SITE_URL } from "@/config"; | ||
import { AppEnv } from "@/types"; | ||
import type { MetadataRoute } from "next"; | ||
|
||
const robots = (): MetadataRoute.Robots => ({ | ||
rules: { | ||
userAgent: "*", | ||
allow: "/", | ||
}, | ||
sitemap: `${SITE_URL}/sitemap.xml/`, | ||
}); | ||
const robots = (): MetadataRoute.Robots => { | ||
// Set the default rule | ||
let rules: MetadataRoute.Robots["rules"] = { userAgent: "*" }; | ||
|
||
// Allow or disallow indexing based on app environment | ||
if (APP_ENV === AppEnv.PROD) { | ||
rules = { ...rules, allow: "/" }; | ||
} else { | ||
rules = { ...rules, disallow: "/" }; | ||
} | ||
|
||
return { | ||
rules, | ||
sitemap: `${SITE_URL}/sitemap.xml`, | ||
}; | ||
}; | ||
|
||
export default robots; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters