Skip to content

Commit e9e6f5a

Browse files
committed
docs: move serviceWorker section to pwa plugin
1 parent 628c330 commit e9e6f5a

File tree

4 files changed

+27
-41
lines changed

4 files changed

+27
-41
lines changed

packages/docs/docs/config/README.md

-21
Original file line numberDiff line numberDiff line change
@@ -83,27 +83,6 @@ Provide the Google Analytics ID to enable integration.
8383
Please be aware of [GDPR (2018 reform of EU data protection rules)](https://ec.europa.eu/commission/priorities/justice-and-fundamental-rights/data-protection/2018-reform-eu-data-protection-rules_en) and consider setting Google Analytics to [anonymize IPs](https://support.google.com/analytics/answer/2763052?hl=en) where appropriate and/or needed.
8484
:::
8585

86-
### serviceWorker
87-
88-
- Type: `boolean`
89-
- Default: `false`
90-
91-
If set to `true`, VuePress will automatically generate and register a service worker that caches the content for offline use (only enabled in production).
92-
93-
If developing a custom theme, the `Layout.vue` component will also be emitting the following events:
94-
95-
- `sw-ready`
96-
- `sw-cached`
97-
- `sw-updated`
98-
- `sw-offline`
99-
- `sw-error`
100-
101-
::: tip PWA NOTES
102-
The `serviceWorker` option only handles the service worker. To make your site fully PWA-compliant, you will need to provide the Web App Manifest and icons in `.vuepress/public`. For more details, see [MDN docs about the Web App Manifest](https://developer.mozilla.org/en-US/docs/Web/Manifest).
103-
104-
Also, only enable this if you are able to deploy your site with SSL, since service worker can only be registered under HTTPs URLs.
105-
:::
106-
10786
### locales
10887

10988
- Type: `{ [path: string]: Object }`

packages/docs/docs/plugin/official/plugin-pwa.md

+14
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,20 @@ module.exports = {
3030

3131
If set to `true`, VuePress will automatically generate and register a [service worker](https://developers.google.com/web/fundamentals/primers/service-workers/) that caches the content for offline use (only enabled in production).
3232

33+
There is a aliased module `@sw-event` module that will also be emitting the following events:
34+
35+
- `sw-ready`
36+
- `sw-cached`
37+
- `sw-updated`
38+
- `sw-offline`
39+
- `sw-error`
40+
41+
::: tip PWA NOTES
42+
The `serviceWorker` option only handles the service worker. To make your site fully PWA-compliant, you will need to provide the Web App Manifest and icons in `.vuepress/public`. For more details, see [MDN docs about the Web App Manifest](https://developer.mozilla.org/en-US/docs/Web/Manifest).
43+
44+
Also, only enable this if you are able to deploy your site with SSL, since service worker can only be registered under HTTPs URLs.
45+
:::
46+
3347
### updatePopup
3448

3549
- Type: `boolean|object`

packages/docs/docs/zh/config/README.md

-20
Original file line numberDiff line numberDiff line change
@@ -81,26 +81,6 @@ module.exports = {
8181
请留意 [GDPR (2018年欧盟数据保护规则改革)](https://ec.europa.eu/commission/priorities/justice-and-fundamental-rights/data-protection/2018-reform-eu-data-protection-rules_en), 在合适或者需要的情况下,考虑将 Google Analytics 设置为[匿名化的 IP](https://support.google.com/analytics/answer/2763052?hl=zh-Hans)
8282
:::
8383

84-
### serviceWorker
85-
86-
- 类型: `boolean`
87-
- 默认值: `false`
88-
89-
如果设置成 `true`,VuePress 将会自动生成并且注册一个 service worker,它缓存了那些已访问过的页面的内容,用于离线访问(仅在生产环境生效)。
90-
91-
如果你正在开发一个自定义主题,`Layout.vue` 组件将会自动触发下述的事件:
92-
93-
- `sw-ready`
94-
- `sw-cached`
95-
- `sw-updated`
96-
- `sw-offline`
97-
- `sw-error`
98-
99-
::: tip PWA NOTES
100-
`serviceWorker` 选项仅仅用来控制 service worker,为了让你的网站完全地兼容 PWA,你需要在 `.vuepress/public` 提供 Manifest 和 icons,更多细节,请参见 [MDN docs about the Web App Manifest](https://developer.mozilla.org/en-US/docs/Web/Manifest).
101-
此外,只有您能够使用 SSL 部署您的站点时才能启用此功能,因为 service worker 只能在 HTTPs 的 URL 下注册。
102-
:::
103-
10484
### locales
10585

10686
- 类型: `{ [path: string]: Object }`

packages/docs/docs/zh/plugin/official/plugin-pwa.md

+13
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,19 @@ module.exports = {
3030

3131
如果设置为 `true`,VuePress 将自动生成并注册一个 [Service Worker](https://developers.google.com/web/fundamentals/primers/service-workers/),用于缓存页面的内容以供离线使用(仅会在生产环境中启用)。
3232

33+
有一个别名化的模块 `@sw-event` 模块将会 emit 以下事件:
34+
35+
- `sw-ready`
36+
- `sw-cached`
37+
- `sw-updated`
38+
- `sw-offline`
39+
- `sw-error`
40+
41+
::: tip PWA NOTES
42+
`serviceWorker` 选项仅仅用来控制 service worker,为了让你的网站完全地兼容 PWA,你需要在 `.vuepress/public` 提供 Manifest 和 icons,更多细节,请参见 [MDN docs about the Web App Manifest](https://developer.mozilla.org/en-US/docs/Web/Manifest).
43+
此外,只有您能够使用 SSL 部署您的站点时才能启用此功能,因为 service worker 只能在 HTTPs 的 URL 下注册。
44+
:::
45+
3346
### updatePopup
3447

3548
- 类型: `boolean|popupConfig`

0 commit comments

Comments
 (0)