Skip to content

jekyll plugin to use service workers and make site content available offline

License

Notifications You must be signed in to change notification settings

lightrainstech/jekyll-offline

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jekyll-offline

ruby gem/jekyll plugin to use service workers and make site content available offline. When visitors load a site, the service worker will be registered and cache content on their device, enabling people to read the content offline/without a network connection.

Many thanks to @gauntface and @jakearchibald for two great resources on Service Workers:

Installation

Add this line to your application's Gemfile:

group 'jekyll-plugins' do
  gem 'jekyll-offline', :git => 'git://github.com/lightrainstech/jekyll-offline.git'
end

And add this to your _config.yml:

gems: ['jekyll-offline']

And then execute:

$ bundle install

Usage

The plugin does most of the work for you, but you have to initialize the service worker on the page with the {% register_service_worker %} liquid tag. It is generally a good idea to put this near the bottom of your default layout so that all pages have it.

You can use a variety of strategies to respond to requests. These strategies were pulled from the offline cookbook with minimal changes.

Configure jekyll-offline to use a given strategy by adding the following to your _config.yml:

...
offline:
  strategy: << whatever you want >>
  version: << cache_version_number >>

You can supply the following options as the value for strategy:

  • cache-only
  • network-only
  • cache-first-network-fallback
  • network-first-cache-fallback
  • cache-network-race
  • cache-then-network (default)

cache_version_number can be anything and any change to this will result in re-caching your whole website.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/jekyll-offline. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

About

jekyll plugin to use service workers and make site content available offline

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 51.1%
  • Ruby 47.2%
  • Shell 1.7%