Giter Club home page Giter Club logo

Comments (9)

samazgor avatar samazgor commented on May 31, 2024 1

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.

samazgor avatar samazgor commented on May 31, 2024 1

@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.

samazgor avatar samazgor commented on May 31, 2024 1

@kalwalt create a folder on the root and name it _plugins. Now copy your ruby file into that folder. See this

from jekyll-pwa.

xiaoiver avatar xiaoiver commented on May 31, 2024

May I ask how do you generate your AMP pages?
Using some Jekyll plugins like amp-jekyll?

from jekyll-pwa.

xiaoiver avatar xiaoiver commented on May 31, 2024

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.

kalwalt avatar kalwalt commented on May 31, 2024

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... 😄 I have not so much experience with Ruby and gem.

from jekyll-pwa.

kalwalt avatar kalwalt commented on May 31, 2024

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 😭 For this reason i modified completely the plugin deleting the 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.

kalwalt avatar kalwalt commented on May 31, 2024

My modified version of the gem-plugin is on RubyGems here

from jekyll-pwa.

kalwalt avatar kalwalt commented on May 31, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.