Offline mode for developer guides

This commit is contained in:
Aaron Carlino 2019-11-14 16:09:30 +13:00
parent 680e657934
commit 9619bf4fd4
2 changed files with 8 additions and 5 deletions

View File

@ -65,9 +65,12 @@ module.exports = {
ignore: ['prismjs/','docsearch.js/', 'src/theme/assets/search/algolia.css'],
//purgeOnly : ['components/', '/main.css', 'bootstrap/'],
}
}
// this (optional) plugin enables Progressive Web App + Offline functionality
// To learn more, visit: https://gatsby.dev/offline
// `gatsby-plugin-offline`,
},
{
resolve: `gatsby-plugin-offline`,
options: {
precachePages: [`/en/4/developer_guides/*`],
},
}
],
}

View File

@ -8,7 +8,7 @@ exports.wrapPageElement = ({ element, props }) => {
exports.onRenderBody = ({ setPostBodyComponents }) => {
setPostBodyComponents([
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js" />,
<script dangerouslySetInnerHTML={{
process.env.NODE_ENV === 'production' && <script dangerouslySetInnerHTML={{
__html: `
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),