Skip to content

Commit

Permalink
fix(netlify): adds right example how to use with Netlify (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdreizin committed Apr 22, 2018
1 parent 0d1c2a4 commit 98d88c9
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions README.md
Expand Up @@ -55,19 +55,29 @@ If you would like to disable crawlers for [deploy-previews](https://www.netlify.
`gatsby-config.js`

```js
const sitePreviewUrl = process.env.DEPLOY_PRIME_URL;
const {
NODE_ENV,
URL: NETLIFY_SITE_URL = 'https://www.example.com',
DEPLOY_PRIME_URL: NETLIFY_DEPLOY_URL = NETLIFY_SITE_URL,
CONTEXT: NETLIFY_ENV = NODE_ENV
} = process.env;
const isNetlifyProduction = NETLIFY_ENV === 'production';
const siteUrl = isNetlifyProduction ? NETLIFY_SITE_URL : NETLIFY_DEPLOY_URL;

module.exports = {
siteMetadata: {
siteUrl: 'https://www.example.com'
siteUrl
},
plugins: [
{
resolve: 'gatsby-plugin-robots-txt',
options:
typeof sitePreviewUrl !== 'undefined'
? { policy: [{ userAgent: '*', disallow: ['/'] }] }
: { policy: [{ userAgent: '*' }] }
options: isNetlifyProduction
? { policy: [{ userAgent: '*' }] }
: {
policy: [{ userAgent: '*', disallow: ['/'] }],
sitemap: null,
host: null
}
}
]
};
Expand Down

0 comments on commit 98d88c9

Please sign in to comment.