diff --git a/docs/src/components/CarbonAd/CarbonAd.js b/docs/src/components/CarbonAd/CarbonAd.js
index 90edf013cc..ca8af59fea 100644
--- a/docs/src/components/CarbonAd/CarbonAd.js
+++ b/docs/src/components/CarbonAd/CarbonAd.js
@@ -1,6 +1,8 @@
import _ from 'lodash'
import React, { Component } from 'react'
+import { isBrowser } from 'src/lib'
+
const style = {
padding: '0.5rem',
background: '#222',
@@ -8,16 +10,22 @@ const style = {
}
let isLoading = true
+let script
const adExist = () => !!document.querySelector('#docs-carbonads #carbonads')
-const script = document.createElement('script')
-script.async = true
-script.id = '_carbonads_js'
-script.type = 'text/javascript'
-script.src = '//cdn.carbonads.com/carbon.js?serve=CK7DT23J&placement=reactsemanticuicom'
-script.onload = () => {
- isLoading = false
+// Heads up!
+// We render docs with React-Static which performs SSR rendering.
+if (isBrowser()) {
+ script = document.createElement('script')
+
+ script.async = true
+ script.id = '_carbonads_js'
+ script.type = 'text/javascript'
+ script.src = '//cdn.carbonads.com/carbon.js?serve=CK7DT23J&placement=reactsemanticuicom'
+ script.onload = () => {
+ isLoading = false
+ }
}
const waitForLoad = () => {
diff --git a/docs/src/components/Document.js b/docs/src/components/Document.js
index 664c2945f3..f309152289 100644
--- a/docs/src/components/Document.js
+++ b/docs/src/components/Document.js
@@ -10,7 +10,7 @@ const Document = ({ Body, children, Head, Html, siteData: { dev, versions } }) =
-
+
{
- build().then(cb)
+ build({ staging: !!process.env.STAGING }).then(cb)
})
task('build:docs:static:reload', (cb) => {
diff --git a/gulpfile.js b/gulpfile.js
index 012ad88cfb..eb176fe70d 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -1,5 +1,5 @@
require('@babel/register')({
- ignore: [/node_modules/, /docs\/dist/],
+ ignore: [/node_modules/, /docs[\\/]dist/],
})
const { task, series, parallel } = require('gulp')
diff --git a/package.json b/package.json
index 294ea2b9ab..994cd7687b 100644
--- a/package.json
+++ b/package.json
@@ -15,7 +15,8 @@
"scripts": {
"build": "cross-env NODE_ENV=production gulp build",
"build:changelog": "github_changelog_generator --no-issues --no-unreleased --release-branch master --since-tag $(git describe --abbrev=0 --tags $(git rev-parse HEAD~300))",
- "build:docs": "gulp --series build:docs",
+ "build:docs": "cross-env NODE_ENV=production gulp build:docs",
+ "build:docs:staging": "cross-env STAGING=true yarn build:docs && yarn serve docs/dist",
"build:dist": "gulp --series build:dist",
"ci": "yarn tsd:lint && yarn tsd:test && yarn lint && yarn test",
"predeploy:docs": "cross-env NODE_ENV=production yarn build:docs && gulp build:docs:cname",