Compare commits

..

18 Commits

232 changed files with 7072 additions and 10278 deletions

59
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@@ -0,0 +1,59 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''
---
<!--
IMPORTANT: Please follow the template to create a new issue.
重要:請依照該模板來提交。
If you upgrade from the old version, and an error occurs when running, please copy the new content in the config to the butterfly.yml
如果你是由舊版本升級到新版執行時出現報錯請首先把config裡新的內容複製到舊的butterfly設定去
If you are a problem when visit the website, please open your browser 'developer tools (shortcut F12)' and check the console if there is an error, include your website address in the feedback
如果你是線上訪問出現問題請檢查瀏覽器開發人員工具快捷鍵F12的console是否有報錯反饋時附上你的網站
-->
## I want to create a Bug report <!-- 我想要建立一個 Bug report -->
<!-- Check all with "x" especially FAQ & Documentation!! (使用 "x" 選擇) -->
<!-- 請確認是否都已經翻閲過如下的資料, 尤其是安裝文件!! -->
- [] Yes, I have read [Hexo Docs page](https://hexo.io/docs/), especially [Templates](https://hexo.io/docs/templates.html), [Variables](https://hexo.io/docs/variables.html), [Helpers](https://hexo.io/docs/helpers.html) and [Troubleshooting](https://hexo.io/docs/troubleshooting.html).
- [] Yes, I have read [Butterfly Documentation](https://demo.jerryc.me/posts/21cfbf15/).
- [] And yes, I already searched for current [issues](https://github.com/jerryc127/hexo-theme-butterfly/issues?utf8=%E2%9C%93&q=is%3Aissue) and this did not help me.
## Butterfly Information
<!-- Butterfly的版本 -->
<!-- 檢視主題的package.json -->
**Butterfly Version:**
<!-- Windows/macOS/Linux/Android/iOS -->
**Platform:**
<!-- Chrome/Safari/FireFox/.. -->
**Browser:**
## Expected behavior <!-- (預期行為) -->
## Actual behavior <!-- (實際行為) -->
## Steps to reproduce the behavior <!-- (重現步驟) -->
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
<!-- If applicable, add screenshots to help explain your problem -->
<!-- 請儘量提供截圖來定位問題 -->
## Screenshots <!-- (截圖) -->
<!-- Provide your website to find the issues -->
## Website
## Describe the bug

View File

@@ -1,73 +0,0 @@
name: Bug report
description: Create a report to help us improve
title: '[Bug]: '
body:
- type: markdown
attributes:
value: |
重要:請依照該模板來提交
Please follow the template to create a new issue
- type: input
id: butterfly-ver
attributes:
label: 使用的 Butterfly 版本? | What version of Butterfly are you use?
description: 檢視主題的 package.json | Check the theme's package.json
validations:
required: true
- type: dropdown
id: modify
attributes:
label: 是否修改过主题文件? || Has the theme files been modified?
options:
- 是 (Yes)
- 不是 (No)
validations:
required: true
- type: dropdown
id: browser
attributes:
label: 使用的瀏覽器? || What browse are you using?
options:
- Chrome
- Edge
- Safari
- Opera
- Other
validations:
required: true
- type: dropdown
id: platform
attributes:
label: 使用的系統? || What operating system are you using?
options:
- Windows
- macOS
- Linux
- Android
- iOS
- Other
validations:
required: true
- type: textarea
id: description
attributes:
label: 問題描述 | Describe the bug
description: 請描述你的問題現象 | A clear and concise description of what the bug is.
placeholder: 請儘量提供截圖來定位問題 | If applicable, add screenshots to help explain your problem
value:
validations:
required: true
- type: input
id: website
attributes:
label: 出現問題網站 | Website
description: 請提供下可復現網站地址 | Please supply a website url which can reproduce problem.
placeholder:
validations:
required: true

View File

@@ -1,22 +0,0 @@
blank_issues_enabled: false
contact_links:
- name: Questions about Butterfly
url: https://github.com/jerryc127/hexo-theme-butterfly/discussions
about: 一些使用問題請到 Discussion 詢問。 Please ask questions in Discussion.
- name: Butterfly Q&A
url: https://butterfly.js.org/posts/98d20436/
about: Butterfly Q&A
- name: Telegram
url: https://t.me/bu2fly
about: 'Official Telegram Group'
- name: QQ 1群
url: https://jq.qq.com/?_wv=1027&k=KU9105XR
about: '群號 1070540070不要兩個Q群都添加'
- name: QQ 2群
url: https://jq.qq.com/?_wv=1027&k=r1nK0DQz
about: '群號 978221020不要兩個Q群都添加'

10
.github/ISSUE_TEMPLATE/custom.md vendored Normal file
View File

@@ -0,0 +1,10 @@
---
name: Custom issue template
about: Describe this issue template's purpose here.
title: ''
labels: ''
assignees: ''
---

View File

@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.

View File

@@ -1,14 +0,0 @@
name: Feature request
description: Suggest an idea for this project
title: '[Feature]: '
body:
- type: textarea
id: feature-request
attributes:
label: 想要的功能 | What feature do you want?
description: 請描述你需要的新功能 | A clear and concise description of what the feature is.
placeholder:
value:
validations:
require: true

21
.github/stale.yml vendored Normal file
View File

@@ -0,0 +1,21 @@
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 30
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 7
# Issues with these labels will never be considered stale
exemptLabels:
- pinned
- security
- bug
- enhancement
- Solved
- documentation
# Label to use when marking an issue as stale
staleLabel: wontfix
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
# Comment to post when closing a stale issue. Set to `false` to disable
closeComment: false

View File

@@ -1,19 +0,0 @@
name: npm publish
on:
release:
types: [created]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v1
with:
node-version: '12.x'
registry-url: 'https://registry.npmjs.org'
- run: npm install
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

View File

@@ -1,19 +0,0 @@
name: 'Close stale issues and PRs'
on:
schedule:
- cron: '30 1 * * *'
jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v5
with:
days-before-issue-stale: 30
days-before-pr-stale: -1
days-before-close: 7
stale-issue-message: 'This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.'
close-pr-message: 'This issue has not seen any activity since it was marked stale. Closing.'
stale-issue-label: 'Stale'
exempt-issue-labels: 'pinned,bug,enhancement,documentation,Plan'
operations-per-run: 1000

View File

@@ -1,28 +1,19 @@
<div align="right">
<a title="Chinese" href="/README_CN.md">中文</a>
</div>
# hexo-theme-butterfly # hexo-theme-butterfly
![master version](https://img.shields.io/github/package-json/v/jerryc127/hexo-theme-butterfly/master?color=%231ab1ad&label=master) ![version](https://img.shields.io/github/package-json/v/jerryc127/hexo-theme-butterfly)
![master version](https://img.shields.io/github/package-json/v/jerryc127/hexo-theme-butterfly/dev?label=dev)
![https://img.shields.io/npm/v/hexo-theme-butterfly?color=%09%23bf00ff](https://img.shields.io/npm/v/hexo-theme-butterfly?color=%09%23bf00ff) ![https://img.shields.io/npm/v/hexo-theme-butterfly?color=%09%23bf00ff](https://img.shields.io/npm/v/hexo-theme-butterfly?color=%09%23bf00ff)
![hexo version](https://img.shields.io/badge/hexo-5.3.0+-0e83c) ![hexo version](https://img.shields.io/badge/hexo-4.0+-0e83c)
![npm download](https://img.shields.io/npm/dw/hexo-theme-butterfly?color=green)
![nodejs version](https://img.shields.io/badge/node.js-8.0+-yellow)
![license](https://img.shields.io/github/license/jerryc127/hexo-theme-butterfly?color=FF5531) ![license](https://img.shields.io/github/license/jerryc127/hexo-theme-butterfly?color=FF5531)
![](https://cdn.jsdelivr.net/gh/jerryc127/CDN@m2/img/theme-butterfly-readme.png) Demo: 👍 [Butterfly](https://demo.jerryc.me/) || 🤞 [JerryC](https://jerryc.me/)
📢 Demo: [Butterfly](https://butterfly.js.org/) || [CrazyWong](https://blog.crazywong.com/) Docs: 📖 [Butterfly Docs](https://demo.jerryc.me/posts/21cfbf15/)
📖 Docs: [English](https://butterfly.js.org/en/posts/butterfly-docs-en-get-started/) || [Chinese](https://butterfly.js.org/posts/21cfbf15/)
Based on [hexo-theme-melody](https://github.com/Molunerfinn/hexo-theme-melody) theme. Based on [hexo-theme-melody](https://github.com/Molunerfinn/hexo-theme-melody) theme.
## 💻 Installation ## Installation
### GIT
> If you are in Mainland China, you can download in [Gitee](https://gitee.com/immyw/hexo-theme-butterfly.git)
Stable branch [recommend]: Stable branch [recommend]:
@@ -36,17 +27,7 @@ Dev branch:
git clone -b dev https://github.com/jerryc127/hexo-theme-butterfly.git themes/butterfly git clone -b dev https://github.com/jerryc127/hexo-theme-butterfly.git themes/butterfly
``` ```
### NPM ## Configuration
> It supports Hexo 5.0.0 or later
In Hexo site root directory
```powershell
npm i hexo-theme-butterfly
```
## ⚙ Configuration
Set theme in the hexo work folder's root config file `_config.yml`: Set theme in the hexo work folder's root config file `_config.yml`:
@@ -56,56 +37,10 @@ npm i hexo-theme-butterfly
> npm install hexo-renderer-pug hexo-renderer-stylus > npm install hexo-renderer-pug hexo-renderer-stylus
## 🎉 Features ## Screenshots
- [x] Card UI Design ![image](https://user-images.githubusercontent.com/16351105/58887365-1272f780-8718-11e9-9329-3292c6ba20d4.png)
- [X] Support sub-menu
- [x] Two-column layout
- [x] Responsive Web Design
- [x] Dark Mode
- [x] Pjax
- [x] Read Mode
- [x] Conversion between Traditional and Simplified Chinese
- [X] TOC catalog is available for both computers and mobile phones
- [X] Built-in Syntax Highlighting Themes (darker/pale night/light/ocean/mac/mac light), also support customization
- [X] Code Blocks (Display code language/close or expand Code Blocks/Copy Button/word wrap)
- [X] Disable copy/Add a Copyright Notice to the Copied Text
- [X] Search (Algolia Search/Local Search)
- [x] Mathjax and Katex
- [x] Built-in 404 page
- [x] WordCount
- [x] Related articles
- [x] Displays outdated notice for a post
- [x] Share (Sharejs/Addtoany)
- [X] Comment (Disqus/Disqusjs/Livere/Gitalk/Valine/Waline/Utterances/Facebook Comments/Twikoo/Giscus/Remark42/artalk)
- [x] Multiple Comment System Support
- [x] Online Chats (Chatra/Tidio/Daovoice/Crisp/messenger)
- [x] Web analytics
- [x] Google AdSense
- [x] Webmaster Verification
- [x] Change website colour scheme
- [x] Typewriter Effect: activate_power_mode
- [x] Background effects (Canvas ribbon/canvas_ribbon_piao/canvas_nest)
- [x] Mouse click effects (Fireworks/Heart/Text)
- [x] Preloader/Loading Animation/pace.js
- [x] Busuanzi visitor counter
- [x] Medium Zoom/Fancybox
- [x] Mermaid
- [x] Justified Gallery
- [x] Lazyload images
- [x] Instantpage/Pangu/Snackbar notification toast/PWA......
## ✨ Contributors ![](https://user-images.githubusercontent.com/16351105/58887457-3cc4b500-8718-11e9-9417-2bdea603c92e.png)
<a href="https://github.com/jerryc127/hexo-theme-butterfly/graphs/contributors"> ![](https://user-images.githubusercontent.com/16351105/69338594-7d03f980-0c9e-11ea-8b64-7f165e6508e2.png)
<img src="https://contrib.rocks/image?repo=jerryc127/hexo-theme-butterfly" />
</a>
## 📷 Screenshots
![](https://cdn.jsdelivr.net/gh/jerryc127/CDN@m2/img/butterfly-readme-screenshots-1.jpg)
![](https://cdn.jsdelivr.net/gh/jerryc127/CDN@m2/img/butterfly-readme-screenshots-2.jpg)
![](https://cdn.jsdelivr.net/gh/jerryc127/CDN@m2/img/butterfly-readme-screenshots-3.jpg)
![](https://cdn.jsdelivr.net/gh/jerryc127/CDN@m2/img/butterfly-readme-screenshots-4.jpg)
![](https://cdn.jsdelivr.net/gh/jerryc127/CDN/img/theme-butterfly-readme-homepage-1.png)
![](https://cdn.jsdelivr.net/gh/jerryc127/CDN/img/theme-butterfly-readme-homepage-2.png)

View File

@@ -1,53 +1,34 @@
<div align="right">
<a title="English" href="/README.md">English</a>
</div>
# hexo-theme-butterfly # hexo-theme-butterfly
![master version](https://img.shields.io/github/package-json/v/jerryc127/hexo-theme-butterfly/master?color=%231ab1ad&label=master) ![version](https://img.shields.io/github/package-json/v/jerryc127/hexo-theme-butterfly)
![master version](https://img.shields.io/github/package-json/v/jerryc127/hexo-theme-butterfly/dev?label=dev)
![https://img.shields.io/npm/v/hexo-theme-butterfly?color=%09%23bf00ff](https://img.shields.io/npm/v/hexo-theme-butterfly?color=%09%23bf00ff) ![https://img.shields.io/npm/v/hexo-theme-butterfly?color=%09%23bf00ff](https://img.shields.io/npm/v/hexo-theme-butterfly?color=%09%23bf00ff)
![hexo version](https://img.shields.io/badge/hexo-5.3.0+-0e83c) ![hexo version](https://img.shields.io/badge/hexo-4.0+-0e83c)
![npm download](https://img.shields.io/npm/dw/hexo-theme-butterfly?color=green)
![nodejs version](https://img.shields.io/badge/node.js-8.0+-yellow)
![license](https://img.shields.io/github/license/jerryc127/hexo-theme-butterfly?color=FF5531) ![license](https://img.shields.io/github/license/jerryc127/hexo-theme-butterfly?color=FF5531)
![](https://cdn.jsdelivr.net/gh/jerryc127/CDN@m2/img/theme-butterfly-readme.png)
📢 預覽: [Butterfly](https://butterfly.js.org/) || [CrazyWong](https://blog.crazywong.com/) 預覽: 👍 [Butterfly](https://demo.jerryc.me/) || 🤞 [JerryC](https://jerryc.me/)
📖 文檔: [中文](https://butterfly.js.org/posts/21cfbf15/) || [English](https://butterfly.js.org/en/posts/butterfly-docs-en-get-started/) 文檔: 📖 [Butterfly Docs](https://demo.jerryc.me/posts/21cfbf15/)
一款基於[hexo-theme-melody](https://github.com/Molunerfinn/hexo-theme-melody)修改的主題 一款基於[hexo-theme-melody](https://github.com/Molunerfinn/hexo-theme-melody)修改的主題
## 💻 安裝 ## 安裝
### Git 安裝 在你的博客根目錄裡安裝穩定版【推薦】
> 本倉庫同時上傳到 [Gitee](https://gitee.com/immyw/hexo-theme-butterfly.git),如果你訪問 Github 緩慢,可從 Gitee 中下載。 ```
在博客根目錄裡安裝穩定版【推薦】
```powershell
git clone -b master https://github.com/jerryc127/hexo-theme-butterfly.git themes/butterfly git clone -b master https://github.com/jerryc127/hexo-theme-butterfly.git themes/butterfly
``` ```
如果想要安裝比較新的dev分支可以 如果想要安裝比較新的dev分支可以
```powershell ```
git clone -b dev https://github.com/jerryc127/hexo-theme-butterfly.git themes/butterfly git clone -b dev https://github.com/jerryc127/hexo-theme-butterfly.git themes/butterfly
``` ```
### npm 安裝 ## 應用主題
> 此方法只支持Hexo 5.0.0以上版本
在博客根目錄裡
```powershell
npm i hexo-theme-butterfly
```
## ⚙ 應用主題
修改hexo配置文件`_config.yml`,把主題改為`Butterfly` 修改hexo配置文件`_config.yml`,把主題改為`Butterfly`
``` ```
@@ -56,56 +37,9 @@ theme: butterfly
>如果你沒有pug以及stylus的渲染器請下載安裝 npm install hexo-renderer-pug hexo-renderer-stylus --save >如果你沒有pug以及stylus的渲染器請下載安裝 npm install hexo-renderer-pug hexo-renderer-stylus --save
## 🎉 特色 ## 截圖
- [x] 卡片化設計 ![image](https://user-images.githubusercontent.com/16351105/58887365-1272f780-8718-11e9-9329-3292c6ba20d4.png)
- [X] 支持二級目錄 ![image](https://user-images.githubusercontent.com/16351105/58887457-3cc4b500-8718-11e9-9417-2bdea603c92e.png)
- [x] 雙欄設計
- [x] 響應式主題
- [x] 夜間模式
- [x] Pjax
- [x] 文章閲讀模式
- [x] 簡體和繁體轉換
- [X] 電腦和手機都可查看TOC目錄
- [X] 內置多種代碼配色darker/pale night/light/ocean/mac/mac light可自定義代碼配色
- [X] 代碼塊顯示代碼語言/關閉或展開代碼塊/代碼複製/代碼自動換行
- [X] 可關閉文字複製/可開啟內容複製增加版權信息)
- [X] 兩種搜索( Algolia 搜索和本地搜索)
- [x] Mathjax 和 Katex
- [x] 內置404頁面
- [x] 顯示字數統計
- [x] 顯示相關文章
- [x] 過期文章提醒
- [x] 多種分享系統Sharejs/Addtoany
- [X] 多種評論系統Disqus/Disqusjs/Livere/Gitalk/Valine/Waline/Utterances/Facebook Comments/Twikoo/Giscus/Remark42/artalk
- [x] 支持雙評論部署
- [x] 多種在線聊天Chatra/Tidio/Daovoice/Crisp/messenger
- [x] 多種分析系統
- [x] 谷歌廣告/手動廣告位置
- [x] 各種站長驗證Google/Bing/Baidu/360/Yandex
- [x] 修改網站配色
- [x] 打字特效 activate_power_mode
- [x] 多種背景特效(靜止彩帶/動態彩帶/Canvas Nest
- [x] 多種鼠標點擊特效(煙花/文字/愛心)
- [x] 內置一種 Preloader 加載動畫和 pace.js 加載動畫條
- [x] 不蒜子訪問統計
- [x] 兩種大圖模式Medium Zoom/Fancybox
- [x] Mermaid 圖表顯示
- [x] 照片牆
- [x] 圖片懶加載
- [x] Instantpage/Pangu/Snackbar彈窗/PWA......
## ✨ 貢獻者 ![](https://user-images.githubusercontent.com/16351105/69338594-7d03f980-0c9e-11ea-8b64-7f165e6508e2.png)
<a href="https://github.com/jerryc127/hexo-theme-butterfly/graphs/contributors">
<img src="https://contrib.rocks/image?repo=jerryc127/hexo-theme-butterfly" />
</a>
## 📷 截圖
![](https://cdn.jsdelivr.net/gh/jerryc127/CDN@m2/img/butterfly-readme-screenshots-1.jpg)
![](https://cdn.jsdelivr.net/gh/jerryc127/CDN@m2/img/butterfly-readme-screenshots-2.jpg)
![](https://cdn.jsdelivr.net/gh/jerryc127/CDN@m2/img/butterfly-readme-screenshots-3.jpg)
![](https://cdn.jsdelivr.net/gh/jerryc127/CDN@m2/img/butterfly-readme-screenshots-4.jpg)
![](https://cdn.jsdelivr.net/gh/jerryc127/CDN/img/theme-butterfly-readme-homepage-1.png)
![](https://cdn.jsdelivr.net/gh/jerryc127/CDN/img/theme-butterfly-readme-homepage-2.png)

File diff suppressed because it is too large Load Diff

View File

@@ -1,11 +1,15 @@
sidebar:
catalog: Catalog
have_read: You've read
footer: footer:
framework: Framework framework: Framework
theme: Theme theme: Theme
copy: copy:
success: Copy Successful success: Copy successfully
error: Copy Error error: Copy error
noSupport: Browser Not Supported noSupport: The browser does not support
page: page:
articles: Articles articles: Articles
@@ -13,17 +17,16 @@ page:
category: Category category: Category
archives: Archives archives: Archives
card_post_count: comments sticky: Sticky
no_title: No title
no_title: Untitled
post: post:
created: Created created: Created
updated: Updated updated: Updated
wordcount: Word Count wordcount: Word count
min2read: Reading Time min2read: Reading time
min2read_unit: mins min2read_unit: min
page_pv: Post Views page_pv: Post View
comments: Comments comments: Comments
copyright: copyright:
author: Author author: Author
@@ -31,24 +34,22 @@ post:
copyright_notice: Copyright Notice copyright_notice: Copyright Notice
copyright_content: 'All articles in this blog are licensed under <a href="%s">%s</a> unless stating additionally.' copyright_content: 'All articles in this blog are licensed under <a href="%s">%s</a> unless stating additionally.'
recommend: Related Articles recommend: Related Articles
edit: Edited on
search: search: Search
title: Search algolia_search:
load_data: Loading the Database
algolia_search:
input_placeholder: Search for Posts input_placeholder: Search for Posts
hits_empty: "We didn't find any results for the search: ${query}." hits_empty: "We didn't find any results for the search: ${query}."
hits_stats: '${hits} results found in ${time} ms' hits_stats: '${hits} results found in ${time} ms'
local_search: local_search:
label: Local search
input_placeholder: Search for Posts input_placeholder: Search for Posts
hits_empty: "We didn't find any results for the search: ${query}" hits_empty: "We didn't find any results for the search: ${query}"
hits_stats: '${hits} results found' powered_by: Powered by
pagination: pagination:
prev: Previous prev: Previous Post
next: Next next: Next Post
comment: Comment comment: Comment
@@ -64,46 +65,29 @@ aside:
card_webinfo: card_webinfo:
headline: Info headline: Info
article_name: Article article_name: Article
runtime: runtime_name: Run time
name: Runtime
unit: days
last_push_date:
name: Last Update
site_wordcount: Total Count site_wordcount: Total Count
site_uv_name: UV site_uv_name: UV
site_pv_name: PV site_pv_name: PV
more_button: View More more_button: More
card_newest_comments:
headline: Latest Comments
loading_text: loading...
error: Unable to retrieve comments, please check the configuration
zero: No comments
image: image
link: link
code: code
card_toc: Contents
card_post_series: Series
date_suffix: donate: Donate
just: Just now
min: minutes ago
hour: hours ago
day: days ago
month: months ago
donate: Sponsor
share: Share share: Share
bookmark:
title: Bookmark
rightside: rightside:
readmode_title: Read Mode readmode_title: Read Mode
translate_title: Toggle Between Traditional Chinese And Simplified Chinese font_plus_title: Increase Font Size
night_mode_title: Toggle Between Light And Dark Mode font_minus_title: Decrease Font Size
translate_title: Switch Between Traditional Chinese And Simplified Chinese
night_mode_title: Switch Between Light And Dark Mode
back_to_top: Back To Top back_to_top: Back To Top
toc: Table Of Contents toc: Table Of Contents
scroll_to_comment: Scroll To Comments scroll_to_comment: Scroll To Comments
setting: Setting setting: Setting
aside: Toggle between Single-column and Double-column
chat: Chat runtime_unit: days
copy_copyright: copy_copyright:
author: Author author: Author
@@ -112,12 +96,16 @@ copy_copyright:
info: Copyright is owned by the author. For commercial reprints, please contact the author for authorization. For non-commercial reprints, please indicate the source. info: Copyright is owned by the author. For commercial reprints, please contact the author for authorization. For non-commercial reprints, please indicate the source.
Snackbar: Snackbar:
chs_to_cht: You have switched to Traditional Chinese bookmark:
cht_to_chs: You have switched to Simplified Chinese message_prev: Press
day_to_night: You have switched to Dark Mode message_next: to bookmark this page
night_to_day: You have switched to Light Mode chs_to_cht: Traditional Chinese Activated Manually
cht_to_chs: Simplified Chinese Activated Manually
day_to_night: Dark Mode Activated Manually
night_to_day: Light Mode Activated Manually
loading: Loading... loading: Loading...
load_more: Load More
error404: Page Not Found error404:
error_title: Page not found
back_button: Go back home

View File

@@ -1,11 +1,15 @@
sidebar:
catalog: Catalog
have_read: You've read
footer: footer:
framework: Framework framework: Framework
theme: Theme theme: Theme
copy: copy:
success: Copy Successful success: Copy successfully
error: Copy Error error: Copy error
noSupport: Browser Not Supported noSupport: The browser does not support
page: page:
articles: Articles articles: Articles
@@ -13,17 +17,16 @@ page:
category: Category category: Category
archives: Archives archives: Archives
card_post_count: comments sticky: Sticky
no_title: No title
no_title: Untitled
post: post:
created: Created created: Created
updated: Updated updated: Updated
wordcount: Word Count wordcount: Word count
min2read: Reading Time min2read: Reading time
min2read_unit: mins min2read_unit: min
page_pv: Post Views page_pv: Post View
comments: Comments comments: Comments
copyright: copyright:
author: Author author: Author
@@ -31,24 +34,22 @@ post:
copyright_notice: Copyright Notice copyright_notice: Copyright Notice
copyright_content: 'All articles in this blog are licensed under <a href="%s">%s</a> unless stating additionally.' copyright_content: 'All articles in this blog are licensed under <a href="%s">%s</a> unless stating additionally.'
recommend: Related Articles recommend: Related Articles
edit: Edited on
search: search: Search
title: Search algolia_search:
load_data: Loading the Database
algolia_search:
input_placeholder: Search for Posts input_placeholder: Search for Posts
hits_empty: "We didn't find any results for the search: ${query}." hits_empty: "We didn't find any results for the search: ${query}."
hits_stats: '${hits} results found in ${time} ms' hits_stats: '${hits} results found in ${time} ms'
local_search: local_search:
label: Local search
input_placeholder: Search for Posts input_placeholder: Search for Posts
hits_empty: "We didn't find any results for the search: ${query}" hits_empty: "We didn't find any results for the search: ${query}"
hits_stats: '${hits} results found' powered_by: Powered by
pagination: pagination:
prev: Previous prev: Previous Post
next: Next next: Next Post
comment: Comment comment: Comment
@@ -64,46 +65,29 @@ aside:
card_webinfo: card_webinfo:
headline: Info headline: Info
article_name: Article article_name: Article
runtime: runtime_name: Run time
name: Runtime
unit: days
last_push_date:
name: Last Update
site_wordcount: Total Count site_wordcount: Total Count
site_uv_name: UV site_uv_name: UV
site_pv_name: PV site_pv_name: PV
more_button: View More more_button: More
card_newest_comments:
headline: Latest Comments
loading_text: loading...
error: Unable to retrieve comments, please check the configuration
zero: No comments
image: image
link: link
code: code
card_toc: Contents
card_post_series: Series
date_suffix: donate: Donate
just: Just now
min: minutes ago
hour: hours ago
day: days ago
month: months ago
donate: Sponsor
share: Share share: Share
bookmark:
title: Bookmark
rightside: rightside:
readmode_title: Read Mode readmode_title: Read Mode
translate_title: Toggle Between Traditional Chinese And Simplified Chinese font_plus_title: Increase Font Size
night_mode_title: Toggle Between Light And Dark Mode font_minus_title: Decrease Font Size
translate_title: Switch Between Traditional Chinese And Simplified Chinese
night_mode_title: Switch Between Light And Dark Mode
back_to_top: Back To Top back_to_top: Back To Top
toc: Table Of Contents toc: Table Of Contents
scroll_to_comment: Scroll To Comments scroll_to_comment: Scroll To Comments
setting: Setting setting: Setting
aside: Toggle between Single-column and Double-column
chat: Chat runtime_unit: days
copy_copyright: copy_copyright:
author: Author author: Author
@@ -112,12 +96,16 @@ copy_copyright:
info: Copyright is owned by the author. For commercial reprints, please contact the author for authorization. For non-commercial reprints, please indicate the source. info: Copyright is owned by the author. For commercial reprints, please contact the author for authorization. For non-commercial reprints, please indicate the source.
Snackbar: Snackbar:
chs_to_cht: You have switched to Traditional Chinese bookmark:
cht_to_chs: You have switched to Simplified Chinese message_prev: Press
day_to_night: You have switched to Dark Mode message_next: to bookmark this page
night_to_day: You have switched to Light Mode chs_to_cht: Traditional Chinese Activated Manually
cht_to_chs: Simplified Chinese Activated Manually
day_to_night: Dark Mode Activated Manually
night_to_day: Light Mode Activated Manually
loading: Loading... loading: Loading...
load_more: Load More
error404: Page Not Found error404:
error_title: Page not found
back_button: Go back home

View File

@@ -1,3 +1,7 @@
sidebar:
catalog: 目录
have_read: 你已经读了
footer: footer:
framework: 框架 framework: 框架
theme: 主题 theme: 主题
@@ -13,8 +17,7 @@ page:
category: 分类 category: 分类
archives: 归档 archives: 归档
card_post_count: 条评论 sticky: 置顶
no_title: 无题 no_title: 无题
post: post:
@@ -32,20 +35,19 @@ post:
copyright_content: '本博客所有文章除特别声明外,均采用 copyright_content: '本博客所有文章除特别声明外,均采用
<a href="%s" target="_blank">%s</a> 许可协议。转载请注明来自 <a href="%s" target="_blank">%s</a>' <a href="%s" target="_blank">%s</a> 许可协议。转载请注明来自 <a href="%s" target="_blank">%s</a>'
recommend: 相关推荐 recommend: 相关推荐
edit: 编辑
search: search: 搜索
title: 搜索 algolia_search:
load_data: 数据库加载中
algolia_search:
input_placeholder: 搜索文章 input_placeholder: 搜索文章
hits_empty: '找不到您查询的内容:${query}' hits_empty: '找不到您查询的内容:${query}'
hits_stats: '找到 ${hits} 条结果,用时 ${time} 毫秒' hits_stats: '找到 ${hits} 条结果,用时 ${time} 毫秒'
local_search: local_search:
label: 本地搜索
input_placeholder: 搜索文章 input_placeholder: 搜索文章
hits_empty: '找不到您查询的内容:${query}' hits_empty: '找不到您查询的内容:${query}'
hits_stats: '共找到 ${hits} 篇文章' powered: '提供支持'
by:
pagination: pagination:
prev: 上一篇 prev: 上一篇
@@ -65,46 +67,29 @@ aside:
card_webinfo: card_webinfo:
headline: 网站资讯 headline: 网站资讯
article_name: 文章数目 article_name: 文章数目
runtime: runtime_name: 已运行时间
name: 已运行时间
unit:
last_push_date:
name: 最后更新时间
site_wordcount: 本站总字数 site_wordcount: 本站总字数
site_uv_name: 本站访客数 site_uv_name: 本站访客数
site_pv_name: 本站总访问量 site_pv_name: 本站总访问量
more_button: 查看更多 more_button: 查看更多
card_newest_comments:
headline: 最新评论
loading_text: 正在加载中...
error: 无法获取评论,请确认相关配置是否正确
zero: 没有评论
image: 图片
link: 链接
code: 代码
card_toc: 目录
card_post_series: 系列文章
date_suffix: donate: 打赏
just: 刚刚
min: 分钟前
hour: 小时前
day: 天前
month: 个月前
donate: 赞助
share: 分享 share: 分享
bookmark:
title: 添加书签
rightside: rightside:
readmode_title: 阅读模式 readmode_title: 阅读模式
font_plus_title: 放大字体
font_minus_title: 缩小字体
translate_title: 简繁转换 translate_title: 简繁转换
night_mode_title: 浅色和深色模式转换 night_mode_title: 浅色和深色模式转换
back_to_top: 回到顶部 back_to_top: 回到顶部
toc: 目录 toc: 目录
scroll_to_comment: 直达评论 scroll_to_comment: 直达评论
setting: 设置 setting: 设置
aside: 单栏和双栏切换
chat: runtime_unit:
copy_copyright: copy_copyright:
author: 作者 author: 作者
@@ -113,12 +98,17 @@ copy_copyright:
info: 著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。 info: 著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
Snackbar: Snackbar:
chs_to_cht: 你已切换为繁体中文 bookmark:
cht_to_chs: 你已切换为简体中文 message_prev:
message_next: 键将本页加入书签
chs_to_cht: 你已切换为繁体
cht_to_chs: 你已切换为简体
day_to_night: 你已切换为深色模式 day_to_night: 你已切换为深色模式
night_to_day: 你已切换为浅色模式 night_to_day: 你已切换为浅色模式
error_title: 页面没有找到
loading: 加载中... loading: 加载中...
load_more: 加载更多
error404: 页面没有找到 error404:
error_title: 页面没有找到
back_button: 回到主页

View File

@@ -1,3 +1,7 @@
sidebar:
catalog: 目錄
have_read: 你已經讀了
footer: footer:
framework: 框架 framework: 框架
theme: 主題 theme: 主題
@@ -13,15 +17,14 @@ page:
category: 分類 category: 分類
archives: 歸檔 archives: 歸檔
card_post_count: 條評論 sticky: 置頂
no_title: 無題
no_title: 無標題
post: post:
created: 發表於 created: 發表於
updated: 更新於 updated: 更新於
wordcount: 字數總計 wordcount: 字數總計
min2read: 讀時長 min2read: 讀時長
min2read_unit: 分鐘 min2read_unit: 分鐘
page_pv: 閱讀量 page_pv: 閱讀量
comments: 評論數 comments: 評論數
@@ -32,20 +35,19 @@ post:
copyright_content: '本部落格所有文章除特別聲明外,均採用 copyright_content: '本部落格所有文章除特別聲明外,均採用
<a href="%s" target="_blank">%s</a> 許可協議。轉載請註明來自 <a href="%s" target="_blank">%s</a>' <a href="%s" target="_blank">%s</a> 許可協議。轉載請註明來自 <a href="%s" target="_blank">%s</a>'
recommend: 相關推薦 recommend: 相關推薦
edit: 編輯
search: search: 搜尋
title: 搜尋 algolia_search:
load_data: 資料庫載入中
algolia_search:
input_placeholder: 搜尋文章 input_placeholder: 搜尋文章
hits_empty: '找不到您查詢的內容:${query}' hits_empty: '找不到您查詢的內容:${query}'
hits_stats: '找到 ${hits} 條結果,用時 ${time} 毫秒' hits_stats: '找到 ${hits} 條結果,用時 ${time} 毫秒'
local_search: local_search:
label: 本地搜尋
input_placeholder: 搜尋文章 input_placeholder: 搜尋文章
hits_empty: '找不到您查詢的內容:${query}' hits_empty: '找不到您查詢的內容:${query}'
hits_stats: '共找到 ${hits} 篇文章' powered: '提供支援'
by:
pagination: pagination:
prev: 上一篇 prev: 上一篇
@@ -65,60 +67,47 @@ aside:
card_webinfo: card_webinfo:
headline: 網站資訊 headline: 網站資訊
article_name: 文章數目 article_name: 文章數目
runtime: runtime_name: 已執行時間
name: 已執行時間
unit:
last_push_date:
name: 最後更新時間
site_wordcount: 本站總字數 site_wordcount: 本站總字數
site_uv_name: 本站訪客數 site_uv_name: 本站訪客數
site_pv_name: 本站總訪問量 site_pv_name: 本站總訪問量
more_button: 檢視更多 more_button: 檢視更多
card_newest_comments:
headline: 最新評論
loading_text: 正在載入中...
error: 無法獲取評論,請確認相關配置是否正確
zero: 沒有評論
image: 圖片
link: 連結
code: 程式碼
card_toc: 目錄
card_post_series: 文章系列
date_suffix: donate: 打賞
just: 剛剛
min: 分鐘前
hour: 小時前
day: 天前
month: 個月前
donate: 贊助
share: 分享 share: 分享
bookmark:
title: 新增書籤
rightside: rightside:
readmode_title: 閱讀模式 readmode_title: 閱讀模式
font_plus_title: 放大字型
font_minus_title: 縮小字型
translate_title: 簡繁轉換 translate_title: 簡繁轉換
night_mode_title: 淺色和深色模式轉換 night_mode_title: 淺色和深色模式轉換
back_to_top: 回頂部 back_to_top: 頂部
toc: 目錄 toc: 目錄
scroll_to_comment: 直達評論 scroll_to_comment: 直達評論
setting: 設定 setting: 設定
aside: 單欄和雙欄切換
chat: runtime_unit:
copy_copyright: copy_copyright:
author: 作者 author: 作者
link: 連結 link: 連結
source: 來源 source: 來源
info: 著作權歸作者所有。商業轉載請聯作者獲得授權,非商業轉載請註明出處。 info: 著作權歸作者所有。商業轉載請聯作者獲得授權,非商業轉載請註明出處。
Snackbar: Snackbar:
chs_to_cht: 你已切換為繁體中文 bookmark:
cht_to_chs: 你已切換為簡體中文 message_prev:
message_next: 鍵將本頁加入書籤
chs_to_cht: 你已切換為繁體
cht_to_chs: 你已切換為簡體
day_to_night: 你已切換為深色模式 day_to_night: 你已切換為深色模式
night_to_day: 你已切換為淺色模式 night_to_day: 你已切換為淺色模式
loading: 載入中... loading: 載入中...
load_more: 載入更多
error404: 頁面沒有找到 error404:
error_title: 頁面沒有找到
back_button: 回到主頁

30
layout/404.pug Normal file
View File

@@ -0,0 +1,30 @@
- var top_img = theme.error_404.background || theme.default_top_img
- var bg_img = `background-image: url(${url_for(top_img)})`
doctype html
html(lang=config.language data-theme=theme.display_mode)
head
include includes/head.pug
body
if theme.preloader
!=partial('includes/loading/loading', {}, {cache:theme.fragment_cache})
if theme.fireworks && theme.fireworks.enable
canvas.fireworks
if theme.background
- var is_photo = theme.background.startsWith('url') ? 'photo':'color'
#web_bg(data-type=is_photo)
#error-wrap
.error-content
.error-img(style=bg_img)
.error-info
h1.error_title= '404'
.error_subtitle= theme.error_404.subtitle
a.button--animated(href=config.root)
i.fas.fa-rocket
= _p('error404.back_button')
!=partial('includes/third-party/search/index', {}, {cache:theme.fragment_cache})
include includes/additional-js.pug

View File

@@ -3,6 +3,6 @@ extends includes/layout.pug
block content block content
include ./includes/mixins/article-sort.pug include ./includes/mixins/article-sort.pug
#archive #archive
.article-sort-title= `${_p('page.articles')} - ${getArchiveLength()}` .article-sort-title= _p('page.articles') + ' - ' + site.posts.length
+articleSort(page.posts) +articleSort(page.posts)
include includes/pagination.pug include includes/pagination.pug

24
layout/flink.pug Normal file
View File

@@ -0,0 +1,24 @@
#page
.flink#article-container
if site.data.link
each i in site.data.link
if i.class_name
h2!= i.class_name
if i.class_desc
.flink-desc!=i.class_desc
.flink-list
each item in i.link_list
.flink-list-item
a(href=url_for(item.link) title=item.name target="_blank")
if theme.lazyload.enable
img(data-lazy-src=url_for(item.avatar) onerror=`this.onerror=null;this.src='` + url_for(theme.error_img.flink) + `'` alt=item.name )
else
img(src=url_for(item.avatar) onerror=`this.onerror=null;this.src='` + url_for(theme.error_img.flink) + `'` alt=item.name )
span.flink-item-name= item.name
span.flink-item-desc(title=item.descr)= item.descr
!= page.content
if page.comments !== false && theme.comments && theme.comments.use
- var commentsJsLoad = true
!=partial('includes/third-party/comments/index', {}, {cache:theme.fragment_cache})

View File

@@ -1,12 +0,0 @@
- var top_img_404 = theme.error_404.background || theme.default_top_img
#body-wrap.error404
include ./header/index.pug
#error-wrap
.error-content
.error-img
img(src=url_for(top_img_404) alt='Page not found')
.error-info
h1.error_title= '404'
.error_subtitle= theme.error_404.subtitle || _p('error404')

View File

@@ -1,65 +1,61 @@
div div
script(src=url_for(theme.asset.utils)) script(src=url_for(theme.CDN.jquery))
script(src=url_for(theme.asset.main)) script(src=url_for(theme.CDN.utils))
script(src=url_for(theme.CDN.main))
if theme.translate.enable if theme.translate && theme.translate.enable
script(src=url_for(theme.asset.translate)) script(src=url_for(theme.CDN.translate))
if theme.medium_zoom if theme.medium_zoom
script(src=url_for(theme.asset.medium_zoom)) script(src=url_for(theme.CDN.medium_zoom))
else if theme.fancybox else if theme.fancybox
script(src=url_for(theme.asset.fancybox)) script(src=url_for(theme.CDN.fancybox))
if theme.instantpage if theme.instantpage
script(src=url_for(theme.asset.instantpage), type='module') script(src=url_for(theme.CDN.instantpage) type="module" defer)
if theme.lazyload.enable if theme.lazyload.enable
script(src=url_for(theme.asset.lazyload)) script(src=url_for(theme.CDN.lazyload) async)
if theme.snackbar.enable if (theme.snackbar && theme.snackbar.enable)
script(src=url_for(theme.asset.snackbar)) script(src=url_for(theme.CDN.snackbar))
if theme.pangu.enable if theme.pangu && theme.pangu.enable
!= partial("includes/third-party/pangu.pug", {}, { cache: true }) !=partial('includes/third-party/pangu.pug', {}, {cache:theme.fragment_cache})
//- search
if theme.algolia_search.enable
script(src=url_for(theme.CDN.algolia_js))
else if theme.local_search.enable
script(src=url_for(theme.CDN.local_search))
if theme.preloader
!=partial('includes/loading/loading-js', {}, {cache:theme.fragment_cache})
.js-pjax .js-pjax
if needLoadCountJs if is_home() && theme.subtitle.enable
!= partial("includes/third-party/card-post-count/index", {}, { cache: true })
if loadSubJs
include ./third-party/subtitle.pug include ./third-party/subtitle.pug
include ./third-party/math/index.pug include ./third-party/math/index.pug
include ./third-party/abcjs/index.pug
if commentsJsLoad if commentsJsLoad
include ./third-party/comments/js.pug include ./third-party/comments/js.pug
!= partial("includes/third-party/prismjs", {}, { cache: true }) if theme.busuanzi.site_uv || theme.busuanzi.site_pv || theme.busuanzi.page_pv
script(async src=url_for(theme.CDN.busuanzi))
if theme.aside.enable && theme.newest_comments.enable !=fragment_cache('injectBottom', function(){return injectHtml(theme.inject.bottom)})
if theme.pjax.enable
!= partial("includes/third-party/newest-comments/index", {}, { cache: true })
else if (!is_post() && page.aside !== false)
!= partial("includes/third-party/newest-comments/index", {}, { cache: true })
!= fragment_cache('injectBottom', function(){return injectHtml(theme.inject.bottom)}) !=partial('includes/third-party/effect', {}, {cache:theme.fragment_cache})
!= partial("includes/third-party/effect", {}, { cache: true }) !=partial('includes/third-party/chat/index', {}, {cache:theme.fragment_cache})
!= partial("includes/third-party/chat/index", {}, { cache: true })
if theme.aplayerInject && theme.aplayerInject.enable if theme.aplayerInject && theme.aplayerInject.enable
if theme.pjax.enable || theme.aplayerInject.per_page if theme.pjax || theme.aplayerInject.per_page
include ./third-party/aplayer.pug include ./head/aplayer.pug
else if page.aplayer else if page.aplayer
include ./third-party/aplayer.pug include ./head/aplayer.pug
if theme.pjax.enable if theme.pjax
!= partial("includes/third-party/pjax", {}, { cache: true }) !=partial('includes/third-party/pjax', {}, {cache:theme.fragment_cache})
if theme.busuanzi.site_uv || theme.busuanzi.site_pv || theme.busuanzi.page_pv
script(async data-pjax src= theme.asset.busuanzi || '//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js')
!=partial('includes/third-party/search/index', {}, {cache: true})

View File

@@ -15,3 +15,9 @@
a(href='https://github.com/jerryc127/hexo-theme-butterfly')= 'Butterfly' a(href='https://github.com/jerryc127/hexo-theme-butterfly')= 'Butterfly'
if theme.footer.custom_text if theme.footer.custom_text
.footer_custom_text!=`${theme.footer.custom_text}` .footer_custom_text!=`${theme.footer.custom_text}`
if theme.footer.ICP.enable
.icp
a(href=theme.footer.ICP.url)
if theme.footer.ICP.icon
img.icp-icon(src=url_for(theme.footer.ICP.icon))
span=theme.footer.ICP.text

View File

@@ -1,68 +1,90 @@
- var pageTitle - var pageTitle
- is_archive() ? page.title = findArchivesTitle(page, theme.menu, date) : '' - if (is_archive()) pageTitle = _p('page.archives')
- if (is_tag()) pageTitle = _p('page.tag') + ': ' + page.tag - else if (is_tag()) pageTitle = _p('page.tag') + ': ' + page.tag
- else if (is_category()) pageTitle = _p('page.category') + ': ' + page.category - else if (is_category()) pageTitle = _p('page.category') + ': ' + page.category
- else if (is_current('/404.html', [strict])) pageTitle = _p('error404') - else if (is_month()) pageTitle += ': ' + page.month + '/' + page.year
- else if (is_year()) pageTitle += ': ' + page.year
- else if (is_current('/404.html', [strict])) pageTitle = _p('error404.error_title')
- else pageTitle = page.title || config.title || '' - else pageTitle = page.title || config.title || ''
- var isSubtitle = config.subtitle ? ' - ' + config.subtitle : '' - var isSubtitle = config.subtitle ? ' - ' + config.subtitle : ''
- var tabTitle = is_home() || !pageTitle ? config.title + isSubtitle : pageTitle + ' | ' + config.title - var tabTitle = is_home() || !pageTitle ? config.title + isSubtitle : pageTitle + ' | ' + config.title
- var pageDescription = page_description()
- var pageKeywords
- if (page.keywords) pageKeywords = Array.isArray(page.keywords) ? (page.keywords).join(',') : ([]).join(',') || page.keywords
- else if (page.tags && page.tags.length) pageKeywords = page.tags.data.map(function(tag) {return tag.name;}).join(',')
- else pageKeywords = Array.isArray(config.keywords) ? (config.keywords).join(','): ([]).join(',') || config.keywords
- var pageAuthor = config.email ? config.author + ',' + config.email : config.author - var pageAuthor = config.email ? config.author + ',' + config.email : config.author
- var pageCopyright = config.copyright || config.author - var pageCopyright = config.copyright || config.author
- var themeColorLight = theme.theme_color && theme.theme_color.enable && theme.theme_color.meta_theme_color_light || '#ffffff'
- var themeColorDark = theme.theme_color && theme.theme_color.enable && theme.theme_color.meta_theme_color_dark || '#0d0d0d'
- var themeColor = theme.display_mode === 'dark' ? themeColorDark : themeColorLight
meta(charset='UTF-8') meta(charset='UTF-8')
meta(http-equiv="X-UA-Compatible" content="IE=edge") meta(http-equiv="X-UA-Compatible" content="IE=edge")
meta(name="viewport" content="width=device-width, initial-scale=1.0,viewport-fit=cover") meta(name="viewport" content="width=device-width,initial-scale=1")
title= tabTitle title= tabTitle
meta(name="description" content!=pageDescription)
if pageKeywords
meta(name="keywords" content=pageKeywords)
meta(name="author" content=pageAuthor) meta(name="author" content=pageAuthor)
meta(name="copyright" content=pageCopyright) meta(name="copyright" content=pageCopyright)
meta(name ="format-detection" content="telephone=no") meta(name ="format-detection" content="telephone=no")
meta(name="theme-color" content=themeColor) !=favicon_tag(theme.favicon || config.favicon)
link(rel="canonical" href=urlNoIndex())
if theme.disable_baidu_transformation
meta(http-equiv="Cache-Control" content="no-transform")
meta(http-equiv="Cache-Control" content="no-siteapp")
//- 預解析
!=partial('includes/head/preconnect', {}, {cache:theme.fragment_cache})
//- 網站驗證
!=partial('includes/head/site_verification', {}, {cache:theme.fragment_cache})
//- Open_Graph //- Open_Graph
include ./head/Open_Graph.pug include ./head/Open_Graph.pug
!=favicon_tag(theme.favicon || config.favicon) if theme.facebook_comments.app_id
link(rel="canonical" href=urlNoIndex(null,config.pretty_urls.trailing_index,config.pretty_urls.trailing_html)) meta(property="fb:app_id" content=theme.facebook_comments.app_id )
if theme.facebook_comments.user_id
//- 預解析 meta(property="fb:admins" content=theme.facebook_comments.user_id)
!=partial('includes/head/preconnect', {}, {cache: true})
//- 網站驗證
!=partial('includes/head/site_verification', {}, {cache: true})
//- PWA //- PWA
if (theme.pwa && theme.pwa.enable) if (theme.pwa && theme.pwa.enable)
!=partial('includes/head/pwa', {}, {cache: true}) !=partial('includes/head/pwa', {}, {cache:theme.fragment_cache})
if theme.darkmode.enable
!=partial('includes/head/darkmode', {}, {cache:theme.fragment_cache})
//- main css //- main css
link(rel='stylesheet', href=url_for(theme.asset.main_css)) link(rel='stylesheet', href=url_for(theme.CDN.main_css))
link(rel='stylesheet', href=url_for(theme.asset.fontawesome) media="print" onload="this.media='all'") link(rel='stylesheet', href=url_for(theme.CDN.fontawesome))
if (theme.snackbar && theme.snackbar.enable)
link(rel='stylesheet', href=url_for(theme.asset.snackbar_css) media="print" onload="this.media='all'")
if theme.fancybox if theme.fancybox
link(rel='stylesheet' href=url_for(theme.asset.fancybox_css) media="print" onload="this.media='all'") link(rel='stylesheet', href=url_for(theme.CDN.fancybox_css))
if (theme.snackbar && theme.snackbar.enable)
link(rel='stylesheet', href=url_for(theme.CDN.snackbar_css))
if theme.algolia_search.enable
link(rel='stylesheet' href=url_for(theme.CDN.algolia_search_css))
script(src=url_for(theme.CDN.algolia_search) defer)
//- google_adsense //- google_adsense
!=partial('includes/head/google_adsense', {}, {cache: true}) !=partial('includes/head/google_adsense', {}, {cache:theme.fragment_cache})
//- analytics //- analytics
!=partial('includes/head/analytics', {}, {cache: true}) !=partial('includes/head/analytics', {}, {cache:theme.fragment_cache})
//- font //- font
if theme.blog_title_font && theme.blog_title_font.font_link if theme.blog_title_font.font_link
link(rel='stylesheet' href=url_for(theme.blog_title_font.font_link) media="print" onload="this.media='all'") link(rel='stylesheet' href=url_for(theme.blog_title_font.font_link))
//- global config //- global config
!=partial('includes/head/config', {}, {cache: true}) !=partial('includes/head/config', {}, {cache:theme.fragment_cache})
include ./head/config_site.pug include ./head/config_site.pug
include ./head/noscript.pug
!=fragment_cache('injectHeadJs', function(){return inject_head_js()})
!=fragment_cache('injectHead', function(){return injectHtml(theme.inject.head)}) !=fragment_cache('injectHead', function(){return injectHtml(theme.inject.head)})

View File

@@ -1,14 +1,12 @@
if theme.Open_Graph_meta.enable - var contentType = is_post() ? 'article' : 'website'
-
const coverVal = page.cover_type === 'img' ? page.cover : theme.avatar.img
let ogOption = Object.assign({
type: is_post() ? 'article' : 'website',
image: coverVal ? full_url_for(coverVal) : '',
fb_admins: theme.facebook_comments.user_id || '',
fb_app_id: theme.facebook_comments.app_id || '',
}, theme.Open_Graph_meta.option)
-
!= open_graph(ogOption)
else
meta(name="description" content=page_description())
if theme.Open_Graph_meta
meta(property="og:type" content=contentType)
meta(property="og:title" content=pageTitle)
meta(property="og:url" content=urlNoIndex())
meta(property="og:site_name" content=config.title)
meta(property="og:description" content!=pageDescription)
meta(property="og:image" content=full_url_for(page.cover || theme.avatar.img))
meta(property="article:published_time" content=date_xml(page.date))
meta(property="article:modified_time" content=date_xml(page.updated))
meta(name="twitter:card" content="summary")

View File

@@ -16,13 +16,5 @@ if theme.google_analytics
gtag('js', new Date()); gtag('js', new Date());
gtag('config', '!{theme.google_analytics}'); gtag('config', '!{theme.google_analytics}');
if theme.cloudflare_analytics if theme.tencent_analytics
script(defer data-pjax src='https://static.cloudflareinsights.com/beacon.min.js' data-cf-beacon=`{"token": "${theme.cloudflare_analytics}"}`) script(src=`https://tajs.qq.com/stats?sId=${theme.tencent_analytics}` charset="UTF-8" data-pjax)
if theme.microsoft_clarity
script.
(function(c,l,a,r,i,t,y){
c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;
y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
})(window, document, "clarity", "script", "!{theme.microsoft_clarity}");

View File

@@ -0,0 +1,3 @@
link(rel='stylesheet' href=url_for(theme.CDN.aplayer_css))
script(src=url_for(theme.CDN.aplayer_js))
script(src=url_for(theme.CDN.meting_js))

View File

@@ -1,6 +1,6 @@
- -
let algolia = 'undefined'; var algolia = 'undefined';
let env = process.env; var env = process.env;
if (theme.algolia_search.enable) { if (theme.algolia_search.enable) {
algolia = JSON.stringify({ algolia = JSON.stringify({
appId: env.ALGOLIA_APP_ID || config.algolia.appId || config.algolia.applicationID, appId: env.ALGOLIA_APP_ID || config.algolia.appId || config.algolia.applicationID,
@@ -9,29 +9,24 @@
hits: theme.algolia_search.hits, hits: theme.algolia_search.hits,
// search languages // search languages
languages: { languages: {
input_placeholder: _p("search.algolia_search.input_placeholder"), input_placeholder: _p("algolia_search.input_placeholder"),
hits_empty: _p("search.algolia_search.hits_empty"), hits_empty: _p("algolia_search.hits_empty"),
hits_stats: _p("search.algolia_search.hits_stats"), hits_stats: _p("algolia_search.hits_stats")
} }
}) })
} }
let localSearch = 'undefined'; var localSearch = 'undefined';
if (theme.local_search && theme.local_search.enable) { if (theme.local_search && theme.local_search.enable) {
localSearch = JSON.stringify({ localSearch = JSON.stringify({
path: theme.local_search.CDN ? theme.local_search.CDN : config.root + config.search.path, path: config.search.path,
preload: theme.local_search.preload,
top_n_per_article: theme.local_search.top_n_per_article,
unescape: theme.local_search.unescape,
languages: { languages: {
// search languages // search languages
hits_empty: _p("search.local_search.hits_empty"), hits_empty: _p("local_search.hits_empty")
hits_stats: _p("search.local_search.hits_stats"),
} }
}) })
} }
var translate = 'undefined';
let translate = 'undefined';
if (theme.translate && theme.translate.enable){ if (theme.translate && theme.translate.enable){
translate = JSON.stringify({ translate = JSON.stringify({
defaultEncoding: theme.translate.defaultEncoding, defaultEncoding: theme.translate.defaultEncoding,
@@ -41,7 +36,7 @@
}) })
} }
let copyright = 'undefined'; var copyright = 'undefined';
if (theme.copy.enable && theme.copy.copyright.enable){ if (theme.copy.enable && theme.copy.copyright.enable){
copyright = JSON.stringify({ copyright = JSON.stringify({
limitCount: theme.copy.copyright.limit_count, limitCount: theme.copy.copyright.limit_count,
@@ -54,9 +49,22 @@
}) })
} }
let Snackbar = 'undefined'; var ClickShowText = 'undefined';
if (theme.ClickShowText && theme.ClickShowText.enable) {
ClickShowText = JSON.stringify({
text: theme.ClickShowText.text.join(","),
fontSize: theme.ClickShowText.fontSize
})
}
var Snackbar = 'undefined';
if (theme.snackbar && theme.snackbar.enable) { if (theme.snackbar && theme.snackbar.enable) {
Snackbar = JSON.stringify({ Snackbar = JSON.stringify({
bookmark: {
message_prev: _p("Snackbar.bookmark.message_prev"),
message_next: _p("Snackbar.bookmark.message_next")
},
chs_to_cht: _p("Snackbar.chs_to_cht"), chs_to_cht: _p("Snackbar.chs_to_cht"),
cht_to_chs: _p("Snackbar.cht_to_chs"), cht_to_chs: _p("Snackbar.cht_to_chs"),
day_to_night: _p("Snackbar.day_to_night"), day_to_night: _p("Snackbar.day_to_night"),
@@ -67,7 +75,7 @@
}) })
} }
let noticeOutdate = 'undefined'; var noticeOutdate = 'undefined';
if (theme.noticeOutdate && theme.noticeOutdate.enable) { if (theme.noticeOutdate && theme.noticeOutdate.enable) {
noticeOutdate = JSON.stringify({ noticeOutdate = JSON.stringify({
limitDay: theme.noticeOutdate.limit_day, limitDay: theme.noticeOutdate.limit_day,
@@ -77,54 +85,38 @@
}) })
} }
let highlight = 'undefined';
if ((config.highlight && config.highlight.enable) || (config.prismjs && config.prismjs.enable)) {
highlight = JSON.stringify({
plugin: config.highlight.enable ? 'highlighjs' : 'prismjs',
highlightCopy: theme.highlight_copy,
highlightLang: theme.highlight_lang,
highlightHeightLimit: theme.highlight_height_limit
})
}
script. script.
const GLOBAL_CONFIG = { var GLOBAL_CONFIG = {
root: '!{config.root}', root: '!{config.root}',
algolia: !{algolia}, algolia: !{algolia},
localSearch: !{localSearch}, localSearch: !{localSearch},
translate: !{translate}, translate: !{translate},
noticeOutdate: !{noticeOutdate}, noticeOutdate: !{noticeOutdate},
highlight: !{highlight},
copy: { copy: {
success: '!{_p("copy.success")}', success: '!{_p("copy.success")}',
error: '!{_p("copy.error")}', error: '!{_p("copy.error")}',
noSupport: '!{_p("copy.noSupport")}' noSupport: '!{_p("copy.noSupport")}'
}, },
relativeDate: { bookmark: {
homepage: !{theme.post_meta.page.date_format === 'relative'}, message_prev: '!{_p("Snackbar.bookmark.message_prev")}',
post: !{theme.post_meta.post.date_format === 'relative'} message_next: '!{_p("Snackbar.bookmark.message_next")}'
},
runtime: '!{theme.runtimeshow.enable ? _p("aside.card_webinfo.runtime.unit") : ""}',
dateSuffix: {
just: '!{_p("date_suffix.just")}',
min: '!{_p("date_suffix.min")}',
hour: '!{_p("date_suffix.hour")}',
day: '!{_p("date_suffix.day")}',
month: '!{_p("date_suffix.month")}'
}, },
runtime_unit: '!{_p("runtime_unit")}',
runtime: !{theme.runtimeshow.enable},
copyright: !{copyright}, copyright: !{copyright},
lightbox: '!{ theme.medium_zoom ? "mediumZoom" : (theme.fancybox ? "fancybox" : "null" )}', ClickShowText: !{ClickShowText},
medium_zoom: !{theme.medium_zoom},
fancybox: !{theme.fancybox},
Snackbar: !{Snackbar}, Snackbar: !{Snackbar},
infinitegrid: { justifiedGallery: {
js: '!{url_for(theme.asset.egjs_infinitegrid)}', js: '!{theme.CDN.justifiedGallery_js}',
buttonText: '!{_p("load_more")}' css: '!{theme.CDN.justifiedGallery_css}'
}, },
baiduPush: !{theme.baidu_push},
highlightCopy: !{theme.highlight_copy},
highlightLang: !{theme.highlight_lang},
isPhotoFigcaption: !{theme.photofigcaption}, isPhotoFigcaption: !{theme.photofigcaption},
islazyload: !{theme.lazyload.enable}, islazyload: !{theme.lazyload.enable},
isAnchor: !{theme.anchor.auto_update || false}, isanchor: !{theme.anchor}
percent: {
toc: !{theme.toc.scroll_percent},
rightside: !{theme.rightside_scroll_percent},
},
autoDarkmode: !{theme.darkmode.enable && theme.darkmode.autoChangeMode === 1}
} }

View File

@@ -1,30 +1,19 @@
- -
const titleVal = pageTitle.replace(/'/ig,"\\'")
let isHighlightShrink let isHighlightShrink
if (theme.highlight_shrink == 'none') isHighlightShrink = 'undefined' if (theme.highlight_shrink == 'none') isHighlightShrink = 'undefined'
else if (page.highlight_shrink === true || page.highlight_shrink === false) isHighlightShrink = page.highlight_shrink else if (page.highlight_shrink === true || page.highlight_shrink === false) isHighlightShrink = page.highlight_shrink
else isHighlightShrink = theme.highlight_shrink else isHighlightShrink = theme.highlight_shrink
var showToc = false const pageToc = page.toc === true || page.toc === false ? page.toc : theme.toc.enable
if (theme.aside.enable && page.aside !== false) { const showToc = is_post() && pageToc && (toc(page.content) !== '' || page.encrypt == true )
let tocEnable = false
if (is_post()) {
if (theme.toc.post) tocEnable = true
} else if (is_page()) {
if (theme.toc.page) tocEnable = true
}
const pageToc = page.toc === true || page.toc === false ? page.toc : tocEnable
showToc = pageToc && (toc(page.content) !== '' || page.encrypt == true )
}
- -
script#config-diff. script#config_change
.
var GLOBAL_CONFIG_SITE = { var GLOBAL_CONFIG_SITE = {
title: '!{titleVal}',
isPost: !{is_post()}, isPost: !{is_post()},
isHome: !{is_home()}, isHome: !{is_home()},
isHighlightShrink: !{isHighlightShrink}, isHighlightShrink: !{isHighlightShrink},
isToc: !{showToc}, isSidebar: !{showToc},
postUpdate: '!{full_date(page.updated)}' postUpdate: '!{full_date(page.updated)}'
} }

View File

@@ -0,0 +1,56 @@
script.
var activateDarkMode = function () {
document.documentElement.setAttribute('data-theme', 'dark')
if (document.querySelector('meta[name="theme-color"]') !== null) {
document.querySelector('meta[name="theme-color"]').setAttribute('content', '#000')
}
}
var activateLightMode = function () {
document.documentElement.setAttribute('data-theme', 'light')
if (document.querySelector('meta[name="theme-color"]') !== null) {
document.querySelector('meta[name="theme-color"]').setAttribute('content', '#fff')
}
}
var getCookies = function (name) {
const value = `; ${document.cookie}`
const parts = value.split(`; ${name}=`)
if (parts.length === 2) return parts.pop().split(';').shift()
}
var autoChangeMode = '#{theme.darkmode.autoChangeMode}'
var t = getCookies('theme')
if (autoChangeMode === '1') {
var isDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches
var isLightMode = window.matchMedia('(prefers-color-scheme: light)').matches
var isNotSpecified = window.matchMedia('(prefers-color-scheme: no-preference)').matches
var hasNoSupport = !isDarkMode && !isLightMode && !isNotSpecified
if (t === undefined) {
if (isLightMode) activateLightMode()
else if (isDarkMode) activateDarkMode()
else if (isNotSpecified || hasNoSupport) {
console.log('You specified no preference for a color scheme or your browser does not support it. I Schedule dark mode during night time.')
var now = new Date()
var hour = now.getHours()
var isNight = hour <= 6 || hour >= 18
isNight ? activateDarkMode() : activateLightMode()
}
window.matchMedia('(prefers-color-scheme: dark)').addListener(function (e) {
if (Cookies.get('theme') === undefined) {
e.matches ? activateDarkMode() : activateLightMode()
}
})
} else if (t === 'light') activateLightMode()
else activateDarkMode()
} else if (autoChangeMode === '2') {
now = new Date()
hour = now.getHours()
isNight = hour <= 6 || hour >= 18
if (t === undefined) isNight ? activateDarkMode() : activateLightMode()
else if (t === 'light') activateLightMode()
else activateDarkMode()
} else {
if (t === 'dark') activateDarkMode()
else if (t === 'light') activateLightMode()
}

View File

@@ -0,0 +1,9 @@
noscript.
<style>
#nav {
opacity: 1
}
.justified-gallery img {
opacity: 1
}
</style>

View File

@@ -1,35 +1,19 @@
- link(rel="preconnect" href="//cdn.jsdelivr.net")
const { internal_provider, third_party_provider, custom_format } = theme.CDN
const providers = {
'jsdelivr': '//cdn.jsdelivr.net',
'cdnjs': '//cdnjs.cloudflare.com',
'unpkg': '//unpkg.com',
'custom': custom_format && custom_format.match(/^((https?:)?(\/\/[^/]+)|([^/]+))(\/|$)/)[1]
}
-
if internal_provider === third_party_provider && internal_provider !== 'local'
link(rel="preconnect" href=providers[internal_provider])
else
if internal_provider !== 'local'
link(rel="preconnect" href=providers[internal_provider])
if third_party_provider !== 'local'
link(rel="preconnect" href=providers[third_party_provider])
if theme.google_analytics if theme.google_analytics
link(rel="preconnect" href="//www.google-analytics.com" crossorigin='') link(rel="preconnect" href="//www.google-analytics.com" crossorigin)
if theme.baidu_analytics if theme.baidu_analytics
link(rel="preconnect" href="//hm.baidu.com") link(rel="preconnect" href="//hm.baidu.com")
if theme.cloudflare_analytics if theme.tencent_analytics
link(rel="preconnect" href="//static.cloudflareinsights.com") link(rel="preconnect" href="//ta.qq.com")
if theme.microsoft_clarity if theme.blog_title_font.font_link && theme.blog_title_font.font_link.indexOf('//fonts.googleapis.com') != -1
link(rel="preconnect" href="//www.clarity.ms") link(rel="preconnect" href="//fonts.googleapis.com" crossorigin)
if theme.blog_title_font && theme.blog_title_font.font_link && theme.blog_title_font.font_link.indexOf('//fonts.googleapis.com') != -1 if theme.busuanzi.site_uv || theme.busuanzi.site_pv || theme.busuanzi.page_pv
link(rel="preconnect" href="//fonts.googleapis.com" crossorigin='')
if !theme.asset.busuanzi && (theme.busuanzi.site_uv || theme.busuanzi.site_pv || theme.busuanzi.page_pv)
link(rel="preconnect" href="//busuanzi.ibruce.info") link(rel="preconnect" href="//busuanzi.ibruce.info")
if theme.baidu_push
link(rel="preconnect" href="//zz.bdstatic.com")

View File

@@ -1,4 +1,6 @@
link(rel="manifest" href=url_for(theme.pwa.manifest)) link(rel="manifest" href=url_for(theme.pwa.manifest))
if(theme.pwa.theme_color)
meta(name="theme-color" content=theme.pwa.theme_color)
if(theme.pwa.theme_color) if(theme.pwa.theme_color)
meta(name="msapplication-TileColor" content=theme.pwa.theme_color) meta(name="msapplication-TileColor" content=theme.pwa.theme_color)
if(theme.pwa.apple_touch_icon) if(theme.pwa.apple_touch_icon)

View File

@@ -1,3 +1,14 @@
if theme.site_verification if theme.google_site_verification
each item in theme.site_verification meta(name="google-site-verification" content=theme.google_site_verification)
meta(name=item.name content=item.content)
if theme.bing_site_verification
meta(name="msvalidate.01" content=theme.bing_site_verification)
if theme.baidu_site_verification
meta(name="baidu-site-verification" content=theme.baidu_site_verification)
if theme.qihu_site_verification
meta(name="360-site-verification" content=theme.qihu_site_verification)
if theme.yandex_site_verification
meta(name="yandex-verification" content=theme.yandex_site_verification)

View File

@@ -1,52 +1,43 @@
if !theme.disable_top_img && page.top_img !== false if is_home()
if is_post() - var top_img = theme.index_img || theme.default_top_img
- var top_img = page.top_img || page.cover || theme.default_top_img else if is_post()
else if is_page() - var top_img = page.top_img || page.cover || page.randomcover || theme.default_top_img
- var top_img = page.top_img || theme.default_top_img else if is_archive()
else if is_tag() - var top_img = theme.archive_img || theme.default_top_img
- var top_img = theme.tag_per_img && theme.tag_per_img[page.tag] else if is_tag()
- top_img = top_img ? top_img : (theme.tag_img !== false ? theme.tag_img || theme.default_top_img : false) - var top_img = theme.tag_img || theme.default_top_img
else if is_category() else if is_category()
- var top_img = theme.category_per_img && theme.category_per_img[page.category] - var top_img = theme.category_img || theme.default_top_img
- top_img = top_img ? top_img : (theme.category_img !== false ? theme.category_img || theme.default_top_img : false)
else if is_home()
- var top_img = theme.index_img !== false ? theme.index_img || theme.default_top_img : false
else if is_archive()
- var top_img = theme.archive_img !== false ? theme.archive_img || theme.default_top_img : false
else
- var top_img = page.top_img || theme.default_top_img
if top_img !== false
- var imgSource = top_img && isImgOrUrl(top_img) ? `background-image: url('${url_for(top_img)}')` : `background: ${top_img}`
- var bg_img = top_img ? imgSource : ''
- var site_title = page.title || page.tag || page.category || config.title
- var isHomeClass = is_home() ? 'full_page' : 'not-home-page'
- is_post() ? isHomeClass = 'post-bg' : isHomeClass
else
- var isHomeClass = 'not-top-img'
else else
- var top_img = false - var top_img = page.top_img || theme.default_top_img
- var isHomeClass = 'not-top-img'
- const isFixedClass = theme.nav.fixed ? ' fixed' : '' if theme.douban
if is_current('/movies/', [strict])
- var top_img = theme.douban.movies_img || theme.default_top_img
else if is_current('/books/', [strict])
- var top_img = theme.douban.books_img || theme.default_top_img
else if is_current('/games/', [strict])
- var top_img = theme.douban.games_img || theme.default_top_img
header#page-header(class=`${isHomeClass+isFixedClass}` style=bg_img) - var bg_img = top_img && top_img !== true ? `background-image: url(${url_for(top_img)})` : ''
!=partial('includes/header/nav', {}, {cache: true}) - var site_title = is_archive() ? _p('page.archives') : page.title || page.tag || page.category || config.title
if top_img !== false - var isHomeClass = is_home() ? 'full_page' : 'not-index-bg'
if is_post() - is_post() ? isHomeClass = 'post-bg' : isHomeClass
include ./post-info.pug
else if is_home() header#page-header(class=isHomeClass style=bg_img)
!=partial('includes/header/nav', {}, {cache:theme.fragment_cache})
if is_home()
#site-info #site-info
h1#site-title=site_title h1#site_title=site_title
if theme.subtitle.enable #site_subtitle
- var loadSubJs = true
#site-subtitle
span#subtitle span#subtitle
if(theme.social) if(theme.social)
#site_social_icons #site_social_icons
!=partial('includes/header/social', {}, {cache: true}) !=fragment_cache('social', function(){return partial('includes/header/social')})
#scroll-down #scroll_down
i.fas.fa-angle-down.scroll-down-effects i.fas.fa-angle-down.scroll-down-effects
else if is_post()
include ./post-info.pug
else else
#page-site-info #page_site-info
h1#site-title=site_title h1#site_title=site_title

View File

@@ -1,27 +1,23 @@
if theme.menu if theme.menu
.menus_items .menus_items
each value, label in theme.menu each value, label in theme.menu
if typeof value !== 'object' if !Array.isArray(value)
.menus_item .menus_item
- const valueArray = value.split('||') a.site-page(href=url_for(trim(value.split('||')[0])))
a.site-page(href=url_for(trim(valueArray[0]))) if value.split('||')[1]
if valueArray[1] i.fa-fw(class=trim(value.split('||')[1]))
i.fa-fw(class=trim(valueArray[1]))
span=' '+label span=' '+label
else else
.menus_item .menus_item
- const labelArray = label.split('||') a.site-page(href='javascript:void(0);')
- const hideClass = labelArray[2] && trim(labelArray[2]) === 'hide' ? 'hide' : '' if label.split('||')[1]
a.site-page.group(class=`${hideClass}` href='javascript:void(0);') i.fa-fw(class=trim(label.split('||')[1]))
if labelArray[1] span=' '+ trim(label.split('||')[0])
i.fa-fw(class=trim(labelArray[1])) i.fas.fa-chevron-down.expand
span=' '+ trim(labelArray[0])
i.fas.fa-chevron-down
ul.menus_item_child ul.menus_item_child
each val,lab in value each i in value
- const valArray = val.split('||')
li li
a.site-page.child(href=url_for(trim(valArray[0]))) a.site-page(href=url_for(trim(i.split('||')[1])))
if valArray[1] if i.split('||')[2]
i.fa-fw(class=trim(valArray[1])) i.fa-fw(class=trim(i.split('||')[2]))
span=' '+ lab span=' '+trim(i.split('||')[0])

View File

@@ -1,21 +1,17 @@
nav#nav nav#nav
span#blog-info span#blog_name.pull-left
a(href=url_for('/') title=config.title) a#site-name.blog_title(href=url_for('/')) #[=config.title]
if theme.nav.logo
img.site-icon(src=url_for(theme.nav.logo))
if theme.nav.display_title
span.site-name=config.title
#menus span.pull-right.menus
if (theme.algolia_search.enable || theme.local_search.enable || theme.docsearch.enable) if (theme.algolia_search.enable || theme.local_search.enable)
#search-button #search_button
a.site-page.social-icon.search(href="javascript:void(0);") a.site-page.social-icon.search
i.fas.fa-search.fa-fw i.fas.fa-search.fa-fw
span=' '+_p('search.title') span=' '+_p('search')
!=partial('includes/header/menu_item', {}, {cache: true}) !=fragment_cache('menus', function(){return partial('includes/header/menu_item')})
#toggle-menu span.toggle-menu.close
a.site-page(href="javascript:void(0);") a.site-page
i.fas.fa-bars.fa-fw i.fas.fa-bars.fa-fw

View File

@@ -1,9 +1,6 @@
- let comments = theme.comments
#post-info #post-info
h1.post-title= page.title || _p('no_title') #post-title
if theme.post_edit.enable .posttitle= page.title || _p('no_title')
a.post-edit-link(href=theme.post_edit.url + page.source title=_p('post.edit') target="_blank")
i.fas.fa-pencil-alt
#post-meta #post-meta
.meta-firstline .meta-firstline
@@ -21,9 +18,9 @@
- let data_type_update = theme.post_meta.post.date_type === 'updated' - let data_type_update = theme.post_meta.post.date_type === 'updated'
- let date_type = data_type_update ? 'updated' : 'date' - let date_type = data_type_update ? 'updated' : 'date'
- let date_icon = data_type_update ? 'fas fa-history' :'far fa-calendar-alt' - let date_icon = data_type_update ? 'fas fa-history' :'far fa-calendar-alt'
- let date_title = data_type_update ? _p('post.updated') : _p('post.created') - let data_info = data_type_update ? _p('post.updated') : _p('post.created')
i.fa-fw.post-meta-icon(class=date_icon) i.fa-fw.post-meta-icon(class=date_icon)
span.post-meta-label= date_title span.post-meta-label= data_info
time(datetime=date_xml(page[date_type]) title=date_title + ' ' + full_date(page[date_type]))=date(page[date_type], config.date_format) time(datetime=date_xml(page[date_type]) title=date_title + ' ' + full_date(page[date_type]))=date(page[date_type], config.date_format)
if (theme.post_meta.post.categories && page.categories.data.length > 0) if (theme.post_meta.post.categories && page.categories.data.length > 0)
span.post-meta-categories span.post-meta-categories
@@ -52,93 +49,35 @@
span.post-meta-label= _p('post.min2read') + ':' span.post-meta-label= _p('post.min2read') + ':'
span= min2read(page.content, {cn: 350, en: 160}) + _p('post.min2read_unit') span= min2read(page.content, {cn: 350, en: 160}) + _p('post.min2read_unit')
//- for pv and count if theme.busuanzi.page_pv
mixin pvBlock(parent_id,parent_class,parent_title)
span.post-meta-separator | span.post-meta-separator |
span(class=parent_class id=parent_id data-flag-title=page.title) span.post-meta-pv-cv
i.far.fa-eye.fa-fw.post-meta-icon i.far.fa-eye.fa-fw.post-meta-icon
span.post-meta-label=_p('post.page_pv') + ':' span.post-meta-label=_p('post.page_pv') + ':'
if block
block
- const commentUse = comments.use
if page.comments !== false && commentUse && !comments.lazyload
if commentUse[0] === 'Valine' && theme.valine.visitor
+pvBlock(url_for(page.path),'leancloud_visitors',page.title)
span.leancloud-visitors-count
i.fa-solid.fa-spinner.fa-spin
else if commentUse[0] === 'Waline' && theme.waline.pageview
+pvBlock('','','')
span.waline-pageview-count(data-path=url_for(page.path))
i.fa-solid.fa-spinner.fa-spin
else if commentUse[0] === 'Twikoo' && theme.twikoo.visitor
+pvBlock('','','')
span#twikoo_visitors
i.fa-solid.fa-spinner.fa-spin
else if commentUse[0] === 'Artalk' && theme.artalk.visitor
+pvBlock('','','')
span#ArtalkPV
i.fa-solid.fa-spinner.fa-spin
else if theme.busuanzi.page_pv
+pvBlock('','post-meta-pv-cv','')
span#busuanzi_value_page_pv span#busuanzi_value_page_pv
i.fa-solid.fa-spinner.fa-spin
else if theme.busuanzi.page_pv
+pvBlock('','post-meta-pv-cv','')
span#busuanzi_value_page_pv
i.fa-solid.fa-spinner.fa-spin
if comments.count && !comments.lazyload && page.comments !== false && comments.use if !theme.comments.lazyload && page.comments !== false && theme.comments.use && theme.comments.count
- var whichCount = comments.use[0] - var whichCount = theme.comments.use[0]
if whichCount !== 'Livere' && whichCount !== 'Utterances'
mixin countBlock
span.post-meta-separator | span.post-meta-separator |
span.post-meta-commentcount span.post-meta-commentcount
if whichCount === 'Disqus' || whichCount === 'Disqusjs'
i.far.fa-comments.fa-fw.post-meta-icon
span.post-meta-label= _p('post.comments') + ':'
span.disqus-comment-count.comment-count
a(href=full_url_for(page.path) + '#disqus_thread')
else if whichCount === 'Valine'
i.far.fa-comments.fa-fw.post-meta-icon i.far.fa-comments.fa-fw.post-meta-icon
span.post-meta-label= _p('post.comments') + ':' span.post-meta-label= _p('post.comments') + ':'
if block
block
case whichCount
when 'Disqus'
+countBlock
a.disqus-comment-count(href=full_url_for(page.path) + '#post-comment')
i.fa-solid.fa-spinner.fa-spin
when 'Disqusjs'
+countBlock
a.disqusjs-comment-count(href=full_url_for(page.path) + '#post-comment')
i.fa-solid.fa-spinner.fa-spin
when 'Valine'
+countBlock
a(href=url_for(page.path) + '#post-comment' itemprop="discussionUrl") a(href=url_for(page.path) + '#post-comment' itemprop="discussionUrl")
span.valine-comment-count(data-xid=url_for(page.path) itemprop="commentCount") span.valine-comment-count.comment-count(data-xid=url_for(page.path) itemprop="commentCount")
i.fa-solid.fa-spinner.fa-spin else if whichCount === 'Gitalk'
when 'Waline' i.far.fa-comments.fa-fw.post-meta-icon
+countBlock span.post-meta-label= _p('post.comments') + ':'
a(href=url_for(page.path) + '#post-comment')
span.waline-comment-count(data-path=url_for(page.path))
i.fa-solid.fa-spinner.fa-spin
when 'Gitalk'
+countBlock
a(href=url_for(page.path) + '#post-comment')
span.gitalk-comment-count
i.fa-solid.fa-spinner.fa-spin
when 'Twikoo'
+countBlock
a(href=url_for(page.path) + '#post-comment')
span#twikoo-count
i.fa-solid.fa-spinner.fa-spin
when 'Facebook Comments'
+countBlock
a(href=url_for(page.path) + '#post-comment') a(href=url_for(page.path) + '#post-comment')
span.gitalk-comment-count.comment-count
else if whichCount === 'Facebook Comments'
i.far.fa-comments.fa-fw.post-meta-icon
span.post-meta-label= _p('post.comments') + ':'
a.comment-count(href=url_for(page.path) + '#post-comment')
span.fb-comments-count(data-href=urlNoIndex()) span.fb-comments-count(data-href=urlNoIndex())
when 'Remark42'
+countBlock
a(href=url_for(page.path) + '#post-comment')
span.remark42__counter(data-url=urlNoIndex())
i.fa-solid.fa-spinner.fa-spin
when 'Artalk'
+countBlock
a(href=url_for(page.path) + '#post-comment')
span.artalk-count
i.fa-solid.fa-spinner.fa-spin

View File

@@ -1,4 +1,4 @@
each url, icon in theme.social each url, icon in theme.social
a.social-icon(href=url_for(trim(url.split('||')[0])) target="_blank" a.social-icon(href=url_for(trim(url.split('||')[0])) target="_blank"
title=url.split('||')[1] === undefined ? '' : trim(url.split('||')[1])) title=url.split('||')[1] === undefined ? '' : trim(url.split('||')[1]))
i(class=icon style=url.split('||')[2] === undefined ? '' : `color: ${trim(url.split('||')[2]).replace(/[\'\"]/g, '')};`) i(class=icon)

View File

@@ -1,47 +1,42 @@
- var htmlClassHideAside = theme.aside.enable && theme.aside.hide ? 'hide-aside' : ''
- page.aside = is_archive() ? theme.aside.display.archive: is_category() ? theme.aside.display.category : is_tag() ? theme.aside.display.tag : page.aside
- var hideAside = !theme.aside.enable || page.aside === false ? 'hide-aside' : '' - var hideAside = !theme.aside.enable || page.aside === false ? 'hide-aside' : ''
- var pageType = is_post() ? 'post' : 'page'
doctype html doctype html
html(lang=config.language data-theme=theme.display_mode class=htmlClassHideAside) html(lang=config.language data-theme=theme.display_mode)
head head
include ./head.pug include ./head.pug
body body
if theme.preloader.enable if theme.preloader
!=partial('includes/loading/index', {}, {cache: true}) !=partial('includes/loading/loading', {}, {cache:theme.fragment_cache})
!=partial('includes/mobile-sidebar/index', {}, {cache:theme.fragment_cache})
#body-wrap
if theme.background if theme.background
#web_bg - var is_photo = theme.background.startsWith('url') ? 'photo':'color'
#web_bg(data-type=is_photo)
!=partial('includes/sidebar', {}, {cache: true}) include ./sidebar.pug
if page.type !== '404'
#body-wrap(class=pageType)
include ./header/index.pug include ./header/index.pug
main#content-inner.layout(class=hideAside) if (!is_post())
main#content-inner.layout_page(class=hideAside)
if body if body
div!= body div!= body
else else
block content block content
if theme.aside.enable && page.aside !== false
include widget/index.pug include widget/index.pug
- var footerBg = theme.footer_bg
if (footerBg)
if (footerBg === true)
- var footer_bg = bg_img
else else
- var footer_bg = isImgOrUrl(theme.footer_bg) ? `background-image: url('${url_for(footerBg)}')` : `background: ${footerBg}` main#content-inner.layout_post
if body
div!= body
else else
- var footer_bg = '' block content
footer#footer(style=footer_bg) - var footer_bg = theme.footer_bg == false ? '' : bg_img
!=partial('includes/footer', {}, {cache: true}) - var is_bg = theme.footer_bg == false ? 'color' : 'photo'
footer#footer(style=footer_bg data-type=is_bg)
else !=partial('includes/footer', {}, {cache:theme.fragment_cache})
include ./404.pug
include ./rightside.pug include ./rightside.pug
!=partial('includes/third-party/search/index', {}, {cache:theme.fragment_cache})
include ./additional-js.pug include ./additional-js.pug

View File

@@ -1,33 +0,0 @@
#loading-box
.loading-left-bg
.loading-right-bg
.spinner-box
.configure-border-1
.configure-core
.configure-border-2
.configure-core
.loading-word= _p('loading')
script.
(()=>{
const $loadingBox = document.getElementById('loading-box')
const $body = document.body
const preloader = {
endLoading: () => {
$body.style.overflow = ''
$loadingBox.classList.add('loaded')
},
initLoading: () => {
$body.style.overflow = 'hidden'
$loadingBox.classList.remove('loaded')
}
}
preloader.initLoading()
window.addEventListener('load',() => { preloader.endLoading() })
if (!{theme.pjax && theme.pjax.enable}) {
document.addEventListener('pjax:send', () => { preloader.initLoading() })
document.addEventListener('pjax:complete', () => { preloader.endLoading() })
}
})()

View File

@@ -1,4 +0,0 @@
if theme.preloader.source === 1
include ./fullpage-loading.pug
else
include ./pace.pug

View File

@@ -0,0 +1,6 @@
script.
var endLoading = function () {
document.body.style.overflow = 'auto';
document.getElementById('loading-box').classList.add("loaded")
}
window.addEventListener('load',endLoading)

View File

@@ -0,0 +1,9 @@
#loading-box
.loading-left-bg
.loading-right-bg
.spinner-box
.configure-border-1
.configure-core
.configure-border-2
.configure-core
.loading-word= _p('loading')

View File

@@ -1,11 +0,0 @@
script.
window.paceOptions = {
restartOnPushState: false
}
document.addEventListener('pjax:send', () => {
Pace.restart()
})
link(rel="stylesheet", href=url_for(theme.preloader.pace_css_url || theme.asset.pace_default_css))
script(src=url_for(theme.asset.pace_js))

View File

@@ -11,10 +11,10 @@ mixin articleSort(posts)
.article-sort-item(class=no_cover) .article-sort-item(class=no_cover)
if article.cover && theme.cover.archives_enable if article.cover && theme.cover.archives_enable
a.article-sort-item-img(href=url_for(article.path) title=title) a.article-sort-item-img(href=url_for(article.path) title=title)
if article.cover_type === 'img' if theme.lazyload.enable
img(src=url_for(article.cover) alt=title onerror=`this.onerror=null;this.src='${url_for(theme.error_img.post_page)}'`) img(data-lazy-src=url_for(article.cover) alt=title onerror=`this.onerror=null;this.src='${url_for(theme.error_img.post_page)}'`)
else else
div(style=`background: ${article.cover}`) img(src=url_for(article.cover) alt=title onerror=`this.onerror=null;this.src='${url_for(theme.error_img.post_page)}'`)
.article-sort-item-info .article-sort-item-info
.article-sort-item-time .article-sort-item-time
i.far.fa-calendar-alt i.far.fa-calendar-alt

View File

@@ -1,36 +1,33 @@
mixin postUI(posts) mixin postUI(posts)
each article , index in page.posts.data each article , index in page.posts.data
.recent-post-item .recent-post-item
- - let link = article.link || article.path
let link = article.link || article.path - let title = article.title || _p('no_title')
let title = article.title || _p('no_title') - let leftOrRight = index%2 == 0 ? 'left_radius' : 'right_radius'
const position = theme.cover.position - let post_cover = article.cover
let leftOrRight = position === 'both' - let no_cover = article.cover === false || !theme.cover.index_enable ? 'no-cover' : ''
? index%2 == 0 ? 'left' : 'right'
: position === 'left' ? 'left' : 'right'
let post_cover = article.cover
let no_cover = article.cover === false || !theme.cover.index_enable ? 'no-cover' : ''
-
if post_cover && theme.cover.index_enable if post_cover && theme.cover.index_enable
.post_cover(class=leftOrRight) .post_cover(class=leftOrRight)
a(href=url_for(link) title=title) a(href=url_for(link) title=title)
if article.cover_type === 'img' if theme.lazyload.enable
img.post-bg(src=url_for(post_cover) onerror=`this.onerror=null;this.src='${url_for(theme.error_img.post_page)}'` alt=title) img.post_bg(data-lazy-src=url_for(post_cover) onerror=`this.onerror=null;this.src='`+ url_for(theme.error_img.post_page) + `'` alt=title)
else else
div.post-bg(style=`background: ${post_cover}`) img.post_bg(src=url_for(post_cover) onerror=`this.onerror=null;this.src='`+ url_for(theme.error_img.post_page) + `'` alt=title)
.recent-post-info(class=no_cover) .recent-post-info(class=no_cover)
a.article-title(href=url_for(link) title=title) a.article-title(href=url_for(link) title=title)= title
if (is_home() && (article.top || article.sticky > 0))
i.fas.fa-thumbtack.sticky
= title
.article-meta-wrap .article-meta-wrap
if (is_home() && (article.top || article.sticky > 0))
span.article-meta
i.fas.fa-thumbtack.article-meta__icon.sticky
span.sticky= _p('sticky')
span.article-meta__separator |
if (theme.post_meta.page.date_type) if (theme.post_meta.page.date_type)
span.post-meta-date span.post-meta-date
if (theme.post_meta.page.date_type === 'both') if (theme.post_meta.page.date_type === 'both')
i.far.fa-calendar-alt i.far.fa-calendar-alt
span.article-meta-label=_p('post.created') span.article-meta-label=_p('post.created')
time.post-meta-date-created(datetime=date_xml(article.date) title=_p('post.created') + ' ' + full_date(article.date))=date(article.date, config.date_format) time.post-meta-date-created(datetime=date_xml(article.date) title=_p('post.created') + ' ' + full_date(article.date))=date(article.date, config.date_format)
span.article-meta-separator | span.article-meta__separator |
i.fas.fa-history i.fas.fa-history
span.article-meta-label=_p('post.updated') span.article-meta-label=_p('post.updated')
time.post-meta-date-updated(datetime=date_xml(article.updated) title=_p('post.updated') + ' ' + full_date(article.updated))=date(article.updated, config.date_format) time.post-meta-date-updated(datetime=date_xml(article.updated) title=_p('post.updated') + ' ' + full_date(article.updated))=date(article.updated, config.date_format)
@@ -44,73 +41,25 @@ mixin postUI(posts)
time(datetime=date_xml(article[date_type]) title=date_title + ' ' + full_date(article[date_type]))=date(article[date_type], config.date_format) time(datetime=date_xml(article[date_type]) title=date_title + ' ' + full_date(article[date_type]))=date(article[date_type], config.date_format)
if (theme.post_meta.page.categories && article.categories.data.length > 0) if (theme.post_meta.page.categories && article.categories.data.length > 0)
span.article-meta span.article-meta
span.article-meta-separator | span.article-meta__separator |
i.fas.fa-inbox i.fas.fa-inbox.article-meta__icon
each item, index in article.categories.data each item, index in article.categories.data
a(href=url_for(item.path)).article-meta__categories #[=item.name] a(href=url_for(item.path)).article-meta__categories #[=item.name]
if (index < article.categories.data.length - 1) if (index < article.categories.data.length - 1)
i.fas.fa-angle-right.article-meta-link i.fas.fa-angle-right
if (theme.post_meta.page.tags && article.tags.data.length > 0) if (theme.post_meta.page.tags && article.tags.data.length > 0)
span.article-meta.tags span.article-meta.tags
span.article-meta-separator | span.article-meta__separator |
i.fas.fa-tag i.fas.fa-tag.article-meta__icon
each item, index in article.tags.data each item, index in article.tags.data
a(href=url_for(item.path)).article-meta__tags #[=item.name] a(href=url_for(item.path)).article-meta__tags #[=item.name]
if (index < article.tags.data.length - 1) if (index < article.tags.data.length - 1)
span.article-meta-link #[='•'] span.article-meta__link #[='•']
mixin countBlockInIndex
- needLoadCountJs = true
span.article-meta
span.article-meta-separator |
i.fas.fa-comments
if block
block
span.article-meta-label= ' ' + _p('card_post_count')
if theme.comments.card_post_count && theme.comments.use
case theme.comments.use[0]
when 'Disqus'
when 'Disqusjs'
+countBlockInIndex
a.disqus-count(href=full_url_for(link) + '#post-comment')
i.fa-solid.fa-spinner.fa-spin
when 'Valine'
+countBlockInIndex
a(href=url_for(link) + '#post-comment')
span.valine-comment-count(data-xid=url_for(link))
i.fa-solid.fa-spinner.fa-spin
when 'Waline'
+countBlockInIndex
a(href=url_for(link) + '#post-comment')
span.waline-comment-count(data-path=url_for(link))
i.fa-solid.fa-spinner.fa-spin
when 'Twikoo'
+countBlockInIndex
a.twikoo-count(href=url_for(link) + '#post-comment')
i.fa-solid.fa-spinner.fa-spin
when 'Facebook Comments'
+countBlockInIndex
a(href=url_for(link) + '#post-comment')
span.fb-comments-count(data-href=urlNoIndex(article.permalink))
when 'Remark42'
+countBlockInIndex
a(href=url_for(link) + '#post-comment')
span.remark42__counter(data-url=urlNoIndex(article.permalink))
i.fa-solid.fa-spinner.fa-spin
when 'Artalk'
+countBlockInIndex
a(href=url_for(link) + '#post-comment')
span.artalk-count(data-page-key=url_for(link))
i.fa-solid.fa-spinner.fa-spin
//- Display the article introduction on homepage //- Display the article introduction on homepage
case theme.index_post_content.method if theme.index_post_content.method == 1
when false
- break
when 1
.content!= article.description .content!= article.description
when 2 else if theme.index_post_content.method == 2
if article.description if article.description
.content!= article.description .content!= article.description
else else
@@ -118,7 +67,7 @@ mixin postUI(posts)
- let expert = content.substring(0, theme.index_post_content.length) - let expert = content.substring(0, theme.index_post_content.length)
- content.length > theme.index_post_content.length ? expert += ' ...' : '' - content.length > theme.index_post_content.length ? expert += ' ...' : ''
.content!= expert .content!= expert
default else
- const content = strip_html(article.content) - const content = strip_html(article.content)
- let expert = content.substring(0, theme.index_post_content.length) - let expert = content.substring(0, theme.index_post_content.length)
- content.length > theme.index_post_content.length ? expert += ' ...' : '' - content.length > theme.index_post_content.length ? expert += ' ...' : ''
@@ -126,4 +75,4 @@ mixin postUI(posts)
if theme.ad && theme.ad.index if theme.ad && theme.ad.index
if (index + 1) % 3 == 0 if (index + 1) % 3 == 0
.recent-post-item.ads-wrap!=theme.ad.index .recent-post-item.ad_height!=theme.ad.index

View File

@@ -0,0 +1,3 @@
#mobile-sidebar
#menu_mask
include ../mobile-sidebar/mobile-menus.pug

View File

@@ -0,0 +1,29 @@
#mobile-sidebar-menus
.mobile_author_icon
if theme.lazyload.enable
img.avatar-img(data-lazy-src=url_for(theme.avatar.img) onerror=`onerror=null;src='${theme.error_img.flink}'` alt="avatar")
else
img.avatar-img(src=url_for(theme.avatar.img) onerror=`onerror=null;src='${theme.error_img.flink}'` alt="avatar")
.mobile_post_data
if site.posts.length
.mobile_data_item.is-center
.mobile_data_link
a(href=url_for(config.archive_dir) + '/')
.headline= _p('aside.articles')
.length_num= site.posts.length
if site.tags.length
.mobile_data_item.is-center
.mobile_data_link
a(href=url_for(config.tag_dir) + '/' )
.headline= _p('aside.tags')
.length_num= site.tags.length
if site.categories.length
.mobile_data_item.is-center
.mobile_data_link
a(href=url_for(config.category_dir) + '/')
.headline= _p('aside.categories')
.length_num= site.categories.length
hr
!=fragment_cache('menus', function(){return partial('includes/header/menu_item')})

View File

@@ -1 +0,0 @@
.category-lists!= list_categories()

View File

@@ -1,2 +0,0 @@
#article-container
!= page.content

View File

@@ -1,82 +0,0 @@
#article-container
.flink
- let { content, random, flink_url } = page
- let pageContent = content
if flink_url || random
- const linkData = flink_url ? false : site.data.link || false
script.
(()=>{
const replaceSymbol = (str) => {
return str.replace(/[\p{P}\p{S}]/gu, "-")
}
let result = ""
const add = (str) => {
for(let i = 0; i < str.length; i++){
const replaceClassName = replaceSymbol(str[i].class_name)
const className = str[i].class_name ? `<h2 id="${replaceClassName}"><a href="#${replaceClassName}" class="headerlink" title="${str[i].class_name}"></a>${str[i].class_name}</h2>` : ""
const classDesc = str[i].class_desc ? `<div class="flink-desc">${str[i].class_desc}</div>` : ""
let listResult = ""
const lists = str[i].link_list
if (!{random === true}) {
lists.sort(() => Math.random() - 0.5)
}
for(let j = 0; j < lists.length; j++){
listResult += `
<div class="flink-list-item">
<a href="${lists[j].link}" title="${lists[j].name}" target="_blank">
<div class="flink-item-icon">
<img class="no-lightbox" src="${lists[j].avatar}" onerror='this.onerror=null;this.src="!{url_for(theme.error_img.flink)}"' alt="${lists[j].name}" />
</div>
<div class="flink-item-name">${lists[j].name}</div>
<div class="flink-item-desc" title="${lists[j].descr}">${lists[j].descr}</div>
</a>
</div>`
}
result += `${className}${classDesc} <div class="flink-list">${listResult}</div>`
}
document.querySelector(".flink").insertAdjacentHTML("afterbegin", result)
window.lazyLoadInstance && window.lazyLoadInstance.update()
}
const linkData = !{JSON.stringify(linkData)}
if (!{Boolean(flink_url)}) {
fetch("!{url_for(flink_url)}")
.then(response => response.json())
.then(add)
} else if (linkData) {
add(linkData)
}
})()
else
if site.data.link
- let result = ""
each i in site.data.link
- let className = i.class_name ? markdown(`## ${i.class_name}`) : ""
- let classDesc = i.class_desc ? `<div class="flink-desc">${i.class_desc}</div>` : ""
- let listResult = ""
each j in i.link_list
-
listResult += `
<div class="flink-list-item">
<a href="${j.link}" title="${j.name}" target="_blank">
<div class="flink-item-icon">
<img class="no-lightbox" src="${j.avatar}" onerror='this.onerror=null;this.src="${url_for(theme.error_img.flink)}"' alt="${j.name}" />
</div>
<div class="flink-item-name">${j.name}</div>
<div class="flink-item-desc" title="${j.descr}">${j.descr}</div>
</a>
</div>`
-
- result += `${className}${classDesc} <div class="flink-list">${listResult}</div>`
- pageContent = result + pageContent
!= pageContent

View File

@@ -1,2 +0,0 @@
.tag-cloud-list.is-center
!=cloudTags({source: site.tags, orderby: page.orderby || 'random', order: page.order || 1, minfontsize: 1.2, maxfontsize: 2.1, limit: 0, unit: 'em'})

View File

@@ -6,36 +6,34 @@
escape: false escape: false
} }
if is_post() if(!is_post())
- let prev = theme.post_pagination === 1 ? page.prev : page.next nav#pagination
- let next = theme.post_pagination === 1 ? page.next : page.prev div.pagination
!=paginator(options)
else
nav#pagination.pagination-post nav#pagination.pagination-post
if(prev) if(page.prev)
- var hasPageNext = next ? 'pull-left' : 'pull-full' - var hasPageNext = page.next ? 'pull-left' : 'pull-full'
.prev-post(class=hasPageNext) .prev-post(class=hasPageNext)
a(href=url_for(prev.path) title=prev.title) - var pagination_cover = page.prev.cover === false ? page.prev.randomcover : page.prev.cover
if prev.cover_type === 'img' a(href=url_for(page.prev.path))
img.cover(src=url_for(prev.cover) onerror=`onerror=null;src='${url_for(theme.error_img.post_page)}'` alt='cover of previous post') if theme.lazyload.enable
img.prev-cover(data-lazy-src=url_for(pagination_cover) onerror=`onerror=null;src='${url_for(theme.error_img.post_page)}'` )
else else
.cover(style=`background: ${prev.cover || 'var(--default-bg-color)'}`) img.prev-cover(src=url_for(pagination_cover) onerror=`onerror=null;src='${url_for(theme.error_img.post_page)}'` )
.pagination-info .pagination-info
.label=_p('pagination.prev') .label=_p('pagination.prev')
.prev_info=prev.title .prev_info=page.prev.title
if(next) if(page.next)
- var hasPagePrev = prev ? 'pull-right' : 'pull-full' - var hasPagePrev = page.prev ? 'pull-right' : 'pull-full'
- var pagination_cover = page.next.cover == false ? page.next.randomcover : page.next.cover
.next-post(class=hasPagePrev) .next-post(class=hasPagePrev)
a(href=url_for(next.path) title=next.title) a(href=url_for(page.next.path))
if next.cover_type === 'img' if theme.lazyload.enable
img.cover(src=url_for(next.cover) onerror=`onerror=null;src='${url_for(theme.error_img.post_page)}'` alt='cover of next post') img.next-cover(data-lazy-src=url_for(pagination_cover) onerror=`onerror=null;src='${url_for(theme.error_img.post_page)}'`)
else else
.cover(style=`background: ${next.cover || 'var(--default-bg-color)'}`) img.next-cover(src=url_for(pagination_cover) onerror=`onerror=null;src='${url_for(theme.error_img.post_page)}'`)
.pagination-info .pagination-info
.label=_p('pagination.next') .label=_p('pagination.next')
.next_info=next.title .next_info=page.next.title
else
nav#pagination
.pagination
if is_home()
- options.format = 'page/%d/#content-inner'
!=paginator(options)

View File

@@ -1,23 +1,17 @@
if theme.post_copyright.enable && page.copyright !== false if theme.post_copyright.enable && page.copyright !== false
- let author = page.copyright_author || config.author - let author = page.copyright_author ? page.copyright_author : config.author
- let authorHref = page.copyright_author_href || theme.post_copyright.author_href || config.url - let authorHref = page.copyright_author_href ? page.copyright_author_href : `mailto:${config.email}`
- let url = page.copyright_url || page.permalink - let url = page.copyright_url ? page.copyright_url : page.permalink
- let info = page.copyright_info || _p('post.copyright.copyright_content', theme.post_copyright.license_url, theme.post_copyright.license, config.url, config.title) - let info = page.copyright_info ? page.copyright_info : _p('post.copyright.copyright_content', theme.post_copyright.license_url, theme.post_copyright.license, config.url, config.title)
.post-copyright .post-copyright
.post-copyright__author .post-copyright__author
span.post-copyright-meta span.post-copyright-meta= _p('post.copyright.author') + ": "
i.fas.fa-circle-user.fa-fw
= _p('post.copyright.author') + ": "
span.post-copyright-info span.post-copyright-info
a(href=authorHref)=author a(href=authorHref)=author
.post-copyright__type .post-copyright__type
span.post-copyright-meta span.post-copyright-meta= _p('post.copyright.link') + ": "
i.fas.fa-square-arrow-up-right.fa-fw
= _p('post.copyright.link') + ": "
span.post-copyright-info span.post-copyright-info
a(href=url_for(url))= theme.post_copyright.decode ? decodeURI(url) : url a(href=url_for(url))= theme.post_copyright.decode ? decodeURI(url) : url
.post-copyright__notice .post-copyright__notice
span.post-copyright-meta span.post-copyright-meta= _p('post.copyright.copyright_notice') + ": "
i.fas.fa-circle-exclamation.fa-fw
= _p('post.copyright.copyright_notice') + ": "
span.post-copyright-info!= info span.post-copyright-info!= info

View File

@@ -1,13 +1,16 @@
.post-reward .post-reward
.reward-button .reward-button
i.fas.fa-qrcode i.fas.fa-qrcode
= theme.reward.text || _p('donate') = ' ' + _p('donate')
.reward-main .reward-main
ul.reward-all ul.reward-all
each item in theme.reward.QR_code each item in theme.reward.QR_code
- var clickTo = item.link ? item.link : item.img - var clickTo = (item.itemlist||item).link ? (item.itemlist||item).link : (item.itemlist||item).img
li.reward-item li.reward-item
a(href=url_for(clickTo) target='_blank') a(href=clickTo target='_blank')
img.post-qr-code-img(src=url_for(item.img) alt=item.text) if theme.lazyload.enable
.post-qr-code-desc=item.text img.post-qr-code-img(data-lazy-src=url_for((item.itemlist||item).img) alt=(item.itemlist||item).text)
else
img.post-qr-code-img(src=url_for((item.itemlist||item).img) alt=(item.itemlist||item).text)
.post-qr-code-desc=(item.itemlist||item).text

View File

@@ -1,61 +1,32 @@
- const { readmode, translate, darkmode, aside, chat_btn } = theme section#rightside
mixin rightsideItem(array) #rightside-config-hide
each item in array if is_post()
case item if theme.readmode
when 'readmode'
if is_post() && readmode
button#readmode(type="button" title=_p('rightside.readmode_title')) button#readmode(type="button" title=_p('rightside.readmode_title'))
i.fas.fa-book-open i.fas.fa-book-open
when 'translate' button#font_plus(type="button" title=_p('rightside.font_plus_title'))
if translate.enable i.fas.fa-plus
button#translateLink(type="button" title=_p('rightside.translate_title'))= translate.default button#font_minus(type="button" title=_p('rightside.font_minus_title'))
when 'darkmode' i.fas.fa-minus
if darkmode.enable && darkmode.button if theme.translate && theme.translate.enable
button#translateLink(type="button" title=_p('rightside.translate_title'))= theme.translate.default
if theme.darkmode.enable && theme.darkmode.button
button#darkmode(type="button" title=_p('rightside.night_mode_title')) button#darkmode(type="button" title=_p('rightside.night_mode_title'))
i.fas.fa-adjust i.fas.fa-adjust
when 'hideAside' #rightside-config-show
if aside.enable && aside.button && page.aside !== false button#rightside_config(type="button" title=_p("rightside.setting"))
button#hide-aside-btn(type="button" title=_p('rightside.aside')) i.fas.fa-cog
i.fas.fa-arrows-alt-h if is_post() && page.comments !== false && theme.comments.use
when 'toc' a#to_comment(href="#post-comment" title=_p("rightside.scroll_to_comment"))
i.fas.fa-comments
if showToc if showToc
button#mobile-toc-button.close(type="button" title=_p("rightside.toc")) button#mobile-toc-button.close(type="button" title=_p("rightside.toc"))
i.fas.fa-list-ul i.fas.fa-list-ul
when 'chat' if theme.chat_btn
if chat_btn button#chat_btn(type="button" title=_p("rightside.chat_btn"))
button#chat-btn(type="button" title=_p("rightside.chat"))
i.fas.fa-sms i.fas.fa-sms
when 'comment'
if commentsJsLoad
a#to_comment(href="#post-comment" title=_p("rightside.scroll_to_comment"))
i.fas.fa-comments
#rightside
- const { enable, hide, show } = theme.rightside_item_order
- const hideArray = enable ? hide && hide.split(',') : ['readmode','translate','darkmode','hideAside']
- const showArray = enable ? show && show.split(',') : ['toc','chat','comment']
#rightside-config-hide
if hideArray
+rightsideItem(hideArray)
#rightside-config-show
if enable
if hide
button#rightside-config(type="button" title=_p("rightside.setting"))
i.fas.fa-cog.fa-spin
else
if is_post()
if (readmode || translate.enable || (darkmode.enable && darkmode.button))
button#rightside-config(type="button" title=_p("rightside.setting"))
i.fas.fa-cog.fa-spin
else if translate.enable || (darkmode.enable && darkmode.button)
button#rightside-config(type="button" title=_p("rightside.setting"))
i.fas.fa-cog.fa-spin
if showArray
+rightsideItem(showArray)
button#go-up(type="button" title=_p("rightside.back_to_top")) button#go-up(type="button" title=_p("rightside.back_to_top"))
span.scroll-percent
i.fas.fa-arrow-up i.fas.fa-arrow-up

View File

@@ -1,18 +1,21 @@
#sidebar -
#menu-mask let tocNumber = page.toc_number !== undefined ? page.toc_number : theme.toc.number
#sidebar-menus let autoOpenPostSet = page.auto_open == undefined ? theme.toc.auto_open : page.auto_open
.avatar-img.is-center let autoOpenSidebar = autoOpenPostSet ? 'on' : ''
img(src=url_for(theme.avatar.img) onerror=`onerror=null;src='${theme.error_img.flink}'` alt="avatar") -
.sidebar-site-data.site-data.is-center
a(href=url_for(config.archive_dir) + '/') if(showToc)
.headline= _p('aside.articles') #sidebar
.length-num= site.posts.length i.fas.fa-arrow-right#toggle-sidebar(class=autoOpenSidebar)
a(href=url_for(config.tag_dir) + '/' ) .sidebar-toc
.headline= _p('aside.tags') div.sidebar-toc__title= _p('sidebar.catalog')
.length-num= site.tags.length div.sidebar-toc__progress
a(href=url_for(config.category_dir) + '/') span.progress-notice= _p('sidebar.have_read')
.headline= _p('aside.categories') span.progress-num 0
.length-num= site.categories.length span.progress-percentage %
div.sidebar-toc__progress-bar
if (page.encrypt == true)
div.sidebar-toc__content.toc-div-class(style="display:none")!=toc(page.origin, {list_number: tocNumber})
else
div.sidebar-toc__content!=toc(page.content, {list_number: tocNumber})
hr.custom-hr
!=partial('includes/header/menu_item', {}, {cache: true})

View File

@@ -1,15 +0,0 @@
script.
(() => {
const abcjsInit = () => {
const abcjsFn = () => {
document.querySelectorAll(".abc-music-sheet").forEach(ele => {
ABCJS.renderAbc(ele, ele.innerHTML, {responsive: 'resize'})
})
}
typeof ABCJS === 'object' ? abcjsFn()
: getScript('!{url_for(theme.asset.abcjs_basic_js)}').then(abcjsFn)
}
window.pjax ? abcjsInit() : window.addEventListener('load', abcjsInit)
})()

View File

@@ -1,6 +0,0 @@
if theme.abcjs && theme.abcjs.enable
if theme.abcjs.per_page
if is_post() || is_page()
include ./abcjs.pug
else if page.abcjs
include ./abcjs.pug

View File

@@ -1,3 +0,0 @@
link(rel='stylesheet' href=url_for(theme.asset.aplayer_css) media="print" onload="this.media='all'")
script(src=url_for(theme.asset.aplayer_js))
script(src=url_for(theme.asset.meting_js))

View File

@@ -1,35 +0,0 @@
- const { server, site } = theme.artalk
script.
(() => {
const getArtalkCount = async() => {
try {
const eleGroup = document.querySelectorAll('#recent-posts .artalk-count')
const keyArray = Array.from(eleGroup).map(i => i.getAttribute('data-page-key'))
const headerList = {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Origin': window.location.origin
},
body: new URLSearchParams({
'site_name': '!{site}',
'type':'page_comment',
'page_keys': keyArray
})
}
const res = await fetch('!{server}/api/stat', headerList)
const result = await res.json()
keyArray.forEach((key, index) => {
eleGroup[index].textContent = result.data[key] || 0
})
} catch (err) {
console.error(err)
}
}
window.pjax ? getArtalkCount() : window.addEventListener('load', getArtalkCount)
})()

View File

@@ -1,25 +0,0 @@
- const { shortname, apikey } = theme.disqus
script.
(() => {
const getCount = async () => {
try {
const eleGroup = document.querySelectorAll('#recent-posts .disqus-count')
const cleanedLinks = Array.from(eleGroup).map(i => `thread:link=${i.href.replace(/#post-comment$/, '')}`);
const res = await fetch(`https://disqus.com/api/3.0/threads/set.json?forum=!{shortname}&api_key=!{apikey}&${cleanedLinks.join('&')}`,{
method: 'GET'
})
const result = await res.json()
eleGroup.forEach(i => {
const cleanedLink = i.href.replace(/#post-comment$/, '')
const urlData = result.response.find(data => data.link === cleanedLink) || { posts: 0 }
i.textContent = urlData.posts
})
} catch (err) {
console.error(err)
}
}
window.pjax ? getCount() : window.addEventListener('load', getCount)
})()

View File

@@ -1,18 +0,0 @@
- const fbSDKVer = 'v16.0'
- const fbSDK = theme.messenger.enable ? `https://connect.facebook.net/${theme.facebook_comments.lang}/sdk/xfbml.customerchat.js#xfbml=1&version=${fbSDKVer}` : `https://connect.facebook.net/${theme.facebook_comments.lang}/sdk.js#xfbml=1&version=${fbSDKVer}`
script.
(()=>{
function loadFBComment () {
if (typeof FB === 'object') FB.XFBML.parse(document.getElementById('recent-posts'))
else {
let ele = document.createElement('script')
ele.setAttribute('src','!{fbSDK}')
ele.setAttribute('async', 'true')
ele.setAttribute('defer', 'true')
ele.setAttribute('crossorigin', 'anonymous')
document.body.appendChild(ele)
}
}
window.pjax ? loadFBComment() : window.addEventListener('load', loadFBComment)
})()

View File

@@ -1,16 +0,0 @@
case theme.comments.use[0]
when 'Twikoo'
include ./twikoo.pug
when 'Disqus'
when 'Disqusjs'
include ./disqus.pug
when 'Valine'
include ./valine.pug
when 'Waline'
include ./waline.pug
when 'Facebook Comments'
include ./fb.pug
when 'Remark42'
include ./remark42.pug
when 'Artalk'
include ./artalk.pug

View File

@@ -1,18 +0,0 @@
- const { host, siteId, option } = theme.remark42
script.
(()=>{
window.remark_config = Object.assign({
host: '!{host}',
site_id: '!{siteId}',
},!{JSON.stringify(option)})
function getCount () {
const s = document.createElement('script')
s.src = remark_config.host + '/web/counter.js'
s.defer = true
document.head.appendChild(s)
}
window.pjax ? getCount() : window.addEventListener('load', getCount)
})()

View File

@@ -1,37 +0,0 @@
script.
(() => {
const getCommentUrl = () => {
const eleGroup = document.querySelectorAll('#recent-posts .article-title')
let urlArray = []
eleGroup.forEach(i=>{
urlArray.push(i.getAttribute('href'))
})
return urlArray
}
const getCount = () => {
const runTwikoo = () => {
twikoo.getCommentsCount({
envId: '!{theme.twikoo.envId}',
region: '!{theme.twikoo.region}',
urls: getCommentUrl(),
includeReply: false
}).then(function (res) {
document.querySelectorAll('#recent-posts .twikoo-count').forEach((item,index) => {
item.textContent = res[index].count
})
}).catch(function (err) {
console.log(err)
})
}
if (typeof twikoo === 'object') {
runTwikoo()
} else {
getScript('!{url_for(theme.asset.twikoo)}').then(runTwikoo)
}
}
window.pjax ? getCount() : window.addEventListener('load', getCount)
})()

View File

@@ -1,20 +0,0 @@
script.
(() => {
function loadValine () {
function initValine () {
let initData = {
el: '#vcomment',
appId: '#{theme.valine.appId}',
appKey: '#{theme.valine.appKey}',
serverURLs: '#{theme.valine.serverURLs}'
}
const valine = new Valine(initData)
}
if (typeof Valine === 'function') initValine()
else getScript('!{url_for(theme.asset.valine)}').then(initValine)
}
window.pjax ? loadValine() : window.addEventListener('load', loadValine)
})()

View File

@@ -1,21 +0,0 @@
- const serverURL = theme.waline.serverURL.replace(/\/$/, '')
script.
(() => {
async function loadWaline () {
try {
const eleGroup = document.querySelectorAll('#recent-posts .waline-comment-count')
const keyArray = Array.from(eleGroup).map(i => i.getAttribute('data-path'))
const res = await fetch(`!{serverURL}/api/comment?type=count&url=${keyArray}`, { method: 'GET' })
const result = await res.json()
result.data.forEach((count, index) => {
eleGroup[index].textContent = count
})
} catch (err) {
console.error(err)
}
}
window.pjax ? loadWaline() : window.addEventListener('load', loadWaline)
})()

View File

@@ -1,50 +1,33 @@
//- https://chatra.io/help/api/ //- https://chatra.io/help/api/
script. script.
(() => {
const isChatBtn = !{theme.chat_btn}
const isChatHideShow = !{theme.chat_hide_show}
if (isChatBtn) {
const close = () => {
Chatra('minimizeWidget')
Chatra('hide')
}
const open = () => {
Chatra('openChat', true)
Chatra('show')
}
window.ChatraSetup = {
startHidden: true
}
window.chatBtnFn = () => {
const isShow = document.getElementById('chatra').classList.contains('chatra--expanded')
isShow ? close() : open()
}
} else if (isChatHideShow) {
window.chatBtn = {
hide: () => {
Chatra('hide')
},
show: () => {
Chatra('show')
}
}
}
(function(d, w, c) { (function(d, w, c) {
w.ChatraID = '#{theme.chatra.id}' w.ChatraID = '#{theme.chatra.id}';
var s = d.createElement('script') var s = d.createElement('script');
w[c] = w[c] || function() { w[c] = w[c] || function() {
(w[c].q = w[c].q || []).push(arguments) (w[c].q = w[c].q || []).push(arguments);
};
s.async = true;
s.src = 'https://call.chatra.io/chatra.js';
if (d.head) d.head.appendChild(s);
})(document, window, 'Chatra');
if (!{theme.chat_btn}) {
var chatBtnFn = () => {
var chatBtn = document.getElementById("chat_btn")
chatBtn.addEventListener("click", function(){
Chatra('openChat')
});
}
chatBtnFn()
} else {
if (!{theme.chat_hide_show}) {
function chatBtnHide () {
Chatra('hide')
}
function chatBtnShow () {
Chatra('show')
}
}
} }
s.async = true
s.src = 'https://call.chatra.io/chatra.js'
if (d.head) d.head.appendChild(s)
})(document, window, 'Chatra')
})()

View File

@@ -1,5 +1,4 @@
script. script.
(() => {
window.$crisp = []; window.$crisp = [];
window.CRISP_WEBSITE_ID = "!{theme.crisp.website_id}"; window.CRISP_WEBSITE_ID = "!{theme.crisp.website_id}";
(function () { (function () {
@@ -11,35 +10,27 @@ script.
})(); })();
$crisp.push(["safe", true]) $crisp.push(["safe", true])
const isChatBtn = !{theme.chat_btn} if (!{theme.chat_btn}) {
const isChatHideShow = !{theme.chat_hide_show} $crisp.push(["do", "chat:hide"])
$crisp.push(["on", "chat:closed", function() {
if (isChatBtn) { $crisp.push(["do", "chat:hide"])
const open = () => { }])
var chatBtnFn = () => {
var chatBtn = document.getElementById("chat_btn")
chatBtn.addEventListener("click", function(){
$crisp.push(["do", "chat:show"]) $crisp.push(["do", "chat:show"])
$crisp.push(["do", "chat:open"]) $crisp.push(["do", "chat:open"])
}
const close = () => { });
}
chatBtnFn()
} else {
if (!{theme.chat_hide_show}) {
function chatBtnHide () {
$crisp.push(["do", "chat:hide"]) $crisp.push(["do", "chat:hide"])
} }
function chatBtnShow () {
close()
$crisp.push(["on", "chat:closed", function() {
close()
}])
window.chatBtnFn = () => {
$crisp.is("chat:visible") ? close() : open()
}
} else if (isChatHideShow) {
window.chatBtn = {
hide: () => {
$crisp.push(["do", "chat:hide"])
},
show: () => {
$crisp.push(["do", "chat:show"]) $crisp.push(["do", "chat:show"])
} }
} }
} }
})()

View File

@@ -1,40 +1,40 @@
//- https://guide.daocloud.io/daovoice/javascript-api-5869833.html //- https://guide.daocloud.io/daovoice/javascript-api-5869833.html
script. script.
(() => {
(function(i,s,o,g,r,a,m){i["DaoVoiceObject"]=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;a.charset="utf-8";m.parentNode.insertBefore(a,m)})(window,document,"script",('https:' == document.location.protocol ? 'https:' : 'http:') + "//widget.daovoice.io/widget/!{theme.daovoice.app_id}.js","daovoice") (function(i,s,o,g,r,a,m){i["DaoVoiceObject"]=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;a.charset="utf-8";m.parentNode.insertBefore(a,m)})(window,document,"script",('https:' == document.location.protocol ? 'https:' : 'http:') + "//widget.daovoice.io/widget/!{theme.daovoice.app_id}.js","daovoice")
const isChatBtn = !{theme.chat_btn} script.
const isChatHideShow = !{theme.chat_hide_show} var isChatBtn = !{theme.chat_btn}
daovoice('init', { daovoice('init', {
app_id: '!{theme.daovoice.app_id}',},{ app_id: '!{theme.daovoice.app_id}',},{
launcher: { launcher: {
disableLauncherIcon: isChatBtn disableLauncherIcon: isChatBtn // 悬浮 ICON 是否显示
}, },
}); });
daovoice('update'); daovoice('update');
if (isChatBtn) { if (isChatBtn) {
window.chatBtnFn = () => { var chatBtnFn = () => {
const isShow = document.getElementById('daodream-messenger').classList.contains('daodream-messenger-active') var chatBtn = document.getElementById("chat_btn")
isShow ? daovoice('hide') : daovoice('show') chatBtn.addEventListener("click", function(){
daovoice('show')
});
} }
} else if (isChatHideShow) { chatBtnFn()
window.chatBtn = { } else {
hide: () => { if (!{theme.chat_hide_show}) {
function chatBtnHide () {
daovoice('update', {},{ daovoice('update', {},{
launcher: { launcher: {
disableLauncherIcon: true disableLauncherIcon: true // 悬浮 ICON 是否显示
}
})
}, },
show: () => { });
daovoice('update', {}, { }
function chatBtnShow () {
daovoice('update', {},{
launcher: { launcher: {
disableLauncherIcon: false disableLauncherIcon: false // 悬浮 ICON 是否显示
} },
}) });
} }
} }
} }
})()

View File

@@ -0,0 +1,43 @@
if theme.chat_btn
script.
((window.gitter = {}).chat = {}).options = {
disableDefaultChat: true,
};
document.addEventListener('gitter-sidecar-ready', (e) => {
const GitterChat = e.detail.Chat
let chat
function initGitter () {
chat = new GitterChat({
room: '#{theme.gitter.room}',
activationElement: '#chat_btn'
});
}
initGitter()
if (!{theme.pjax}) {
document.addEventListener('pjax:complete', () => {
chat.destroy()
initGitter()
})
}
})
else
script.
((window.gitter = {}).chat = {}).options = {
room: '#{theme.gitter.room}',
};
if (!{theme.chat_hide_show}) {
function chatBtnHide () {
document.getElementsByClassName('gitter-open-chat-button')[0].style.display= 'none'
}
function chatBtnShow () {
document.getElementsByClassName('gitter-open-chat-button')[0].style.display= 'block'
}
}
script(src="https://sidecar.gitter.im/dist/sidecar.v1.js" async defer)

View File

@@ -4,7 +4,7 @@ else if theme.tidio && theme.tidio.enable
include ./tidio.pug include ./tidio.pug
else if theme.daovoice && theme.daovoice.enable else if theme.daovoice && theme.daovoice.enable
include ./daovoice.pug include ./daovoice.pug
else if theme.gitter && theme.gitter.enable
include ./gitter.pug
else if theme.crisp && theme.crisp.enable else if theme.crisp && theme.crisp.enable
include ./crisp.pug include ./crisp.pug
else if theme.messenger && theme.messenger.enable
include ./messenger.pug

View File

@@ -1,44 +0,0 @@
- let { pageID, lang } = theme.messenger
- lang = theme.comments.use && theme.comments.use.includes('Facebook Comments') ? theme.facebook_comments.lang : lang
#fb-customer-chat.fb-customerchat(page_id=pageID attribution='biz_inbox')
script.
(() => {
document.getElementById('fb-root') ? '' : document.body.insertAdjacentHTML('afterend', '<div id="fb-root"></div>')
window.fbAsyncInit = function() {
FB.init({
xfbml: true,
version: 'v16.0'
});
};
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = 'https://connect.facebook.net/!{lang}/sdk/xfbml.customerchat.js';
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
const isChatBtn = !{theme.chat_btn}
const isChatHideShow = !{theme.chat_hide_show}
if (isChatBtn) {
window.chatBtnFn = () => {
const isShow = document.querySelector('.fb_customer_chat_bounce_in_v2')
isShow ? FB.CustomerChat.hide() : FB.CustomerChat.show()
}
} else if (isChatHideShow) {
window.chatBtn = {
hide: () => {
FB.CustomerChat.hide()
},
show: () => {
FB.CustomerChat.show(false)
}
}
}
})()

View File

@@ -1,45 +1,41 @@
script(src=`//code.tidio.co/${theme.tidio.public_key}.js` async) script(src=`//code.tidio.co/${theme.tidio.public_key}.js` async)
script.
(() => {
const isChatBtn = !{theme.chat_btn}
const isChatHideShow = !{theme.chat_hide_show}
if (isChatBtn) { if theme.chat_btn
let isShow = false script.
const close = () => { function onTidioChatApiReady() {
window.tidioChatApi.hide() window.tidioChatApi.hide();
isShow = false window.tidioChatApi.on("close", function() {
} window.tidioChatApi.hide();
});
const open = () => {
window.tidioChatApi.open()
window.tidioChatApi.show()
isShow = true
}
const onTidioChatApiReady = () => {
window.tidioChatApi.hide()
window.tidioChatApi.on("close", close)
} }
if (window.tidioChatApi) { if (window.tidioChatApi) {
window.tidioChatApi.on("ready", onTidioChatApiReady) window.tidioChatApi.on("ready", onTidioChatApiReady);
} else { } else {
document.addEventListener("tidioChat-ready", onTidioChatApiReady) document.addEventListener("tidioChat-ready", onTidioChatApiReady);
} }
window.chatBtnFn = () => { var chatBtnFn = () => {
if (!window.tidioChatApi) return document.getElementById("chat_btn").addEventListener("click", function(){
isShow ? close() : open() window.tidioChatApi.show();
window.tidioChatApi.open();
});
} }
} else if (isChatHideShow) { chatBtnFn()
window.chatBtn = {
hide: () => { else if theme.chat_hide_show
window.tidioChatApi && window.tidioChatApi.hide() script.
}, function chatBtnHide () {
show: () => { if (window.tidioChatApi) {
window.tidioChatApi && window.tidioChatApi.show() //- window.tidioChatApi.hide();
} document.getElementById('tidio-chat').style.display= 'none'
} }
} }
})()
function chatBtnShow () {
if (window.tidioChatApi) {
//- window.tidioChatApi.show();
document.getElementById('tidio-chat').style.display= 'block'
}
}

View File

@@ -1,52 +0,0 @@
- const { server, site, option } = theme.artalk
- const { use, lazyload } = theme.comments
script.
(() => {
const initArtalk = () => {
window.artalkItem = new Artalk(Object.assign({
el: '#artalk-wrap',
server: '!{server}',
site: '!{site}',
pageKey: location.pathname,
darkMode: document.documentElement.getAttribute('data-theme') === 'dark',
countEl: '.artalk-count'
},!{JSON.stringify(option)}))
if (GLOBAL_CONFIG.lightbox === 'null') return
window.artalkItem.use(ctx => {
ctx.on('list-loaded', () => {
ctx.getCommentList().forEach(comment => {
const $content = comment.getRender().$content
btf.loadLightbox($content.querySelectorAll('img:not([atk-emoticon])'))
})
})
})
}
const loadArtalk = async () => {
if (typeof window.artalkItem === 'object') initArtalk()
else {
await getCSS('!{theme.asset.artalk_css}')
await getScript('!{theme.asset.artalk_js}')
initArtalk()
}
}
const artalkChangeMode = theme => {
const artalkWrap = document.getElementById('artalk-wrap')
if (!(artalkWrap && artalkWrap.children.length)) return
const isDark = theme === 'dark'
window.artalkItem.setDarkMode(isDark)
}
btf.addGlobalFn('themeChange', artalkChangeMode, 'artalk')
if ('!{use[0]}' === 'Artalk' || !!{lazyload}) {
if (!{lazyload}) btf.loadComment(document.getElementById('artalk-wrap'), loadArtalk)
else loadArtalk()
} else {
window.loadOtherComment = loadArtalk
}
})()

View File

@@ -1,59 +1,45 @@
- const disqusPageTitle = page.title.replace(/'/ig,"\\'")
- const { shortname, apikey } = theme.disqus
- const { use, lazyload, count } = theme.comments
script. script.
(() => { function loadDisqus () {
const disqus_config = function () { var disqus_config = function () {
this.page.url = '!{ page.permalink }' this.page.url = '!{ page.permalink }'
this.page.identifier = '!{ url_for(page.path) }' this.page.identifier = '!{ page.path }'
this.page.title = '!{ disqusPageTitle }' this.page.title = '!{ page.title }'
} };
const disqusReset = () => { window.disqusReset = () => {
window.DISQUS && window.DISQUS.reset({ DISQUS.reset({
reload: true, reload: true,
config: disqus_config config: disqus_config
}) })
} }
btf.addGlobalFn('themeChange', disqusReset, 'disqus')
const loadDisqus = () =>{
if (window.DISQUS) disqusReset() if (window.DISQUS) disqusReset()
else { else {
const script = document.createElement('script') (function() {
script.src = 'https://!{shortname}.disqus.com/embed.js' var d = document, s = d.createElement('script');
script.setAttribute('data-timestamp', +new Date()) s.src = 'https://!{theme.disqus.shortname}.disqus.com/embed.js';
document.head.appendChild(script) s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();
} }
} }
const getCount = async() => { if ('!{theme.comments.use[0]}' === 'Disqus' || !!{theme.comments.lazyload}) {
try { if (!{theme.comments.lazyload}) loadComment(document.getElementById('disqus_thread'), loadDisqus)
const eleGroup = document.querySelector('#post-meta .disqus-comment-count') else loadDisqus()
if (!eleGroup) return
const cleanedLinks = eleGroup.href.replace(/#post-comment$/, '')
const res = await fetch(`https://disqus.com/api/3.0/threads/set.json?forum=!{shortname}&api_key=!{apikey}&thread:link=${cleanedLinks}`,{
method: 'GET'
})
const result = await res.json()
const count = result.response.length ? result.response[0].posts : 0
eleGroup.textContent = count
} catch (err) {
console.error(err)
}
}
if ('!{use[0]}' === 'Disqus' || !!{lazyload}) {
if (!{lazyload}) btf.loadComment(document.getElementById('disqus_thread'), loadDisqus)
else {
loadDisqus()
!{ count ? 'GLOBAL_CONFIG_SITE.isPost && getCount()' : '' }
}
} else { } else {
window.loadOtherComment = loadDisqus function loadOtherComment () {
loadDisqus()
}
}
if is_post() && !theme.comments.lazyload && theme.comments.count && theme.comments.use[0] === 'Disqus'
script.
if (window.DISQUSWIDGETS === undefined) {
var d = document, s = d.createElement('script');
s.src = 'https://!{theme.disqus.shortname}.disqus.com/count.js';
s.id = 'dsq-count-scr';
(d.head || d.body).appendChild(s);
} else {
DISQUSWIDGETS.getCount({reset: true});
} }
})()

View File

@@ -1,64 +1,57 @@
- let disqusjsPageTitle = page.title.replace(/'/ig,"\\'")
- const { shortname:dqShortname, apikey:dqApikey, option:dqOption } = theme.disqusjs
script. script.
(() => { function loadDisqusjs () {
const initDisqusjs = () => { function addDisqusjsCSS () {
window.disqusjs = null const ele = document.createElement('link')
disqusjs = new DisqusJS(Object.assign({ ele.rel = 'stylesheet'
shortname: '!{dqShortname}', ele.href= '!{url_for(theme.CDN.disqusjs_css)}'
identifier: '!{ url_for(page.path) }', document.getElementsByTagName('head')[0].appendChild(ele)
}
function initDisqusjs () {
window.DISQUS = null
new DisqusJS({
shortname: '!{theme.disqusjs.shortname}',
siteName: '!{theme.disqusjs.siteName}',
identifier: '!{ page.path }',
url: '!{ page.permalink }', url: '!{ page.permalink }',
title: '!{ disqusjsPageTitle }', title: '!{ page.title }',
apikey: '!{dqApikey}', api: '!{theme.disqusjs.api}',
},!{JSON.stringify(dqOption)})) apikey: '!{theme.disqusjs.apikey}',
nocomment: '!{theme.disqusjs.nocomment}',
disqusjs.render(document.getElementById('disqusjs-wrap')) admin: '!{theme.disqusjs.admin}',
adminLabel: '!{theme.disqusjs.adminLabel}'
});
} }
const themeChange = () => { window.disqusReset = initDisqusjs
const ele = document.getElementById('disqus_thread')
if(!ele) return
disqusjs.destroy()
initDisqusjs()
}
btf.addGlobalFn('themeChange', themeChange, 'disqusjs')
const loadDisqusjs = async() => {
if (window.disqusJsLoad) initDisqusjs() if (window.disqusJsLoad) initDisqusjs()
else { else {
await getCSS('!{url_for(theme.asset.disqusjs_css)}') addDisqusjsCSS()
await getScript('!{url_for(theme.asset.disqusjs)}') $.getScript('!{url_for(theme.CDN.disqusjs)}', initDisqusjs)
initDisqusjs()
window.disqusJsLoad = true window.disqusJsLoad = true
} }
} }
const getCount = async() => {
try {
const eleGroup = document.querySelector('#post-meta .disqusjs-comment-count')
if (!eleGroup) return
const cleanedLinks = eleGroup.href.replace(/#post-comment$/, '')
const res = await fetch(`https://disqus.com/api/3.0/threads/set.json?forum=!{dqShortname}&api_key=!{dqApikey}&thread:link=${cleanedLinks}`,{
method: 'GET'
})
const result = await res.json()
const count = result.response.length ? result.response[0].posts : 0
eleGroup.textContent = count
} catch (err) {
console.error(err)
}
}
if ('!{theme.comments.use[0]}' === 'Disqusjs' || !!{theme.comments.lazyload}) { if ('!{theme.comments.use[0]}' === 'Disqusjs' || !!{theme.comments.lazyload}) {
if (!{theme.comments.lazyload}) btf.loadComment(document.getElementById('disqusjs-wrap'), loadDisqusjs) if (!{theme.comments.lazyload}) loadComment(document.getElementById('disqus_thread'), loadDisqusjs)
else loadDisqusjs()
}
else { else {
function loadOtherComment () {
loadDisqusjs() loadDisqusjs()
!{ theme.comments.count ? 'GLOBAL_CONFIG_SITE.isPost && getCount()' : '' }
} }
}
if is_post() && !theme.comments.lazyload && theme.comments.count && theme.comments.use[0] === 'Disqusjs'
script.
if (window.DISQUSWIDGETS === undefined) {
var d = document, s = d.createElement('script');
s.src = 'https://!{theme.disqus.shortname}.disqus.com/count.js';
s.id = 'dsq-count-scr';
(d.head || d.body).appendChild(s);
} else { } else {
window.loadOtherComment = loadDisqusjs DISQUSWIDGETS.getCount({reset: true});
} }
})()

View File

@@ -1,46 +1,26 @@
- const fbSDKVer = 'v16.0' #fb-root
- const fbSDK = theme.messenger.enable ? `https://connect.facebook.net/${theme.facebook_comments.lang}/sdk/xfbml.customerchat.js#xfbml=1&version=${fbSDKVer}` : `https://connect.facebook.net/${theme.facebook_comments.lang}/sdk.js#xfbml=1&version=${fbSDKVer}`
script. script.
(()=>{ function loadFBComment () {
const loadFBComment = () => { var themeNow = document.documentElement.getAttribute('data-theme') === 'dark' ? 'dark' : 'light'
document.getElementById('fb-root') ? '' : document.body.insertAdjacentHTML('afterend', '<div id="fb-root"></div>') document.getElementsByClassName('fb-comments')[0].setAttribute('data-colorscheme',themeNow)
const themeNow = document.documentElement.getAttribute('data-theme') === 'dark' ? 'dark' : 'light' if (typeof FB === 'object') FB.XFBML.parse()
const $fbComment = document.getElementsByClassName('fb-comments')[0]
$fbComment.setAttribute('data-colorscheme',themeNow)
$fbComment.setAttribute('data-href', '!{urlNoIndex(page.permalink)}')
if (typeof FB === 'object') {
FB.XFBML.parse(document.getElementsByClassName('post-meta-commentcount')[0])
FB.XFBML.parse(document.getElementById('post-comment'))
}
else { else {
let ele = document.createElement('script') let ele = document.createElement('script')
ele.setAttribute('src','!{fbSDK}') ele.setAttribute('src','https://connect.facebook.net/!{theme.facebook_comments.lang}/sdk.js#xfbml=1&version=v7.0')
ele.setAttribute('async', 'true') ele.setAttribute('async', 'true')
ele.setAttribute('defer', 'true') ele.setAttribute('defer', 'true')
ele.setAttribute('crossorigin', 'anonymous') ele.setAttribute('crossorigin', 'anonymous')
ele.setAttribute('id', 'facebook-jssdk')
document.getElementById('fb-root').insertAdjacentElement('afterbegin',ele) document.getElementById('fb-root').insertAdjacentElement('afterbegin',ele)
} }
} }
const fbModeChange = theme => {
const $fbComment = document.getElementsByClassName('fb-comments')[0]
if ($fbComment && typeof FB === 'object') {
$fbComment.setAttribute('data-colorscheme',theme)
FB.XFBML.parse(document.getElementById('post-comment'))
}
}
btf.addGlobalFn('themeChange', fbModeChange, 'facebook_comments')
if ('!{theme.comments.use[0]}' === 'Facebook Comments' || !!{theme.comments.lazyload}) { if ('!{theme.comments.use[0]}' === 'Facebook Comments' || !!{theme.comments.lazyload}) {
if (!{theme.comments.lazyload}) btf.loadComment(document.querySelector('#post-comment .fb-comments'), loadFBComment) if (!{theme.comments.lazyload}) loadComment(document.querySelector('#post-comment .fb-comments'), loadFBComment)
else loadFBComment() else loadFBComment()
} else { } else {
window.loadOtherComment = loadFBComment function loadOtherComment () {
loadFBComment()
}
} }
})()

View File

@@ -1,54 +0,0 @@
- const { repo, repo_id, category_id, theme:themes, option } = theme.giscus
- const giscusUrl = theme.asset.giscus || 'https://giscus.app/client.js'
- const giscusOriginUrl = new URL(giscusUrl).origin
- const { use, lazyload } = theme.comments
script.
(()=>{
const getGiscusTheme = theme => {
return theme === 'dark' ? '!{themes.dark}' : '!{themes.light}'
}
const loadGiscus = () => {
const config = Object.assign({
src: '!{giscusUrl}',
'data-repo': '!{repo}',
'data-repo-id': '!{repo_id}',
'data-category-id': '!{category_id}',
'data-mapping': 'pathname',
'data-theme': getGiscusTheme(document.documentElement.getAttribute('data-theme')),
'data-reactions-enabled': '1',
crossorigin: 'anonymous',
async: true
},!{JSON.stringify(option)})
const ele = document.createElement('script')
for (let key in config) {
ele.setAttribute(key, config[key])
}
document.getElementById('giscus-wrap').appendChild(ele)
}
const changeGiscusTheme = theme => {
const sendMessage = message => {
const iframe = document.querySelector('iframe.giscus-frame')
if (!iframe) return
iframe.contentWindow.postMessage({ giscus: message }, '!{giscusOriginUrl}')
}
sendMessage({
setConfig: {
theme: getGiscusTheme(theme)
}
});
}
btf.addGlobalFn('themeChange', changeGiscusTheme, 'giscus')
if ('!{use[0]}' === 'Giscus' || !!{lazyload}) {
if (!{lazyload}) btf.loadComment(document.getElementById('giscus-wrap'), loadGiscus)
else loadGiscus()
} else {
window.loadOtherComment= loadGiscus
}
})()

View File

@@ -1,44 +1,52 @@
- const { client_id, client_secret, repo, owner, admin, option } = theme.gitalk
script. script.
(() => { function addGitalkSource () {
const initGitalk = () => { const ele = document.createElement('link')
const gitalk = new Gitalk(Object.assign({ ele.rel = 'stylesheet'
clientID: '!{client_id}', ele.href= '!{url_for(theme.CDN.gitalk_css)}'
clientSecret: '!{client_secret}', document.getElementsByTagName('head')[0].appendChild(ele)
repo: '!{repo}', }
owner: '!{owner}',
admin: ['!{admin}'],
id: '!{md5(page.path)}',
updateCountCallback: commentCount
},!{JSON.stringify(option)}))
function loadGitalk () {
function initGitalk () {
var gitalk = new Gitalk({
clientID: '!{theme.gitalk.client_id}',
clientSecret: '!{theme.gitalk.client_secret}',
repo: '!{theme.gitalk.repo}',
owner: '!{theme.gitalk.owner}',
admin: ['!{theme.gitalk.admin}'],
id: '!{md5(page.path)}',
language: '!{theme.gitalk.language}',
perPage: !{theme.gitalk.perPage},
distractionFreeMode: !{theme.gitalk.distractionFreeMode},
pagerDirection: '!{theme.gitalk.pagerDirection}',
createIssueManually: !{theme.gitalk.createIssueManually},
updateCountCallback: commentCount
})
gitalk.render('gitalk-container') gitalk.render('gitalk-container')
} }
const loadGitalk = async() => {
if (typeof Gitalk === 'function') initGitalk() if (typeof Gitalk === 'function') initGitalk()
else { else {
await getCSS('!{url_for(theme.asset.gitalk_css)}') addGitalkSource()
await getScript('!{url_for(theme.asset.gitalk)}') $.getScript('!{url_for(theme.CDN.gitalk)}', initGitalk)
initGitalk()
} }
} }
const commentCount = n => { function commentCount(n){
const isCommentCount = document.querySelector('#post-meta .gitalk-comment-count') let isCommentCount = document.querySelector('#post-meta .gitalk-comment-count')
if (isCommentCount) { if (isCommentCount) {
isCommentCount.textContent= n isCommentCount.innerHTML= n
} }
} }
if ('!{theme.comments.use[0]}' === 'Gitalk' || !!{theme.comments.lazyload}) { if ('!{theme.comments.use[0]}' === 'Gitalk' || !!{theme.comments.lazyload}) {
if (!{theme.comments.lazyload}) btf.loadComment(document.getElementById('gitalk-container'), loadGitalk) if (!{theme.comments.lazyload}) loadComment(document.getElementById('gitalk-container'), loadGitalk)
else loadGitalk() else loadGitalk()
} else { } else {
window.loadOtherComment = loadGitalk function loadOtherComment () {
loadGitalk()
}
} }
})()

View File

@@ -1,5 +1,5 @@
- let defaultComment = theme.comments.use[0] - let defaultComment = theme.comments.use[0]
hr.custom-hr hr
#post-comment #post-comment
.comment-head .comment-head
.comment-headline .comment-headline
@@ -9,7 +9,9 @@ hr.custom-hr
if theme.comments.use.length > 1 if theme.comments.use.length > 1
.comment-switch .comment-switch
span.first-comment=defaultComment span.first-comment=defaultComment
span#switch-btn label
input#switch-comments-btn(type="checkbox")
span.slider
span.second-comment=theme.comments.use[1] span.second-comment=theme.comments.use[1]
@@ -22,25 +24,15 @@ hr.custom-hr
when 'Valine' when 'Valine'
#vcomment.vcomment #vcomment.vcomment
when 'Disqusjs' when 'Disqusjs'
#disqusjs-wrap #disqus_thread
when 'Livere' when 'Livere'
#lv-container(data-id="city" data-uid=theme.livere.uid) #lv-container(data-id="city" data-uid=theme.livere.uid)
when 'Gitalk' when 'Gitalk'
#gitalk-container #gitalk-container
when 'Utterances' when 'Utterances'
#utterances-wrap #utterances-wrap
when 'Twikoo'
#twikoo-wrap
when 'Waline'
#waline-wrap
when 'Giscus'
#giscus-wrap
when 'Facebook Comments' when 'Facebook Comments'
.fb-comments(data-colorscheme = theme.display_mode === 'dark' ? 'dark' : 'light' .fb-comments(data-colorscheme = theme.display_mode === 'dark' ? 'dark' : 'light'
data-numposts= theme.facebook_comments.pageSize || 10 data-numposts= theme.facebook_comments.pageSize || 10
data-order-by= theme.facebook_comments.order_by || 'social' data-order-by= theme.facebook_comments.order_by || 'social'
data-width="100%") data-width="100%")
when 'Remark42'
#remark42
when 'Artalk'
#artalk-wrap

View File

@@ -1,26 +1,16 @@
each name in theme.comments.use each name in theme.comments.use
case name case name
when 'Valine' when 'Valine'
!=partial('includes/third-party/comments/valine', {}, {cache: true}) !=partial('includes/third-party/comments/valine', {}, {cache:theme.fragment_cache})
when 'Disqus' when 'Disqus'
include ./disqus.pug include ./disqus.pug
when 'Disqusjs' when 'Disqusjs'
include ./disqusjs.pug include ./disqusjs.pug
when 'Livere' when 'Livere'
!=partial('includes/third-party/comments/livere', {}, {cache: true}) !=partial('includes/third-party/comments/livere', {}, {cache:theme.fragment_cache})
when 'Gitalk' when 'Gitalk'
include ./gitalk.pug include ./gitalk.pug
when 'Utterances' when 'Utterances'
!=partial('includes/third-party/comments/utterances', {}, {cache: true}) !=partial('includes/third-party/comments/utterances', {}, {cache:theme.fragment_cache})
when 'Twikoo'
!=partial('includes/third-party/comments/twikoo', {}, {cache: true})
when 'Waline'
!=partial('includes/third-party/comments/waline', {}, {cache: true})
when 'Giscus'
!=partial('includes/third-party/comments/giscus', {}, {cache: true})
when 'Facebook Comments' when 'Facebook Comments'
include ./facebook_comments.pug !=partial('includes/third-party/comments/facebook_comments', {}, {cache:theme.fragment_cache})
when 'Remark42'
!=partial('includes/third-party/comments/remark42', {}, {cache: true})
when 'Artalk'
!=partial('includes/third-party/comments/artalk', {}, {cache: true})

View File

@@ -1,10 +1,5 @@
- const { use, lazyload } = theme.comments
script. script.
(()=>{ function loadLivere () {
const loadLivere = () => {
if (typeof LivereTower === 'object') window.LivereTower.init()
else {
(function(d, s) { (function(d, s) {
var j, e = d.getElementsByTagName(s)[0]; var j, e = d.getElementsByTagName(s)[0];
if (typeof LivereTower === 'function') { return; } if (typeof LivereTower === 'function') { return; }
@@ -14,12 +9,13 @@ script.
e.parentNode.insertBefore(j, e); e.parentNode.insertBefore(j, e);
})(document, 'script'); })(document, 'script');
} }
}
if ('!{use[0]}' === 'Livere' || !!{lazyload}) { if ('!{theme.comments.use[0]}' === 'Livere' || !!{theme.comments.lazyload}) {
if (!{lazyload}) btf.loadComment(document.getElementById('lv-container'), loadLivere) if (!{theme.comments.lazyload}) loadComment(document.getElementById('lv-container'), loadLivere)
else loadLivere() else loadLivere()
} else {
window.loadOtherComment = loadLivere
} }
})() else {
function loadOtherComment () {
loadLivere()
}
}

View File

@@ -1,68 +0,0 @@
- const { host, siteId, option } = theme.remark42
script.
var remark_config = Object.assign({
host: '!{host}',
site_id: '!{siteId}',
components: ['embed'],
theme: document.documentElement.getAttribute('data-theme') === 'dark' ? 'dark' : 'light'
},!{JSON.stringify(option)})
function addRemark42(){
for (let i = 0; i < remark_config.components.length; i++) {
const s = document.createElement('script')
s.src = remark_config.host + '/web/' + remark_config.components[i] + '.js'
s.defer = true
document.head.appendChild(s)
}
}
function initRemark42() {
if (window.REMARK42) {
if (this.remark42Instance) {
this.remark42Instance.destroy()
}
this.remark42Instance = window.REMARK42.createInstance({
...remark_config
})
}
}
function getCount () {
const ele = document.querySelector('.remark42__counter')
if (ele) {
const s = document.createElement('script')
s.src = remark_config.host + '/web/counter.js'
s.defer = true
document.head.appendChild(s)
}
}
function loadRemark42 () {
if (window.REMARK42) {
this.initRemark42()
getCount()
} else {
addRemark42()
window.addEventListener('REMARK42::ready', () => {
this.initRemark42()
getCount()
})
}
}
function remarkChangeMode (theme) {
if (!window.REMARK42) return
window.REMARK42.changeTheme(theme)
}
btf.addGlobalFn('themeChange', remarkChangeMode, 'remark42')
if ('!{theme.comments.use[0]}' === 'Remark42' || !!{theme.comments.lazyload}) {
if (!{theme.comments.lazyload}) btf.loadComment(document.getElementById('remark42'), loadRemark42)
else loadRemark42()
} else {
function loadOtherComment () {
loadRemark42()
}
}

View File

@@ -1,46 +0,0 @@
- const { envId, region, option } = theme.twikoo
- const { use, lazyload, count } = theme.comments
script.
(() => {
const init = () => {
twikoo.init(Object.assign({
el: '#twikoo-wrap',
envId: '!{envId}',
region: '!{region}',
onCommentLoaded: () => {
btf.loadLightbox(document.querySelectorAll('#twikoo .tk-content img:not(.tk-owo-emotion)'))
}
}, !{JSON.stringify(option)}))
}
const loadTwikoo = () => {
if (typeof twikoo === 'object') setTimeout(init,0)
else getScript('!{url_for(theme.asset.twikoo)}').then(init)
}
const getCount = () => {
const countELement = document.getElementById('twikoo-count')
if(!countELement) return
twikoo.getCommentsCount({
envId: '!{envId}',
region: '!{region}',
urls: [window.location.pathname],
includeReply: false
}).then(res => {
countELement.textContent = res[0].count
}).catch(err => {
console.error(err)
})
}
if ('!{use[0]}' === 'Twikoo' || !!{lazyload}) {
if (!{lazyload}) btf.loadComment(document.getElementById('twikoo-wrap'), loadTwikoo)
else {
loadTwikoo()
!{count ? 'GLOBAL_CONFIG_SITE.isPost && getCount()' : ''}
}
} else {
window.loadOtherComment = loadTwikoo
}
})()

View File

@@ -1,39 +1,34 @@
- const { use, lazyload } = theme.comments
- const { repo, issue_term, light_theme, dark_theme } = theme.utterances
script. script.
(() => { function loadUtterances () {
const loadUtterances = () => {
let ele = document.createElement('script') let ele = document.createElement('script')
ele.id = 'utterances_comment' ele.setAttribute('id', 'utterances_comment')
ele.src = 'https://utteranc.es/client.js' ele.setAttribute('src', '!{url_for(theme.CDN.utterances)}')
ele.setAttribute('repo', '!{repo}') ele.setAttribute('repo', '!{theme.utterances.repo}')
ele.setAttribute('issue-term', '!{issue_term}') ele.setAttribute('issue-term', '!{theme.utterances.issue_term}')
const nowTheme = document.documentElement.getAttribute('data-theme') === 'dark' ? '#{dark_theme}' : '#{light_theme}' let nowTheme = document.documentElement.getAttribute('data-theme') === 'dark' ? '#{theme.utterances.dark_theme}' : '#{theme.utterances.light_theme}'
ele.setAttribute('theme', nowTheme) ele.setAttribute('theme', nowTheme)
ele.crossOrigin = 'anonymous' ele.setAttribute('crossorigin', 'anonymous')
ele.async = true ele.setAttribute('async', 'true')
document.getElementById('utterances-wrap').appendChild(ele) document.getElementById('utterances-wrap').insertAdjacentElement('afterbegin',ele)
} }
const utterancesTheme = theme => { function utterancesTheme () {
const iframe = document.querySelector('.utterances-frame') if (document.querySelector('.utterances-frame')) {
if (iframe) { const theme = document.documentElement.getAttribute('data-theme') === 'dark' ? '#{theme.utterances.dark_theme}' : '#{theme.utterances.light_theme}'
const theme = theme === 'dark' ? '#{dark_theme}' : '#{light_theme}'
const message = { const message = {
type: 'set-theme', type: 'set-theme',
theme: theme theme: theme
}; };
const iframe = document.querySelector('.utterances-frame');
iframe.contentWindow.postMessage(message, 'https://utteranc.es'); iframe.contentWindow.postMessage(message, 'https://utteranc.es');
} }
} }
btf.addGlobalFn('themeChange', utterancesTheme, 'utterances') if ('!{theme.comments.use[0]}' === 'Utterances' || !!{theme.comments.lazyload}) {
if (!{theme.comments.lazyload}) loadComment(document.getElementById('utterances-wrap'), loadUtterances)
if ('!{use[0]}' === 'Utterances' || !!{lazyload}) {
if (!{lazyload}) btf.loadComment(document.getElementById('utterances-wrap'), loadUtterances)
else loadUtterances() else loadUtterances()
} else { } else {
window.loadOtherComment = loadUtterances function loadOtherComment () {
loadUtterances()
}
} }
})()

View File

@@ -1,38 +1,40 @@
- const { use, lazyload } = theme.comments
- const { appId, appKey, avatar, serverURLs, visitor, option } = theme.valine
- let emojiMaps = '""' - let emojiMaps = '""'
if site.data.valine if site.data.valine
- emojiMaps = JSON.stringify(site.data.valine) - emojiMaps = JSON.stringify(site.data.valine)
script. script.
(() => { function loadValine () {
const initValine = () => { function initValine () {
const valine = new Valine(Object.assign({ window.valine = new Valine({
el: '#vcomment', el: '#vcomment',
appId: '#{appId}', appId: '#{theme.valine.appId}',
appKey: '#{appKey}', appKey: '#{theme.valine.appKey}',
avatar: '#{avatar}', placeholder: '#{theme.valine.placeholder}',
serverURLs: '#{serverURLs}', avatar: '#{theme.valine.avatar}',
meta: '#{theme.valine.guest_info }'.split(','),
pageSize: '#{theme.valine.pageSize}',
lang: '#{theme.valine.lang}',
recordIP: #{theme.valine.recordIP},
serverURLs: '#{theme.valine.serverURLs}',
emojiCDN: '#{theme.valine.emojiCDN}',
emojiMaps: !{emojiMaps}, emojiMaps: !{emojiMaps},
enableQQ: #{theme.valine.enableQQ},
path: window.location.pathname, path: window.location.pathname,
visitor: #{visitor} });
}, !{JSON.stringify(option)})) if ('#{theme.valine.requiredFields}') { valine.config.requiredFields= '#{theme.valine.requiredFields}'.split(',') }
} }
const loadValine = async () => {
if (typeof Valine === 'function') initValine() if (typeof Valine === 'function') initValine()
else { else $.getScript('!{url_for(theme.CDN.valine)}', initValine)
await getScript('!{url_for(theme.asset.valine)}')
initValine()
}
} }
if ('!{use[0]}' === 'Valine' || !!{lazyload}) { if ('!{theme.comments.use[0]}' === 'Valine' || !!{theme.comments.lazyload}) {
if (!{lazyload}) btf.loadComment(document.getElementById('vcomment'),loadValine) if (!{theme.comments.lazyload}) loadComment(document.querySelector('#vcomment'),loadValine)
else setTimeout(loadValine, 0) else setTimeout(() => loadValine(), 0)
} else { } else {
window.loadOtherComment = loadValine function loadOtherComment () {
loadValine()
}
} }
})()

View File

@@ -1,33 +0,0 @@
- const { serverURL, option, pageview } = theme.waline
- const { lazyload, count, use } = theme.comments
script.
(() => {
const initWaline = () => {
const waline = Waline.init(Object.assign({
el: '#waline-wrap',
serverURL: '!{serverURL}',
pageview: !{lazyload ? false : pageview},
dark: 'html[data-theme="dark"]',
path: window.location.pathname,
comment: !{lazyload ? false : count},
}, !{JSON.stringify(option)}))
}
const loadWaline = async () => {
if (typeof Waline === 'object') initWaline()
else {
await getCSS('!{url_for(theme.asset.waline_css)}')
await getScript('!{url_for(theme.asset.waline_js)}')
initWaline()
}
}
if ('!{use[0]}' === 'Waline' || !!{lazyload}) {
if (!{lazyload}) btf.loadComment(document.getElementById('waline-wrap'),loadWaline)
else setTimeout(loadWaline, 0)
} else {
window.loadOtherComment = loadWaline
}
})()

View File

@@ -1,35 +1,28 @@
if theme.fireworks && theme.fireworks.enable if theme.fireworks && theme.fireworks.enable
canvas.fireworks(mobile=`${theme.fireworks.mobile}`) canvas.fireworks
script(src=url_for(theme.asset.fireworks)) script(src=url_for(theme.CDN.anime))
script(src=url_for(theme.CDN.fireworks))
if (theme.canvas_ribbon && theme.canvas_ribbon.enable) if (theme.canvas_ribbon && theme.canvas_ribbon.enable)
script(defer id="ribbon" src=url_for(theme.asset.canvas_ribbon) size=theme.canvas_ribbon.size script(defer id="ribbon" src=url_for(theme.CDN.canvas_ribbon) size=theme.canvas_ribbon.size
alpha=theme.canvas_ribbon.alpha zIndex=theme.canvas_ribbon.zIndex mobile=`${theme.canvas_ribbon.mobile}` data-click=`${theme.canvas_ribbon.click_to_change}`) alpha=theme.canvas_ribbon.alpha zIndex=theme.canvas_ribbon.zIndex mobile=`${theme.canvas_ribbon.mobile}` data-click=`${theme.canvas_ribbon.click_to_change}`)
if (theme.canvas_fluttering_ribbon && theme.canvas_fluttering_ribbon.enable) if (theme.canvas_ribbon_piao && theme.canvas_ribbon_piao.enable)
script(defer id="fluttering_ribbon" mobile=`${theme.canvas_fluttering_ribbon.mobile}` src=url_for(theme.asset.canvas_fluttering_ribbon)) script(defer id="ribbon_piao" mobile=`${theme.canvas_ribbon_piao.mobile}` src=url_for(theme.CDN.canvas_ribbon_piao))
if (theme.canvas_nest && theme.canvas_nest.enable) if (theme.canvas_nest && theme.canvas_nest.enable)
script#canvas_nest(defer color=theme.canvas_nest.color opacity=theme.canvas_nest.opacity zIndex=theme.canvas_nest.zIndex count=theme.canvas_nest.count mobile=`${theme.canvas_nest.mobile}` src=url_for(theme.asset.canvas_nest)) script#canvas_nest(defer color=theme.canvas_nest.color opacity=theme.canvas_nest.opacity zIndex=theme.canvas_nest.zIndex count=theme.canvas_nest.count mobile=`${theme.canvas_nest.mobile}` src=url_for(theme.CDN.canvas_nest))
if theme.activate_power_mode.enable if theme.activate_power_mode.enable
script(src=url_for(theme.asset.activate_power_mode)) script(src=url_for(theme.CDN.activate_power_mode))
script. script.
POWERMODE.colorful = !{theme.activate_power_mode.colorful}; POWERMODE.colorful = #{theme.activate_power_mode.colorful};
POWERMODE.shake = !{theme.activate_power_mode.shake}; POWERMODE.shake = #{theme.activate_power_mode.shake};
POWERMODE.mobile = !{theme.activate_power_mode.mobile};
document.body.addEventListener('input', POWERMODE); document.body.addEventListener('input', POWERMODE);
//- 鼠標特效 //- 鼠標特效
if theme.click_heart && theme.click_heart.enable if theme.click_heart
script#click-heart(src=url_for(theme.asset.click_heart) async mobile=`${theme.click_heart.mobile}`) script(src=url_for(theme.CDN.click_heart) async)
if theme.clickShowText && theme.clickShowText.enable if theme.ClickShowText && theme.ClickShowText.enable
script#click-show-text( script(src=url_for(theme.CDN.ClickShowText) async)
src= url_for(theme.asset.clickShowText)
data-mobile= `${theme.clickShowText.mobile}`
data-text= theme.clickShowText.text.join(",")
data-fontsize= theme.clickShowText.fontSize
data-random= `${theme.clickShowText.random}`
async
)

View File

@@ -1,6 +1,6 @@
if theme.mathjax && theme.mathjax.enable if theme.mathjax && theme.mathjax.enable
if theme.mathjax.per_page if theme.mathjax.per_page
if is_post() || is_page() if(!is_tag() && !is_category() && !is_archive() && !is_home())
include ./mathjax.pug include ./mathjax.pug
else else
if page.mathjax if page.mathjax
@@ -8,7 +8,7 @@ if theme.mathjax && theme.mathjax.enable
if theme.katex && theme.katex.enable if theme.katex && theme.katex.enable
if theme.katex.per_page if theme.katex.per_page
if is_post() || is_page() if(!is_tag() && !is_category() && !is_archive() && !is_home())
include ./katex.pug include ./katex.pug
else else
if page.katex if page.katex

View File

@@ -1,9 +1,7 @@
link(rel="stylesheet" type="text/css" href=url_for(theme.asset.katex)) link(rel="stylesheet" type="text/css" href=theme.CDN.katex)
script(src=url_for(theme.asset.katex_copytex)) script(src=url_for(theme.CDN.katex_copytex))
link(rel="stylesheet" type="text/css" href=theme.CDN.katex_copytex_css)
script. script.
(() => { $(function () {
document.querySelectorAll('#article-container span.katex-display').forEach(item => { $('span.katex-display').wrap('<div class="katex-wrap"></div>')
btf.wrap(item, 'div', { class: 'katex-wrap'})
}) })
})()

View File

@@ -1,13 +1,20 @@
//- Mathjax 3 //- Mathjax 3
//- http://docs.mathjax.org/en/latest/upgrading/v2.html#changes-in-the-mathjax-api
//- https://github.com/mathjax/MathJax/issues/2209
//- http://docs.mathjax.org/en/latest/options/input/tex.html#the-configuration-block
//- http://docs.mathjax.org/en/latest/web/typeset.html#resetting-automatic-equation-numbering
script. script.
if (!window.MathJax) { if (!window.MathJax) {
window.MathJax = { window.MathJax = {
tex: { loader: {
inlineMath: [['$', '$'], ['\\(', '\\)']], source: {
tags: 'ams' '[tex]/amsCd': '[tex]/amscd'
}
}, },
chtml: { tex: {
scale: 1.1 inlineMath: [ ['$','$'], ["\\(","\\)"]],
tags: 'ams'
}, },
options: { options: {
renderActions: { renderActions: {
@@ -26,13 +33,13 @@ script.
} }
} }
const script = document.createElement('script') var script = document.createElement('script')
script.src = '!{url_for(theme.asset.mathjax)}' script.src = '!{theme.CDN.mathjax}'
script.id = 'MathJax-script' script.id = 'MathJax-script'
script.async = true script.async = true
document.head.appendChild(script) document.head.appendChild(script)
} else { } else {
MathJax.startup.document.state(0) MathJax.startup.document.state(0)
MathJax.texReset() MathJax.texReset()
MathJax.typesetPromise() MathJax.typeset()
} }

View File

@@ -1,38 +1,15 @@
script. script.
(() => { if (document.getElementsByClassName('mermaid').length) {
const $mermaid = document.querySelectorAll('#article-container .mermaid-wrap') if (window.mermaidJsLoad) mermaid.init()
if ($mermaid.length === 0) return else {
const runMermaid = () => { $.getScript('!{theme.CDN.mermaid}', function () {
window.loadMermaid = true window.mermaidJsLoad = true
const theme = document.documentElement.getAttribute('data-theme') === 'dark' ? '!{theme.mermaid.theme.dark}' : '!{theme.mermaid.theme.light}' mermaid.initialize({
theme: '!{theme.mermaid.theme}',
Array.from($mermaid).forEach((item, index) => { })
const mermaidSrc = item.firstElementChild !{theme.pjax} && mermaid.init()
const mermaidThemeConfig = '%%{init:{ \'theme\':\'' + theme + '\'}}%%\n'
const mermaidID = 'mermaid-' + index
const mermaidDefinition = mermaidThemeConfig + mermaidSrc.textContent
const renderFn = mermaid.render(mermaidID, mermaidDefinition)
const renderV10 = () => {
renderFn.then(({svg}) => {
mermaidSrc.insertAdjacentHTML('afterend', svg)
}) })
} }
const renderV9 = svg => {
mermaidSrc.insertAdjacentHTML('afterend', svg)
} }
typeof renderFn === 'string' ? renderV9(renderFn) : renderV10()
})
}
const loadMermaid = () => {
window.loadMermaid ? runMermaid() : getScript('!{url_for(theme.asset.mermaid)}').then(runMermaid)
}
btf.addGlobalFn('themeChange', runMermaid, 'mermaid')
window.pjax ? loadMermaid() : document.addEventListener('DOMContentLoaded', loadMermaid)
})()

View File

@@ -1,110 +0,0 @@
- const { server, site, option } = theme.artalk
- const avatarCdn = option !== null && option.gravatar && option.gravatar.mirror
- const avatarDefault = option !== null && option.gravatar && (option.gravatar.params || option.gravatar.default)
script.
window.addEventListener('load', () => {
const changeContent = (content) => {
if (content === '') return content
content = content.replace(/<img.*?src="(.*?)"?[^\>]+>/ig, '[!{_p("aside.card_newest_comments.image")}]') // replace image link
content = content.replace(/<a[^>]+?href=["']?([^"']+)["']?[^>]*>([^<]+)<\/a>/gi, '[!{_p("aside.card_newest_comments.link")}]') // replace url
content = content.replace(/<pre><code>.*?<\/pre>/gi, '[!{_p("aside.card_newest_comments.code")}]') // replace code
content = content.replace(/<[^>]+>/g,"") // remove html tag
if (content.length > 150) {
content = content.substring(0,150) + '...'
}
return content
}
const generateHtml = array => {
let result = ''
if (array.length) {
for (let i = 0; i < array.length; i++) {
result += '<div class=\'aside-list-item\'>'
if (!{theme.newest_comments.avatar}) {
const name = '!{theme.lazyload.enable ? "data-lazy-src" : "src"}'
result += `<a href='${array[i].url}' class='thumbnail'><img ${name}='${array[i].avatar}' alt='${array[i].nick}'></a>`
}
result += `<div class='content'>
<a class='comment' href='${array[i].url}' title='${array[i].content}'>${array[i].content}</a>
<div class='name'><span>${array[i].nick} / </span><time datetime="${array[i].date}">${btf.diffDate(array[i].date, true)}</time></div>
</div></div>`
}
} else {
result += '!{_p("aside.card_newest_comments.zero")}'
}
let $dom = document.querySelector('#card-newest-comments .aside-list')
$dom.innerHTML= result
window.lazyLoadInstance && window.lazyLoadInstance.update()
window.pjax && window.pjax.refresh($dom)
}
const getSetting = async () => {
try {
const res = await fetch('!{server}/api/conf', { method: 'GET' })
return await res.json()
} catch (e) {
console.log(e)
}
}
const headerList = {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Origin': window.location.origin
},
body: new URLSearchParams({
'site_name': '!{site}',
'limit': '!{theme.newest_comments.limit}',
'type':'latest_comments'
})
}
const getComment = async () => {
try {
const res = await fetch('!{server}/api/stat', headerList)
const result = await res.json()
const avatarStr = await getSetting()
const { mirror, params, default:defaults } = avatarStr.data.frontend_conf.gravatar
const avatarCdn = !{avatarCdn} || mirror
let avatarDefault = !{avatarDefault} || params || defaults
avatarDefault = avatarDefault.startsWith('d=') ? avatarDefault : `d=${avatarDefault}`
const artalk = result.data.map(function (e) {
return {
'avatar': `${avatarCdn}${e.email_encrypted}?${avatarDefault}`,
'content': changeContent(e.content_marked),
'nick': e.nick,
'url': e.page_url,
'date': e.date,
}
})
saveToLocal.set('artalk-newest-comments', JSON.stringify(artalk), !{theme.newest_comments.storage}/(60*24))
generateHtml(artalk)
} catch (e) {
console.log(e)
const $dom = document.querySelector('#card-newest-comments .aside-list')
$dom.innerHTML= "!{_p('aside.card_newest_comments.error')}"
}
}
const newestCommentInit = () => {
if (document.querySelector('#card-newest-comments .aside-list')) {
const data = saveToLocal.get('artalk-newest-comments')
if (data) {
generateHtml(JSON.parse(data))
} else {
getComment()
}
}
}
newestCommentInit()
document.addEventListener('pjax:complete', newestCommentInit)
})

View File

@@ -1,82 +0,0 @@
script.
window.addEventListener('load', () => {
const changeContent = (content) => {
if (content === '') return content
content = content.replace(/<img.*?src="(.*?)"?[^\>]+>/ig, '[!{_p("aside.card_newest_comments.image")}]') // replace image link
content = content.replace(/<a[^>]+?href=["']?([^"']+)["']?[^>]*>([^<]+)<\/a>/gi, '[!{_p("aside.card_newest_comments.link")}]') // replace url
content = content.replace(/<code>.*?<\/code>/gi, '[!{_p("aside.card_newest_comments.code")}]') // replace code
content = content.replace(/<[^>]+>/g,"") // remove html tag
if (content.length > 150) {
content = content.substring(0,150) + '...'
}
return content
}
const getComment = () => {
fetch('https://disqus.com/api/3.0/forums/listPosts.json?forum=!{forum}&related=thread&limit=!{theme.newest_comments.limit}&api_key=!{apiKey}')
.then(response => response.json())
.then(data => {
const disqusArray = data.response.map(item => {
return {
'avatar': item.author.avatar.cache,
'content': changeContent(item.message),
'nick': item.author.name,
'url': item.url,
'date': item.createdAt
}
})
saveToLocal.set('disqus-newest-comments', JSON.stringify(disqusArray), !{theme.newest_comments.storage}/(60*24))
generateHtml(disqusArray)
}).catch(e => {
const $dom = document.querySelector('#card-newest-comments .aside-list')
$dom.textContent= "!{_p('aside.card_newest_comments.error')}"
})
}
const generateHtml = array => {
let result = ''
if (array.length) {
for (let i = 0; i < array.length; i++) {
result += '<div class=\'aside-list-item\'>'
if (!{theme.newest_comments.avatar}) {
const name = '!{theme.lazyload.enable ? "data-lazy-src" : "src"}'
result += `<a href='${array[i].url}' class='thumbnail'><img ${name}='${array[i].avatar}' alt='${array[i].nick}'></a>`
}
result += `<div class='content'>
<a class='comment' href='${array[i].url}' title='${array[i].content}'>${array[i].content}</a>
<div class='name'><span>${array[i].nick}</span><time> / ${btf.diffDate(array[i].date, true)}</time></div>
</div></div>`
}
} else {
result += '!{_p("aside.card_newest_comments.zero")}'
}
let $dom = document.querySelector('#card-newest-comments .aside-list')
$dom.innerHTML= result
window.lazyLoadInstance && window.lazyLoadInstance.update()
window.pjax && window.pjax.refresh($dom)
}
const newestCommentInit = () => {
if (document.querySelector('#card-newest-comments .aside-list')) {
const data = saveToLocal.get('disqus-newest-comments')
if (data) {
generateHtml(JSON.parse(data))
} else {
getComment()
}
}
}
newestCommentInit()
document.addEventListener('pjax:complete', newestCommentInit)
})

View File

@@ -1,109 +0,0 @@
script.
window.addEventListener('load', () => {
const changeContent = (content) => {
if (content === '') return content
content = content.replace(/<img.*?src="(.*?)"?[^\>]+>/ig, '[!{_p("aside.card_newest_comments.image")}]') // replace image link
content = content.replace(/<a[^>]+?href=["']?([^"']+)["']?[^>]*>([^<]+)<\/a>/gi, '[!{_p("aside.card_newest_comments.link")}]') // replace url
content = content.replace(/<pre><code>.*?<\/pre>/gi, '[!{_p("aside.card_newest_comments.code")}]') // replace code
content = content.replace(/<[^>]+>/g,"") // remove html tag
if (content.length > 150) {
content = content.substring(0,150) + '...'
}
return content
}
const findTrueUrl = (array) => {
Promise.all(array.map(item =>
fetch(item.url).then(resp => resp.json()).then(data => {
const urlArray = data.body.match(/(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?/ig)
if (data.user.login === 'utterances-bot') {
return urlArray.pop()
} else {
return urlArray.shift()
}
})
)).then(res => {
array = array.map((i,index)=> {
return {
...i,
url: res[index]
}
})
saveToLocal.set('github-newest-comments', JSON.stringify(array), !{theme.newest_comments.storage}/(60*24))
generateHtml(array)
});
}
const getComment = () => {
fetch('https://api.github.com/repos/!{userRepo}/issues/comments?sort=updated&direction=desc&per_page=!{theme.newest_comments.limit}&page=1',{
"headers": {
Accept: 'application/vnd.github.v3.html+json'
}
})
.then(response => response.json())
.then(data => {
const githubArray = data.map(item => {
return {
'avatar': item.user.avatar_url,
'content': changeContent(item.body_html),
'nick': item.user.login,
'url': item.issue_url,
'date': item.updated_at,
'githubUrl': item.html_url
}
})
findTrueUrl(githubArray)
}).catch(e => {
const $dom = document.querySelector('#card-newest-comments .aside-list')
$dom.textContent= "!{_p('aside.card_newest_comments.error')}"
})
}
const generateHtml = array => {
let result = ''
if (array.length) {
for (let i = 0; i < array.length; i++) {
result += '<div class=\'aside-list-item\'>'
if (!{theme.newest_comments.avatar}) {
const name = '!{theme.lazyload.enable ? "data-lazy-src" : "src"}'
result += `<a href='${array[i].url}' class='thumbnail'><img ${name}='${array[i].avatar}' alt='${array[i].nick}'></a>`
}
result += `<div class='content'>
<a class='comment' href='${array[i].url}' title='${array[i].content}'>${array[i].content}</a>
<div class='name'><span>${array[i].nick} / </span><time datetime="${array[i].date}">${btf.diffDate(array[i].date, true)}</time></div>
</div></div>`
}
} else {
result += '!{_p("aside.card_newest_comments.zero")}'
}
let $dom = document.querySelector('#card-newest-comments .aside-list')
$dom.innerHTML= result
window.lazyLoadInstance && window.lazyLoadInstance.update()
window.pjax && window.pjax.refresh($dom)
}
const newestCommentInit = () => {
if (document.querySelector('#card-newest-comments .aside-list')) {
const data = saveToLocal.get('github-newest-comments')
if (data) {
generateHtml(JSON.parse(data))
} else {
getComment()
}
}
}
newestCommentInit()
document.addEventListener('pjax:complete', newestCommentInit)
})

View File

@@ -1,30 +0,0 @@
- let { use } = theme.comments
if use
- let forum,apiKey,userRepo
case use[0]
when 'Valine'
include ./valine.pug
when 'Waline'
include ./waline.pug
when 'Twikoo'
include ./twikoo-comment.pug
when 'Disqus'
- forum = theme.disqus.shortname
- apiKey = theme.disqus.apikey
include ./disqus-comment.pug
when 'Disqusjs'
- forum = theme.disqusjs.shortname
- apiKey = theme.disqusjs.apikey
include ./disqus-comment.pug
when 'Gitalk'
- let { repo,owner } = theme.gitalk
- userRepo = owner + '/' + repo
include ./github-issues.pug
when 'Utterances'
- userRepo = theme.utterances.repo
include ./github-issues.pug
when 'Remark42'
include ./remark42.pug
when 'Artalk'
include ./artalk.pug

View File

@@ -1,80 +0,0 @@
- const { host, siteId } = theme.remark42
script.
window.addEventListener('load', () => {
const changeContent = (content) => {
if (content === '') return content
content = content.replace(/<img.*?src="(.*?)"?[^\>]+>/ig, '[!{_p("aside.card_newest_comments.image")}]') // replace image link
content = content.replace(/<a[^>]+?href=["']?([^"']+)["']?[^>]*>([^<]+)<\/a>/gi, '[!{_p("aside.card_newest_comments.link")}]') // replace url
content = content.replace(/<pre><code>.*?<\/pre>/gi, '[!{_p("aside.card_newest_comments.code")}]') // replace code
content = content.replace(/<[^>]+>/g,"") // remove html tag
if (content.length > 150) {
content = content.substring(0,150) + '...'
}
return content
}
const generateHtml = array => {
let result = ''
if (array.length) {
for (let i = 0; i < array.length; i++) {
result += '<div class=\'aside-list-item\'>'
if (!{theme.newest_comments.avatar}) {
const name = '!{theme.lazyload.enable ? "data-lazy-src" : "src"}'
result += `<a href='${array[i].url}' class='thumbnail'><img ${name}='${array[i].avatar}' alt='${array[i].nick}'></a>`
}
result += `<div class='content'>
<a class='comment' href='${array[i].url}' title='${array[i].content}'>${array[i].content}</a>
<div class='name'><span>${array[i].nick} / </span><time datetime="${array[i].date}">${btf.diffDate(array[i].date, true)}</time></div>
</div></div>`
}
} else {
result += '!{_p("aside.card_newest_comments.zero")}'
}
let $dom = document.querySelector('#card-newest-comments .aside-list')
$dom.innerHTML= result
window.lazyLoadInstance && window.lazyLoadInstance.update()
window.pjax && window.pjax.refresh($dom)
}
const getComment = () => {
fetch('!{host}/api/v1/last/!{theme.newest_comments.limit}?site=!{siteId}')
.then(response => response.json())
.then(data => {
const remark42 = data.map(function (e) {
return {
'avatar': e.user.picture,
'content': changeContent(e.text),
'nick': e.user.name,
'url': e.locator.url,
'date': e.time,
}
})
saveToLocal.set('remark42-newest-comments', JSON.stringify(remark42), !{theme.newest_comments.storage}/(60*24))
generateHtml(remark42)
}).catch(e => {
const $dom = document.querySelector('#card-newest-comments .aside-list')
$dom.textContent= "!{_p('aside.card_newest_comments.error')}"
})
}
const newestCommentInit = () => {
if (document.querySelector('#card-newest-comments .aside-list')) {
const data = saveToLocal.get('remark42-newest-comments')
if (data) {
generateHtml(JSON.parse(data))
} else {
getComment()
}
}
}
newestCommentInit()
document.addEventListener('pjax:complete', newestCommentInit)
})

View File

@@ -1,93 +0,0 @@
script.
window.addEventListener('load', () => {
const changeContent = (content) => {
if (content === '') return content
content = content.replace(/<img.*?src="(.*?)"?[^\>]+>/ig, '[!{_p("aside.card_newest_comments.image")}]') // replace image link
content = content.replace(/<a[^>]+?href=["']?([^"']+)["']?[^>]*>([^<]+)<\/a>/gi, '[!{_p("aside.card_newest_comments.link")}]') // replace url
content = content.replace(/<pre><code>.*?<\/pre>/gi, '[!{_p("aside.card_newest_comments.code")}]') // replace code
content = content.replace(/<[^>]+>/g,"") // remove html tag
if (content.length > 150) {
content = content.substring(0,150) + '...'
}
return content
}
const getComment = () => {
const runTwikoo = () => {
twikoo.getRecentComments({
envId: '!{theme.twikoo.envId}',
region: '!{theme.twikoo.region}',
pageSize: !{theme.newest_comments.limit},
includeReply: true
}).then(function (res) {
const twikooArray = res.map(e => {
return {
'content': changeContent(e.comment),
'avatar': e.avatar,
'nick': e.nick,
'url': e.url + '#' + e.id,
'date': new Date(e.created).toISOString()
}
})
saveToLocal.set('twikoo-newest-comments', JSON.stringify(twikooArray), !{theme.newest_comments.storage}/(60*24))
generateHtml(twikooArray)
}).catch(function (err) {
const $dom = document.querySelector('#card-newest-comments .aside-list')
$dom.textContent= "!{_p('aside.card_newest_comments.error')}"
})
}
if (typeof twikoo === 'object') {
runTwikoo()
} else {
getScript('!{url_for(theme.asset.twikoo)}').then(runTwikoo)
}
}
const generateHtml = array => {
let result = ''
if (array.length) {
for (let i = 0; i < array.length; i++) {
result += '<div class=\'aside-list-item\'>'
if (!{theme.newest_comments.avatar}) {
const name = '!{theme.lazyload.enable ? "data-lazy-src" : "src"}'
result += `<a href='${array[i].url}' class='thumbnail'><img ${name}='${array[i].avatar}' alt='${array[i].nick}'></a>`
}
result += `<div class='content'>
<a class='comment' href='${array[i].url}' title='${array[i].content}'>${array[i].content}</a>
<div class='name'><span>${array[i].nick} / </span><time datetime="${array[i].date}">${btf.diffDate(array[i].date, true)}</time></div>
</div></div>`
}
} else {
result += '!{_p("aside.card_newest_comments.zero")}'
}
let $dom = document.querySelector('#card-newest-comments .aside-list')
$dom.innerHTML= result
window.lazyLoadInstance && window.lazyLoadInstance.update()
window.pjax && window.pjax.refresh($dom)
}
const newestCommentInit = () => {
if (document.querySelector('#card-newest-comments .aside-list')) {
const data = saveToLocal.get('twikoo-newest-comments')
if (data) {
generateHtml(JSON.parse(data))
} else {
getComment()
}
}
}
newestCommentInit()
document.addEventListener('pjax:complete', newestCommentInit)
})

Some files were not shown because too many files have changed in this diff Show More