Comments (9)
I've fixed the issue btw. Have to load jekyll-pwa-plugin.rb
locally and replace lines from 134 to 144.
I m using amplify
from jekyll-pwa.
@kalwalt here is what i did for my site.
- First of all include the following code before
</head>
of your theme/ template if it's already not there. See amp referencec.
<script async custom-element="amp-install-serviceworker" src="https://cdn.ampproject.org/v0/amp-install-serviceworker-0.1.js"></script>
- Now install
jekyll-pwa
plugin manually, choose option 1 - Docs. - Modify the jekyll-pwa-plugin.rb file and replace
<script> tag
from L134 to L144 with the following amp snippet.
<amp-install-serviceworker src="https://sam.azgor.com/sw-register.js" layout="nodisplay"></amp-install-serviceworker>
dont forget to replace sam.azgor.com
with your actual domain name.
from jekyll-pwa.
@kalwalt create a folder on the root and name it _plugins
. Now copy your ruby file into that folder. See this
from jekyll-pwa.
May I ask how do you generate your AMP pages?
Using some Jekyll plugins like amp-jekyll?
from jekyll-pwa.
What L134-144
do is simply appending service worker registration code to <body>
.
So maybe I should not hard code the inject point like this.
from jekyll-pwa.
Hi @xiaoiver @samazgor i'm using the plugin with amp but i need also to modify the lines from 134 to 144 because amp not allow to inject javscript code, i would to use the code on my host but not sure if i can build and install the gem on Netlify. i could do the modification in the code if someone help me a bit...
from jekyll-pwa.
Thank you @samazgor! Yes basically this is what i tryed but the problem is: how i import the plugin inside jekyll? i created the modified jekyll-pwa-plugin.rb but i didn't understand if i have to add to the plugin in _config.yml
. i had never do this before. I am not very smart with Jekyll and Ruby self.insert_sw_register_into_body
function and his registration. You can see here my code in my fork of the gem.
Basically in this way i inject the code
<amp-install-serviceworker src="https://path/to/service-worker.js" layout="nodisplay"></amp-install-serviceworker>
with a Liquid tag
For now i only tested in my localhost but i would try soon on my website.
from jekyll-pwa.
My modified version of the gem-plugin is on RubyGems here
from jekyll-pwa.
@samazgor i did as you explain, it works as you said... But in the end i prefer with my custom gem. Thank you for the help! Maybe it will be nice to add an option for custom code injection or disable or enable the injection of the script code....
from jekyll-pwa.
Related Issues (20)
- How to add html pages to runtime cache HOT 2
- Consolidate settings in _config.yml?
- No need to set the cache header for the service worker since Chrome 68
- Trying to make cache fetch work HOT 1
- Content Security Policy
- CSP: feature request HOT 4
- gh-pages support HOT 3
- Please check my installation HOT 15
- Error during service worker registration: TypeError: Failed to register a ServiceWorker: ServiceWorker script evaluation failed HOT 1
- How to clear cache? HOT 1
- Event.initEvent() has been deprecated HOT 2
- How to listen for sw.update? HOT 1
- undefined local variable or method `page' for Jekyll:Module HOT 3
- jekyll-pwa-plugin.rb:161:in `block in <module:Jekyll>': undefined local HOT 6
- Images Not Caching HOT 1
- Migrate from Workbox v2 to v3 HOT 2
- Adding plugins HOT 2
- Service worker not being injected HOT 2
- undefined method `+' for nil :NilClass HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jekyll-pwa.