Skip to content

Commit

Permalink
docs($cn): document for themeConfig.serviceWorker.updatePopup
Browse files Browse the repository at this point in the history
  • Loading branch information
ulivz committed Jul 28, 2018
1 parent 92314ac commit a8b06b1
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 9 deletions.
24 changes: 15 additions & 9 deletions docs/default-theme-config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -356,26 +356,32 @@ Note that it's `off` by default. If given `string`, it will be displayed as a pr
Since `lastUpdated` is based on `git`, you can only use it in a `git` repository. As well, since the timestamp used comes from the git commit, it will display only after a first commit for a given page, and update only on subsequent commits of that page.
:::

## Service Workers
## Service Worker

The `themeConfig.serviceWorker` option allows you to configure about service workers.
The `themeConfig.serviceWorker` option allows you to configure about service worker.

### Popup UI to refresh contents
::: tip
Please do not confuse this option with [Config > serviceWorker](../config/README.md#serviceworker), [Config > serviceWorker](../config/README.md#serviceworker) is **site-level**, while this option is **theme-level**.
:::

The `themeConfig.serviceWorker.updatePopup` option enables the popup to refresh contents. The popup will be shown when the site is updated (the service worker is updated). It provides `refresh` button to allow users to refresh contents immediately.
### Popup UI to refresh contents <Badge text="0.13.0+"/>

::: tip NOTE
If without the `refresh` button, the new service worker will be active after all clients are closed.
This means that visitors cannot see new contents until they close all tabs of your site.
The `themeConfig.serviceWorker.updatePopup` option enables the popup to refresh contents. The popup will be shown when the site is updated (i.e. service worker is updated). It provides `refresh` button to allow users to refresh contents immediately.

But the `refresh` button activates the new service worker immediately.
::: tip NOTE
If without the `refresh` button, the new service worker will be active after all [clients](https://developer.mozilla.org/en-US/docs/Web/API/Clients) are closed. This means that visitors cannot see new contents until they close all tabs of your site. But the `refresh` button activates the new service worker immediately.
:::

``` js
module.exports = {
themeConfig: {
serviceWorker: {
updatePopup: true | {message: "New content is available.", buttonText: "Refresh"}
updatePopup: true // Boolean | Object, default to undefined.
// If set to true, the default text config will be:
// updatePopup: {
// message: "New content is available.",
// buttonText: "Refresh"
// }
}
}
}
Expand Down
31 changes: 31 additions & 0 deletions docs/zh/default-theme-config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,37 @@ module.exports = {
由于 `lastUpdated` 是基于 `git` 的, 所以你只能在一个基于 `git` 的项目中启用它。
:::

## Service Worker

`themeConfig.serviceWorker` 允许你去配置 Service Worker。

::: tip 提示
请不要将本选项与 [Config > serviceWorker](../config/README.md#serviceworker) 混淆,[Config > serviceWorker](../config/README.md#serviceworker) 是网站级别的配置,而本选项是主题级别的配置。
:::

### 刷新内容的弹窗 <Badge text="0.13.0+"/>

开启 `themeConfig.serviceWorker.updatePopup` 选项,将开启一个能够刷新内容的弹窗。当网站更新(即 Service Worker 更新)时,它会提供一个 `refresh` 按钮,允许用户立刻刷新内容。

::: tip 提示
如果没有 `refresh` 按钮,新的 service worker 将在所有的 [clients](https://developer.mozilla.org/en-US/docs/Web/API/Clients) 关闭后才会处于活动状态。这意味着访问者在关闭你网站的所有标签之前将无法看到新内容。但是,`refresh` 按钮可以立即激活新的 Service Worker。
:::

``` js
module.exports = {
themeConfig: {
serviceWorker: {
updatePopup: true // Boolean | Object, 默认值是 undefined.
// 如果设置为 true, 默认的文本配置将是:
// updatePopup: {
// message: "New content is available.",
// buttonText: "Refresh"
// }
}
}
}
```

## 上 / 下一篇链接

上一篇和下一篇文章的链接将会自动地根据当前页面的侧边栏的顺序来获取。你也可以使用 `YAML front matter` 来明确地重写或者禁用它:
Expand Down

0 comments on commit a8b06b1

Please sign in to comment.