Hexo PWA plugin
Switch branches/tags
Nothing to show
Clone or download
Latest commit 920d586 May 19, 2018
Permalink
Failed to load latest commit information.
lib modify README.md Dec 12, 2017
templates replace Workbox with sw-toolbox Nov 9, 2017
.fecsignore replace Workbox with sw-toolbox Nov 9, 2017
.fecsrc modify README.md Dec 12, 2017
.gitignore hexo-pwa Nov 6, 2017
LICENSE Update LICENSE May 19, 2018
README.md modify README.md Dec 12, 2017
index.js add priority parameter Dec 3, 2017
package.json modify README.md Dec 12, 2017

README.md

hexo-pwa

NPM version NPM Downloads

Progressive Web Apps (PWA) plugin for Hexo.

hexo-pwa let Hexo sites have these two capabilities.

Installation

$ npm install --save hexo-pwa

Options

You can configure this plugin in _config.yml.

pwa:
  manifest:
    path: /manifest.json
    body:
      name: hexo
      short_name: hexo
      icons:
        - src: /images/android-chrome-192x192.png
          sizes: 192x192
          type: image/png
  serviceWorker:
    path: /sw.js
    preload:
      urls:
        - /
      posts: 5
    opts:
      networkTimeoutSeconds: 5
    routes:
      - pattern: !!js/regexp /hm.baidu.com/
        strategy: networkOnly
      - pattern: !!js/regexp /.*\.(js|css|jpg|jpeg|png|gif)$/
        strategy: cacheFirst
      - pattern: !!js/regexp /\//
        strategy: networkFirst
  priority: 5
  • manifest - manifest configuration
    • path - the path of manifest.json, eg: /manifest.json
    • body - the content of manifest.json, manifest.json example. body can be null, if not null, hexo-pwa will generate manifest.json with JSON.stringify(body)
  • serviceWorker - service worker configuration
    • path: the path of sw.js, eg: /sw.js, you shouldn't put sw.js in subdirectory because of the service worker scope
    • preload - urls or posts that you want to preload
      • urls: an array of the preload urls
      • posts: the count of preload posts
    • opts: the options for sw-toolbox
    • routes - request routes and strategies, based on sw-toolbox. The routes order does matter.
      • pattern: url pattern, this config can be express-style or RegExp
      • strategy: the strategy you want to choose. All strategies: cacheFirst, networkFirst, cacheOnly, networkOnly, fastest. Caution: Log requests should use networkOnly strategy.
  • priority - plugin priority (default value is 10)

License

MIT