Add CMS service worker field
This commit is contained in:
parent
395c669ec0
commit
3f70d0b5f0
3 changed files with 11 additions and 3 deletions
|
|
@ -9,3 +9,4 @@ socialMediaCard:
|
|||
twitterSiteAccount: ''
|
||||
headerScripts: |-
|
||||
<!-- Add your analytics scripts / verification meta here -->
|
||||
enableServiceWorker: false
|
||||
|
|
|
|||
|
|
@ -103,3 +103,4 @@ collections: # A list of collections the CMS should be able to edit
|
|||
- {label: Twitter Site Account, name: twitterSiteAccount, widget: string, required: false}
|
||||
- {label: Twitter Creator Account, name: twitterCreatorAccount, widget: string, required: false}
|
||||
- {label: Header Meta / Scripts, name: headerScripts, widget: text, required: false}
|
||||
- {label: Enable Service Worker Pre-Cache, name: enableServiceWorker, widget: boolean, required: false}
|
||||
|
|
|
|||
12
src/index.js
12
src/index.js
|
|
@ -4,7 +4,8 @@ import { render } from 'react-snapshot'
|
|||
import 'normalize.css'
|
||||
import './globalStyles.css'
|
||||
import App from './App'
|
||||
import registerServiceWorker from './registerServiceWorker'
|
||||
import registerServiceWorker, { unregister } from './registerServiceWorker'
|
||||
import data from './data.json'
|
||||
|
||||
const rootEl = document.getElementById('root')
|
||||
render(<App />, rootEl)
|
||||
|
|
@ -16,8 +17,13 @@ if (module.hot) {
|
|||
})
|
||||
}
|
||||
|
||||
registerServiceWorker()
|
||||
|
||||
if (process.env.REACT_APP_SITE_URL && 'localStorage' in window) {
|
||||
window.localStorage.setItem('netlifySiteURL', process.env.REACT_APP_SITE_URL)
|
||||
}
|
||||
|
||||
const globalSettings =
|
||||
data.settings && data.settings.filter(doc => doc.name === 'global')[0]
|
||||
|
||||
if (globalSettings) {
|
||||
globalSettings.enableServiceWorker ? registerServiceWorker() : unregister()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue