Skip to content

Commit

Permalink
Merge pull request #93 from zkz098/main
Browse files Browse the repository at this point in the history
fix: 修复 cloudflare rocket-loader开启时卡loading问题
  • Loading branch information
zkz098 authored May 13, 2023
2 parents 6b700a7 + 2d227cc commit 7d15649
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 4 deletions.
3 changes: 2 additions & 1 deletion docs/.vuepress/nav/sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ export default {
{text: "快速上手",link: "/guide/"},
{text: "更多配置",link: "/guide/config.html"},
{text: "主题配置",link: "/guide/theme.html"},
{text: "评论系统",link: "/guide/comment.html"}
{text: "评论系统",link: "/guide/comment.html"},
{text: "内容模块",link: "/guide/tags.html"}
]
},
{
Expand Down
6 changes: 5 additions & 1 deletion docs/guide/index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 快速上手
## 在开始之前
在开始之前,你应该已经安装了如下软件:
- nodejs 16以上
- nodejs 18以上
- hexo-cli 的 latest 版本

ShokaX-CLI 目前版本不负责处理 hexo 环境,请自行`hexo init`
Expand Down Expand Up @@ -132,5 +132,9 @@ prismjs:
enable: false
```
:::warning
在0.2.5及以下的版本中,如果您把 ShokaX 网站部署到了 cloudflare CDN 支持的服务上,请关闭`rocket-loader`,此功能与ShokaX的page ts存在冲突,会导致页面在loading时卡死 \
0.2.6已修复此问题,可开启`rocket-loader`功能
:::

现在shokaX已经可以正常运行了,`hexo s`即可
46 changes: 46 additions & 0 deletions docs/guide/tags.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# 文章内嵌标签
## Hexo标签
### links(链接块)
此标签用于以富媒体形式表现某链接,可用于友链、网站分享和功能合集等 \
配置格式如下:
```yaml
- site: # 主标题
owner: # 站点所有者(选填)
url: # 站点链接
desc: # 站点描述(选填)
image: # 站点图像(选填)
color: # 站点颜色(选填)
```
- `color`: 需要使用双引号包裹,值为大写的16进制颜色代码

在文章中使用:
:::: code-group
::: code-group-item 文章内嵌
```text
{% links %}
- site: # 主标题
owner: # 站点所有者(选填)
url: # 站点链接
desc: # 站点描述(选填)
image: # 站点图像(选填)
color: # 站点颜色(选填)
# 多链接参考yaml列表格式
{% endlinks %}
```
:::
::: code-group-item 外部文件
```text
# path为一个yaml文件
{% linksfile [path] %}
```
示例文件:
```yaml
- site: # 主标题
owner: # 站点所有者(选填)
url: # 站点链接
desc: # 站点描述(选填)
image: # 站点图像(选填)
color: # 站点颜色(选填)
```
:::
::::
2 changes: 1 addition & 1 deletion layout/_partials/post/footer.pug
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ div(class="meta")
!= __('post.edited')
time(title=__('post.modified') + __('symbol.colon') + full_date(post.updated) itemprop="dateModified" datetime=moment(post.updated).format())
!= date(post.updated)
if theme.waline.pageview && !theme.waline.enable
if theme.waline.pageview && !theme.waline.enable && !theme.twikoo.enable
script(type = "module" data-pjax).
import { pageviewCount } from 'https://unpkg.com/@waline/client/dist/pageview.mjs';

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hexo-theme-shokax",
"version": "0.2.5",
"version": "0.2.6",
"description": "a hexo theme based on shoka",
"main": "index.js",
"repository": "https://github.com/theme-shoka-x/hexo-theme-shokaX",
Expand Down
16 changes: 16 additions & 0 deletions source/js/_app/library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -480,3 +480,19 @@ const pageScroll = function (target: any, offset?: number, complete?: Function)
anime(opt).play()
// 调用 anime.js 函数,并传入参数
}

// rocket-loader & Auto minify(cloudflare) 补丁
// cloudflare 的上述功能会导致DOMContentLoaded事件无法触发,此补丁会将DOMContentLoaded重定向为load事件
let inCloudFlare = true
window.addEventListener('DOMContentLoaded', function () {
inCloudFlare = false
})

if (document.readyState === 'loading') {
window.addEventListener('load', function () {
if (inCloudFlare) {
window.dispatchEvent(new Event('DOMContentLoaded'))
console.log('%c ☁️cloudflare patch ' + '%c running(rocket & minify)', 'color: white; background: #ff8c00; padding: 5px 3px;', 'padding: 4px;border:1px solid #ff8c00')
}
})
}

0 comments on commit 7d15649

Please sign in to comment.