yarn add @jiangtj/hexo-next-pwa
- hexo version require >= 5.0
- not work in
hexo s
, please exechexo g
and serve public dir by other tool (e.g.serve public
)
I added some default configurations, see default.yaml or my blog configuration
pwa:
# Generate manifest.json
manifest:
enable: true
path: /manifest.json
# See https://developer.mozilla.org/zh-CN/docs/Web/Manifest
body:
# name: Blog
# short_name: dnocm
# lang: zh-CN
# display: standalone
# background_color: "#ecedee"
# theme_color: "#414852"
# icons:
# - src: /images/favicon-32.png
# sizes: 32x32
# type: image/png
# - src: /images/favicon-192.png
# sizes: 192x192
# type: image/png
# - src: /images/favicon-512.png
# sizes: 512x512
# type: image/png
# Generate sw.js
serviceWorker:
enable: true
sw: /sw.js
# add <script> if ('serviceWorker' in navigator) {...}</script> to your html file
addScript: true
# auto exec hexo workbox after generate, If you customize generate, please set it to false
wrapGenerate: true
options:
# see [the workbox-build's `generateSW()` API](https://developers.google.cn/web/tools/workbox/reference-docs/latest/module-workbox-build#.generateSW)
hexo workbox [-g]
-g
: auto exec hexo generate before workbox build.
This is very useful. If you disable the wrapGenerate
option, it allows you to directly generate sw.js
, but you need to be aware that you need to execute hexo generate
before.
- #57: In
hexo g -d
, pwa generate after deploy, please usehexo g && hexo d
instead ofhexo g -d
Initially, hexo-next-pwa was a fork of hexo-pwa, so you can see that they have similar options, but due to several revisions, the current hexo-next-pwa has been very different from hexo-pwa
In fact, I don’t know much about pwa. I doubt whether I can maintain this plugin. Anyway, my blog depends on it. In the short term, I don’t Will give up 😂.