diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE/bug_report.md similarity index 64% rename from .github/ISSUE_TEMPLATE.md rename to .github/ISSUE_TEMPLATE/bug_report.md index c7a86b3..850acf3 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -1,21 +1,30 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: '' +assignees: '' + +--- + -## I want to create a new issue +## I want to create a Bug report - + - [] 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 [Hexo-theme-butterfly Documentation](https://jerryc.me/posts/21cfbf15/). +- [] 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 @@ -34,19 +43,17 @@ If you are a problem when visit the website, please open your browser 'developer ## Actual behavior - - - ## Steps to reproduce the behavior +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error -## Feature Request + + +## Screenshots - - + +## Website ---- - - \ No newline at end of file +## Describe the bug diff --git a/.github/ISSUE_TEMPLATE/custom.md b/.github/ISSUE_TEMPLATE/custom.md new file mode 100644 index 0000000..48d5f81 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/custom.md @@ -0,0 +1,10 @@ +--- +name: Custom issue template +about: Describe this issue template's purpose here. +title: '' +labels: '' +assignees: '' + +--- + + diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..bbcbbe7 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -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. diff --git a/LICENSE b/LICENSE index 472ac23..7a4a3ea 100644 --- a/LICENSE +++ b/LICENSE @@ -1,8 +1,202 @@ -MIT License -Copyright (c) -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/README.md b/README.md index 1aea826..7184e82 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,15 @@ # hexo-theme-butterfly -Version -Author -Hexo -node.js +![version](https://img.shields.io/github/package-json/v/jerryc127/hexo-theme-butterfly) +![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-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) -Demo: 👍 [Butterfly](https://demo.jerryc.me/) || 🤞 [JerryC](https://jerryc.me/) +Demo: 👍 [Butterfly](https://demo.jerryc.me/) || 🤞 [JerryC](https://jerryc.me/) + +Docs: 📖 [Butterfly Docs](https://demo.jerryc.me/posts/21cfbf15/) Based on [hexo-theme-melody](https://github.com/Molunerfinn/hexo-theme-melody) theme. @@ -33,18 +37,6 @@ git clone -b dev https://github.com/jerryc127/hexo-theme-butterfly.git themes/bu > npm install hexo-renderer-pug hexo-renderer-stylus -## Documentation - -Find in [Butterfly Docs](https://demo.jerryc.me/posts/21cfbf15/). it supports `zh-TW` and `zh-CN` - -You can also join the Chat Group. - -[💬 Join QQ Group [recommend]](https://jq.qq.com/?_wv=1027&k=5KI3Jqb) - -[💬 Join Telegram Group](https://t.me/hexo_butterfly) - - - ## Screenshots ![image](https://user-images.githubusercontent.com/16351105/58887365-1272f780-8718-11e9-9329-3292c6ba20d4.png) diff --git a/README_CN.md b/README_CN.md index c951209..6d5955a 100644 --- a/README_CN.md +++ b/README_CN.md @@ -1,11 +1,16 @@ # hexo-theme-butterfly -Version -Author -Hexo -node.js +![version](https://img.shields.io/github/package-json/v/jerryc127/hexo-theme-butterfly) +![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-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) -Demo: 👍 [Butterfly](https://demo.jerryc.me/) || 🤞 [JerryC](https://jerryc.me/) + +預覽: 👍 [Butterfly](https://demo.jerryc.me/) || 🤞 [JerryC](https://jerryc.me/) + +文檔: 📖 [Butterfly Docs](https://demo.jerryc.me/posts/21cfbf15/) 一款基於[hexo-theme-melody](https://github.com/Molunerfinn/hexo-theme-melody)修改的主題 @@ -30,17 +35,7 @@ git clone -b dev https://github.com/jerryc127/hexo-theme-butterfly.git themes/bu theme: butterfly ``` ->如果你沒有pug以及stylus的渲染器,請下載安裝: npm install hexo-renderer-pug hexo-renderer-stylus --save or yarn add hexo-renderer-pug hexo-renderer-stylus - -## 文檔 - -可查看[Butterfly Docs](https://demo.jerryc.me/posts/21cfbf15/) - -你也可以加入群組 - -[ 💬 QQ群 [推薦]](https://jq.qq.com/?_wv=1027&k=5KI3Jqb) - -[ 💬 Telegram群](https://t.me/hexo_butterfly) +>如果你沒有pug以及stylus的渲染器,請下載安裝: npm install hexo-renderer-pug hexo-renderer-stylus --save ## 截圖 diff --git a/_config.yml b/_config.yml index ff041a8..7f52dc6 100644 --- a/_config.yml +++ b/_config.yml @@ -7,20 +7,20 @@ # name || link || icon menu: - Home: / || fas fa-home - Archives: /archives/ || fas fa-archive - Tags: /tags/ || fas fa-tags - Categories: /categories/ || fas fa-folder-open - List||fas fa-list: - - Music || /music/ || fas fa-music - - Movie || /movies/ || fas fa-video - Link: /link/ || fas fa-link - About: /about/ || fas fa-heart + # Home: / || fas fa-home + # Archives: /archives/ || fas fa-archive + # Tags: /tags/ || fas fa-tags + # Categories: /categories/ || fas fa-folder-open + # List||fas fa-list: + # - Music || /music/ || fas fa-music + # - Movie || /movies/ || fas fa-video + # Link: /link/ || fas fa-link + # About: /about/ || fas fa-heart # Code Blocks (代碼相關) # -------------------------------------- -highlight_theme: light # default / darker / pale night / light / ocean / mac / false +highlight_theme: light # default / darker / pale night / light / ocean / mac / mac light / false highlight_copy: true # copy button highlight_lang: true # show the code language highlight_shrink: false # true: shrink the code blocks / false: expand the code blocks | none: expand code blocks and hide the button @@ -30,14 +30,16 @@ code_word_wrap: false # copyright: Add the copyright information after copied content (複製的內容後面加上版權信息) copy: enable: true - copyright: false + copyright: + enable: false + limit_count: 50 # social settings (社交圖標設置) # formal: # icon: link || the description social: - fab fa-github: https://github.com/xxxxx || Github - fas fa-envelope: mailto:xxxxxx@gmail.com || Email + # fab fa-github: https://github.com/xxxxx || Github + # fas fa-envelope: mailto:xxxxxx@gmail.com || Email # search (搜索) # -------------------------------------- @@ -92,18 +94,18 @@ avatar: # the banner image of home page index_img: -# if the banner of page not setting,it will show the top_img +# if the banner of page not setting, it will show the top_img default_top_img: https://i.loli.net/2020/05/01/IuWi8QbHvzjlOPw.jpg # the banner image of archive page archive_img: # the banner image of tag page -# tag page, look like https://xxxxxxxxx.com/tags/butterfly +# note: tag page, not tags page (子標籤頁面的 top_img) tag_img: # the banner image of category page -# category page, look like https://xxxxxxxxx.com/categories/butterfly +# note: category page, not categories page (子分類頁面的 top_img) category_img: # If you are using hexo-douban, you can configure it (如果你有使用 hexo-douban,可配置這個) @@ -122,7 +124,7 @@ cover: # left/right/both position: both # When cover is not set, the default cover is displayed (當沒有設置cover時,默認的封面顯示) - default_cover: + default_cover: - https://i.loli.net/2020/05/01/gkihqEjXxJ5UZ1C.jpg # Replace Broken Images (替換無法顯示的圖片) @@ -141,10 +143,12 @@ post_meta: date_type: created # created or updated or both 主頁文章日期是創建日或者更新日或都顯示 categories: true # true or false 主頁是否顯示分類 tags: false # true or false 主頁是否顯示標籤 + label: true # true or false 顯示描述性文字 post: date_type: both # created or updated or both 文章頁日期是創建日或者更新日或都顯示 categories: true # true or false 文章頁是否顯示分類 tags: true # true or false 文章頁是否顯示標籤 + label: true # true or false 顯示描述性文字 # wordcount (字數統計) wordcount: @@ -155,7 +159,7 @@ wordcount: # Display the article introduction on homepage # 1: description -# 2: both (if the description exists, it will show description. or show the auto_excerpt) +# 2: both (if the description exists, it will show description, or show the auto_excerpt) # 3: auto_excerpt (default) index_post_content: method: 3 @@ -180,12 +184,12 @@ post_copyright: reward: enable: false QR_code: - - img: /img/wechat.jpg - link: - text: wechat - - img: /img/alipay.jpg - link: - text: alipay + # - img: /img/wechat.jpg + # link: + # text: wechat + # - img: /img/alipay.jpg + # link: + # text: alipay # Related Articles related_post: @@ -200,6 +204,15 @@ photofigcaption: false # when you scroll in post, the URL will update according to header id. anchor: false +# Displays outdated notice for a post (文章過期提醒) +noticeOutdate: + enable: false + style: flat # style: simple/flat + limit_day: 500 # When will it be shown + position: top # position: top/bottom + message_prev: It has been + message_next: days since the last update, the content of the article may be outdated. + # Share System (分享功能) # -------------------------------------- @@ -231,18 +244,27 @@ addtoany: # Comments System # -------------------------------------- +comments: + # Up to two comments system, the first will be shown as default + # Choose: Disqus/Disqusjs/Livere/Gitalk/Valine/Utterances/Facebook Comments + use: + # - Valine + # - Disqus + text: true # Display the comment name next to the button + # lazyload: The comment system will be load when comment element enters the browser's viewport. + # If you set it to false, the comment count will be invalid + lazyload: false + count: false # Display comment count in top_img + # disqus # https://disqus.com/ disqus: - enable: false shortname: - count: false # dispaly comment count in top_img # Alternative Disqus - Render comments with Disqus API -# DisqusJS評論系統,可以實現在網路審查地區載入 Disqus 評論列表,兼容原版 +# DisqusJS 評論系統,可以實現在網路審查地區載入 Disqus 評論列表,兼容原版 # https://github.com/SukkaW/DisqusJS disqusjs: - enable: false shortname: siteName: apikey: @@ -250,18 +272,15 @@ disqusjs: nocomment: # display when a blog post or an article has no comment attached admin: adminLabel: - count: false # dispaly comment count in top_img -# livere(來必力) +# livere (來必力) # https://www.livere.com/ livere: - enable: false uid: # gitalk # https://github.com/gitalk/gitalk gitalk: - enable: false client_id: client_secret: repo: @@ -272,31 +291,27 @@ gitalk: distractionFreeMode: false # Facebook-like distraction free mode. pagerDirection: last # Comment sorting direction, available values are last and first. createIssueManually: false # Gitalk will create a corresponding github issue for your every single page automatically - count: false # dispaly comment count in top_img # valine # https://valine.js.org valine: - enable: false # if you want use valine,please set this value is true appId: # leancloud application app id appKey: # leancloud application app key pageSize: 10 # comment list page size avatar: monsterid # gravatar style https://valine.js.org/#/avatar lang: en # i18n: zh-CN/zh-TW/en/ja - placeholder: Please leave your footprints # valine comment input placeholder(like: Please leave your footprints ) - guest_info: nick,mail,link #valine comment header info (nick/mail/link) + placeholder: Please leave your footprints # valine comment input placeholder (like: Please leave your footprints) + guest_info: nick,mail,link # valine comment header info (nick/mail/link) recordIP: false # Record reviewer IP serverURLs: # This configuration is suitable for domestic custom domain name users, overseas version will be automatically detected (no need to manually fill in) bg: # valine background emojiCDN: # emoji CDN enableQQ: false # enable the Nickname box to automatically get QQ Nickname and QQ Avatar requiredFields: nick,mail # required fields (nick/mail) - count: false # dispaly comment count in top_img # utterances # https://utteranc.es/ utterances: - enable: false repo: # Issue Mapping: pathname/url/title/og:title issue_term: pathname @@ -307,13 +322,11 @@ utterances: # Facebook Comments Plugin # https://developers.facebook.com/docs/plugins/comments/ facebook_comments: - enable: false app_id: user_id: # optional pageSize: 10 # The number of comments to show order_by: social # social/time/reverse_time lang: en_US # Language en_US/zh_CN/zh_TW and so on - count: false # Chat Services # -------------------------------------- @@ -349,20 +362,25 @@ gitter: enable: false room: +# crisp +# https://crisp.chat/en/ +crisp: + enable: false + website_id: + # Footer Settings # -------------------------------------- - -since: 2020 - -footer_custom_text: - -footer_copyright: true - -ICP: - enable: false - url: - text: - icon: /img/icp.png +footer: + owner: + enable: true + since: 2020 + custom_text: + copyright: true # Copyright of theme and framework + ICP: # Chinese ICP License + enable: false + url: + text: + icon: /img/icp.png # Analysis # -------------------------------------- @@ -382,6 +400,7 @@ tencent_analytics: # Google Adsense (谷歌廣告) google_adsense: enable: false + auto_ads: true js: https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js client: enable_page_level_ads: true @@ -411,6 +430,10 @@ baidu_site_verification: # see http://zhanzhang.so.com/ qihu_site_verification: +# Yandex Webmaster tools verification setting +# see https://webmaster.yandex.com/ +yandex_site_verification: + # Beautify/Effect (美化/效果) # -------------------------------------- @@ -434,7 +457,7 @@ qihu_site_verification: # The top_img settings of home page # default: top img - full screen, site info - middle (默認top_img全屏,site_info在中間) -# The positon of site info, eg: 300px/300em/300rem/10% (主頁標題距離頂部距離) +# The position of site info, eg: 300px/300em/300rem/10% (主頁標題距離頂部距離) index_site_info_top: # The height of top_img, eg: 300px/300em/300rem (主頁top_img高度) index_top_img_height: @@ -531,17 +554,17 @@ font: # 左上角網站名字 主頁居中網站名字 blog_title_font: font_link: https://fonts.googleapis.com/css?family=Titillium+Web&display=swap - font-family: Titillium Web, 'PingFang SC', 'Hiragino Sans GB', Microsoft YaHei', sans-serif + font-family: Titillium Web, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif # The setting of divider icon (水平分隔線圖標設置) hr_icon: enable: true - icon: # the unicode value of Font Awesome icon + icon: # the unicode value of Font Awesome icon, such as '\3423' icon-top: # the subtitle on homepage (主頁subtitle) subtitle: - enable: true + enable: false # Typewriter Effect (打字效果) effect: true # loop (循環打字) @@ -559,8 +582,6 @@ subtitle: # 開頭不允許轉義字元,如需要,請把整個句子用雙引號包住 # 如果關閉打字效果,subtitle只會顯示sub的第一行文字 sub: - - 今日事,今日畢 - - Never put off till tomorrow what you can do today # Loading Animation (加載動畫) preloader: false @@ -575,12 +596,17 @@ aside: card_author: enable: true description: + button: + icon: fab fa-github + text: Follow Me + link: https://github.com/xxxxxx card_announcement: enable: true content: This is my Blog card_recent_post: enable: true limit: 5 # if set 0 will show all + sort: date # date or updated card_categories: enable: true limit: 8 # if set 0 will show all @@ -615,7 +641,7 @@ runtimeshow: # Conversion between Traditional and Simplified Chinese (簡繁轉換) translate: - enable: true + enable: false # The text of a button default: 繁 # the language of website (1 - Traditional Chinese/ 2 - Simplified Chinese) @@ -680,6 +706,16 @@ note: # other # -------------------------------------- +# Pjax [Beta] +# It may contain bugs and unstable, give feedback when you find the bugs. +# https://github.com/MoOx/pjax +pjax: false + +# Inject the css and script (aplayer/meting) +aplayerInject: + enable: false + per_page: true + # Snackbar (Toast Notification 彈窗) # https://github.com/polonel/SnackBar # position 彈窗位置 @@ -736,7 +772,7 @@ fragment_cache: true # 插入代码到头部 之前 和 底部 之前 inject: head: - # - + # - bottom: # - @@ -750,8 +786,10 @@ CDN: main: /js/main.js utils: /js/utils.js + # pjax + pjax: https://cdn.jsdelivr.net/npm/pjax/pjax.min.js + # comments - blueimp_md5: https://cdn.jsdelivr.net/npm/blueimp-md5/js/md5.min.js gitalk: https://cdn.jsdelivr.net/npm/gitalk@latest/dist/gitalk.min.js gitalk_css: https://cdn.jsdelivr.net/npm/gitalk/dist/gitalk.min.css valine: https://cdn.jsdelivr.net/npm/valine/dist/Valine.min.js @@ -771,7 +809,7 @@ CDN: algolia_search_css: https://cdn.jsdelivr.net/npm/instantsearch.js@2.10.5/dist/instantsearch.min.css # math - mathjax: https://cdn.jsdelivr.net/npm/mathjax/MathJax.js?config=TeX-AMS-MML_HTMLorMML + mathjax: https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js katex: https://cdn.jsdelivr.net/npm/katex@latest/dist/katex.min.css katex_copytex: https://cdn.jsdelivr.net/npm/katex-copytex@latest/dist/katex-copytex.min.js katex_copytex_css: https://cdn.jsdelivr.net/npm/katex-copytex@latest/dist/katex-copytex.min.css @@ -787,7 +825,7 @@ CDN: lazyload: https://cdn.jsdelivr.net/npm/vanilla-lazyload/dist/lazyload.iife.min.js instantpage: https://cdn.jsdelivr.net/npm/instant.page/instantpage.min.js - typed: https://cdn.jsdelivr.net/npm/typed.js + typed: https://cdn.jsdelivr.net/npm/typed.js/lib/typed.min.js pangu: https://cdn.jsdelivr.net/npm/pangu/dist/browser/pangu.min.js # photo @@ -819,4 +857,4 @@ CDN: # aplayer aplayer_css: https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.css aplayer_js: https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.js - meting_js: https://cdn.jsdelivr.net/npm/meting@1.2.0/dist/Meting.min.js + meting_js: https://cdn.jsdelivr.net/gh/metowolf/MetingJS@1.2/dist/Meting.min.js diff --git a/languages/default.yml b/languages/default.yml index 6c601af..e3a5524 100644 --- a/languages/default.yml +++ b/languages/default.yml @@ -3,7 +3,7 @@ sidebar: have_read: You've read footer: - driven: Driven + framework: Framework theme: Theme copy: @@ -24,7 +24,8 @@ post: created: Created updated: Updated wordcount: Word count - min2read: 'Reading time: %s min' + min2read: Reading time + min2read_unit: min page_pv: Post View comments: Comments copyright: @@ -61,7 +62,6 @@ aside: card_tags: Tags card_archives: Archives card_recent_post: Recent Post - card_bookmark: Bookmark card_webinfo: headline: Info article_name: Article diff --git a/languages/en.yml b/languages/en.yml index 6c601af..e3a5524 100644 --- a/languages/en.yml +++ b/languages/en.yml @@ -3,7 +3,7 @@ sidebar: have_read: You've read footer: - driven: Driven + framework: Framework theme: Theme copy: @@ -24,7 +24,8 @@ post: created: Created updated: Updated wordcount: Word count - min2read: 'Reading time: %s min' + min2read: Reading time + min2read_unit: min page_pv: Post View comments: Comments copyright: @@ -61,7 +62,6 @@ aside: card_tags: Tags card_archives: Archives card_recent_post: Recent Post - card_bookmark: Bookmark card_webinfo: headline: Info article_name: Article diff --git a/languages/zh-CN.yml b/languages/zh-CN.yml index d66990e..ae6b207 100644 --- a/languages/zh-CN.yml +++ b/languages/zh-CN.yml @@ -3,7 +3,7 @@ sidebar: have_read: 你已经读了 footer: - driven: 驱动 + framework: 框架 theme: 主题 copy: @@ -24,7 +24,8 @@ post: created: 发表于 updated: 更新于 wordcount: 字数总计 - min2read: '阅读时长: %s 分钟' + min2read: 阅读时长 + min2read_unit: 分钟 page_pv: 阅读量 comments: 评论数 copyright: @@ -38,13 +39,13 @@ post: search: 搜索 algolia_search: input_placeholder: 搜索文章 - hits_empty: '找不到您查询的内容:${query}' + hits_empty: '找不到您查询的内容:${query}' hits_stats: '找到 ${hits} 条结果,用时 ${time} 毫秒' local_search: label: 本地搜索 input_placeholder: 搜索文章 - hits_empty: '找不到您查询的内容:${query}' + hits_empty: '找不到您查询的内容:${query}' powered: '提供支持' by: 由 @@ -63,7 +64,6 @@ aside: card_tags: 标签 card_archives: 归档 card_recent_post: 最新文章 - card_bookmark: 加入书签 card_webinfo: headline: 网站资讯 article_name: 文章数目 diff --git a/languages/zh-TW.yml b/languages/zh-TW.yml index 0e73531..74902a2 100644 --- a/languages/zh-TW.yml +++ b/languages/zh-TW.yml @@ -3,8 +3,8 @@ sidebar: have_read: 你已經讀了 footer: - driven: Power by - theme: Theme + framework: 框架 + theme: 主題 copy: success: 複製成功 @@ -24,7 +24,8 @@ post: created: 發表於 updated: 更新於 wordcount: 字數總計 - min2read: '閱讀時長: %s 分鐘' + min2read: 閲讀時長 + min2read_unit: 分鐘 page_pv: 閱讀量 comments: 評論數 copyright: @@ -38,13 +39,13 @@ post: search: 搜尋 algolia_search: input_placeholder: 搜尋文章 - hits_empty: '找不到您查詢的內容:${query}' + hits_empty: '找不到您查詢的內容:${query}' hits_stats: '找到 ${hits} 條結果,用時 ${time} 毫秒' local_search: label: 本地搜尋 input_placeholder: 搜尋文章 - hits_empty: '找不到您查詢的內容:${query}' + hits_empty: '找不到您查詢的內容:${query}' powered: '提供支援' by: 由 @@ -63,7 +64,6 @@ aside: card_tags: 標籤 card_archives: 歸檔 card_recent_post: 最新文章 - card_bookmark: 加入書籤 card_webinfo: headline: 網站資訊 article_name: 文章數目 diff --git a/layout/404.pug b/layout/404.pug index 0e6c394..1e7191b 100644 --- a/layout/404.pug +++ b/layout/404.pug @@ -26,5 +26,5 @@ html(lang=config.language data-theme=theme.display_mode) i.fas.fa-rocket = _p('error404.back_button') - !=partial('includes/search/index', {}, {cache:theme.fragment_cache}) + !=partial('includes/third-party/search/index', {}, {cache:theme.fragment_cache}) include includes/additional-js.pug diff --git a/layout/flink.pug b/layout/flink.pug index 178f683..fab186c 100644 --- a/layout/flink.pug +++ b/layout/flink.pug @@ -11,13 +11,14 @@ .flink-list-item a(href=url_for(item.link) title=item.name target="_blank") if theme.lazyload.enable - img(data-src=url_for(item.avatar) onerror=`this.onerror=null;this.src='` + url_for(theme.error_img.flink) + `'` alt=item.name ) + 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 ) - .flink-item-name= item.name - .flink-item-desc= item.descr + span.flink-item-name= item.name + span.flink-item-desc(title=item.descr)= item.descr != page.content - if page.comments !== false - include includes/comments/index.pug + if page.comments !== false && theme.comments && theme.comments.use + - var commentsJsLoad = true + !=partial('includes/third-party/comments/index', {}, {cache:theme.fragment_cache}) diff --git a/layout/includes/additional-js.pug b/layout/includes/additional-js.pug index effa64e..2e00ca6 100644 --- a/layout/includes/additional-js.pug +++ b/layout/includes/additional-js.pug @@ -1,76 +1,61 @@ -script(src=url_for(theme.CDN.jquery)) -script(src=url_for(theme.CDN.utils)) -script(src=url_for(theme.CDN.main)) +div + script(src=url_for(theme.CDN.jquery)) + script(src=url_for(theme.CDN.utils)) + script(src=url_for(theme.CDN.main)) -if theme.translate && theme.translate.enable - script(src=url_for(theme.CDN.translate)) + if theme.translate && theme.translate.enable + script(src=url_for(theme.CDN.translate)) -if theme.medium_zoom - script(src=url_for(theme.CDN.medium_zoom)) + if theme.medium_zoom + script(src=url_for(theme.CDN.medium_zoom)) + else if theme.fancybox + script(src=url_for(theme.CDN.fancybox)) -if theme.fancybox - script(src=url_for(theme.CDN.fancybox)) + if theme.instantpage + script(src=url_for(theme.CDN.instantpage) type="module" defer) -include ./math/index.pug + if theme.lazyload.enable + script(src=url_for(theme.CDN.lazyload) async) -if theme.fireworks && theme.fireworks.enable - script(src=url_for(theme.CDN.anime)) - script(src=url_for(theme.CDN.fireworks)) + if (theme.snackbar && theme.snackbar.enable) + script(src=url_for(theme.CDN.snackbar)) -if (theme.snackbar && theme.snackbar.enable) - script(src=url_for(theme.CDN.snackbar)) + if theme.pangu && theme.pangu.enable + !=partial('includes/third-party/pangu.pug', {}, {cache:theme.fragment_cache}) -if (theme.canvas_ribbon && theme.canvas_ribbon.enable) - include ./third-party/canvas-ribbon.pug + //- 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.canvas_ribbon_piao && theme.canvas_ribbon_piao.enable) - include ./third-party/canvas-ribbon-piao.pug + if theme.preloader + !=partial('includes/loading/loading-js', {}, {cache:theme.fragment_cache}) -if (theme.canvas_nest && theme.canvas_nest.enable) - include ./third-party/canvas-nest.pug + .js-pjax + if is_home() && theme.subtitle.enable + include ./third-party/subtitle.pug -if theme.activate_power_mode.enable - script(src=url_for(theme.CDN.activate_power_mode)) - script. - POWERMODE.colorful = #{theme.activate_power_mode.colorful}; - POWERMODE.shake = #{theme.activate_power_mode.shake}; - document.body.addEventListener('input', POWERMODE); + include ./third-party/math/index.pug -if theme.busuanzi.site_uv || theme.busuanzi.site_pv || theme.busuanzi.page_pv - script(async src=url_for(theme.CDN.busuanzi)) + if commentsJsLoad + include ./third-party/comments/js.pug -if theme.instantpage - script(src=url_for(theme.CDN.instantpage) type="module" defer) + if theme.busuanzi.site_uv || theme.busuanzi.site_pv || theme.busuanzi.page_pv + script(async src=url_for(theme.CDN.busuanzi)) -if theme.lazyload.enable - script(src=url_for(theme.CDN.lazyload) async) + !=fragment_cache('injectBottom', function(){return injectHtml(theme.inject.bottom)}) -//- 鼠標特效 -if theme.click_heart - script(src=url_for(theme.CDN.click_heart)) + !=partial('includes/third-party/effect', {}, {cache:theme.fragment_cache}) -if theme.ClickShowText && theme.ClickShowText.enable - script(src=url_for(theme.CDN.ClickShowText)) + !=partial('includes/third-party/chat/index', {}, {cache:theme.fragment_cache}) -if theme.pangu && theme.pangu.enable - include ./third-party/pangu.pug + if theme.aplayerInject && theme.aplayerInject.enable + if theme.pjax || theme.aplayerInject.per_page + include ./head/aplayer.pug + else if page.aplayer + include ./head/aplayer.pug -//- search -if theme.algolia_search && theme.algolia_search.enable - script(src=url_for(theme.CDN.algolia_js)) -else if theme.local_search && theme.local_search.enable - script(src=url_for(theme.CDN.local_search)) + if theme.pjax + !=partial('includes/third-party/pjax', {}, {cache:theme.fragment_cache}) -//- mermaid -if theme.mermaid.enable - include ./math/mermaid.pug - -if is_home() - include ./head/subtitle.pug - -!=fragment_cache('injectBottom', function(){return injectHtml(theme.inject.bottom)}) - -if theme.preloader - !=partial('includes/loading/loading-js', {}, {cache:theme.fragment_cache}) - -!=partial('includes/chat/index', {}, {cache:theme.fragment_cache}) diff --git a/layout/includes/chat/gitter.pug b/layout/includes/chat/gitter.pug deleted file mode 100644 index 51cdc0a..0000000 --- a/layout/includes/chat/gitter.pug +++ /dev/null @@ -1,28 +0,0 @@ -//- https://sidecar.gitter.im/ -script. - var isChatBtn = !{theme.chat_btn} - - if (isChatBtn) { - ((window.gitter = {}).chat = {}).options = { - room: '#{theme.gitter.room}', - activationElement: '#chat_btn' - }; - } else { - ((window.gitter = {}).chat = {}).options = { - room: '#{theme.gitter.room}', - }; - - if (!{theme.chat_hide_show}) { - var gitterBtn = document.getElementsByClassName('gitter-open-chat-button') - - function chatBtnHide () { - gitterBtn[0].style.display= 'none' - } - - function chatBtnShow () { - gitterBtn[0].style.display= 'block' - } - } - } - -script(src="https://sidecar.gitter.im/dist/sidecar.v1.js" async defer) \ No newline at end of file diff --git a/layout/includes/chat/tidio.pug b/layout/includes/chat/tidio.pug deleted file mode 100644 index 90270a7..0000000 --- a/layout/includes/chat/tidio.pug +++ /dev/null @@ -1,39 +0,0 @@ -script(src=`//code.tidio.co/${theme.tidio.public_key}.js` async) - -if theme.chat_btn - script. - (function() { - function onTidioChatApiReady() { - window.tidioChatApi.hide(); - window.tidioChatApi.on("close", function() { - window.tidioChatApi.hide(); - }); - } - if (window.tidioChatApi) { - window.tidioChatApi.on("ready", onTidioChatApiReady); - } else { - document.addEventListener("tidioChat-ready", onTidioChatApiReady); - } - - document.getElementById("chat_btn").addEventListener("click", function(){ - window.tidioChatApi.show(); - window.tidioChatApi.open(); - }); - })(); -else if theme.chat_hide_show - script. - function chatBtnHide () { - if (window.tidioChatApi) { - 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' - } - } - - diff --git a/layout/includes/comments/disqus.pug b/layout/includes/comments/disqus.pug deleted file mode 100644 index 661f53f..0000000 --- a/layout/includes/comments/disqus.pug +++ /dev/null @@ -1,24 +0,0 @@ -#disqus_thread -script. - var disqus_config = function () { - this.page.url = '!{ page.permalink }'; - this.page.identifier = '!{ page.path }'; - this.page.title = '!{ page.title }'; - }; - (function() { - var d = document, s = d.createElement('script'); - s.src = 'https://!{theme.disqus.shortname}.disqus.com/embed.js'; - s.setAttribute('data-timestamp', +new Date()); - (d.head || d.body).appendChild(s); - })(); - -if is_post() && theme.disqus.count - script. - function getDisqusCount() { - 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); - } - - window.addEventListener('load', getDisqusCount, false); \ No newline at end of file diff --git a/layout/includes/comments/disqusjs.pug b/layout/includes/comments/disqusjs.pug deleted file mode 100644 index 7d670d2..0000000 --- a/layout/includes/comments/disqusjs.pug +++ /dev/null @@ -1,25 +0,0 @@ -#disqus_thread -script(src=url_for(theme.CDN.disqusjs)) -script. - var dsqjs = new DisqusJS({ - shortname: '!{theme.disqusjs.shortname}', - siteName: '!{theme.disqusjs.siteName}', - identifier: '!{ page.path }', - url: '!{ page.permalink }', - title: '!{ page.title }', - api: '!{theme.disqusjs.api}', - apikey: '!{theme.disqusjs.apikey}', - nocomment: '!{theme.disqusjs.nocomment}', - admin: '!{theme.disqusjs.admin}', - adminLabel: '!{theme.disqusjs.adminLabel}' - }); - -if is_post() && theme.disqusjs.count - script. - function getDisqusCount() { - var d = document, s = d.createElement('script'); - s.src = 'https://!{theme.disqusjs.shortname}.disqus.com/count.js'; - s.id = 'dsq-count-scr'; - (d.head || d.body).appendChild(s); - } - window.addEventListener('load', getDisqusCount, false); diff --git a/layout/includes/comments/facebook_comments.pug b/layout/includes/comments/facebook_comments.pug deleted file mode 100644 index 50f8838..0000000 --- a/layout/includes/comments/facebook_comments.pug +++ /dev/null @@ -1,12 +0,0 @@ -#fb-root -script(async defer crossorigin="anonymous" src=`https://connect.facebook.net/${theme.facebook_comments.lang}/sdk.js#xfbml=1&version=v6.0`) -.fb-comments(data-colorscheme = theme.display_mode === 'dark' ? 'dark' : 'light' - data-href=urlNoIndex() - data-numposts= theme.facebook_comments.pageSize || 10 - data-order-by= theme.facebook_comments.order_by || 'social' - data-width="100%") - -if theme.darkmode.enable - script. - var themeNow = document.documentElement.getAttribute('data-theme') === 'dark' ? 'dark' : 'light' - document.getElementsByClassName('fb-comments')[0].setAttribute('data-colorscheme',themeNow) diff --git a/layout/includes/comments/gitalk.pug b/layout/includes/comments/gitalk.pug deleted file mode 100644 index 9a1fee9..0000000 --- a/layout/includes/comments/gitalk.pug +++ /dev/null @@ -1,27 +0,0 @@ -#gitalk-container -script. - 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(decodeURI(location.pathname)), - 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') - - function commentCount(n){ - try { - document.getElementsByClassName('gitalk-comment-count')[0].innerHTML= n - } catch (e) { - return false - } - } - - diff --git a/layout/includes/comments/index.pug b/layout/includes/comments/index.pug deleted file mode 100644 index a8d1a92..0000000 --- a/layout/includes/comments/index.pug +++ /dev/null @@ -1,29 +0,0 @@ -- var d = theme.disqus && theme.disqus.enable -- var dj = theme.disqusjs && theme.disqusjs.enable -- var l = theme.livere && theme.livere.enable -- var gt = theme.gitalk && theme.gitalk.enable -- var v = theme.valine && theme.valine.enable -- var u = theme.utterances && theme.utterances.enable -- var fb = theme.facebook_comments && theme.facebook_comments.enable -- var isComment = d || dj || l || gt || v || u || fb - -if isComment - hr - #post-comment - .comment_headling - i.fas.fa-comments.fa-fw - span= ' ' + _p('comment') - if d - include ./disqus.pug - else if dj - include ./disqusjs.pug - else if l - include ./livere.pug - else if gt - include ./gitalk.pug - else if v - include ./valine.pug - else if u - include ./utterances.pug - else if fb - include ./facebook_comments.pug \ No newline at end of file diff --git a/layout/includes/comments/utterances.pug b/layout/includes/comments/utterances.pug deleted file mode 100644 index d9cc76d..0000000 --- a/layout/includes/comments/utterances.pug +++ /dev/null @@ -1,21 +0,0 @@ -script#utterances_comment(src=theme.CDN.utterances - repo=theme.utterances.repo - issue-term=theme.utterances.issue_term - theme= theme.display_mode === 'dark' ? theme.utterances.dark_theme : theme.utterances.light_theme - crossorigin="anonymous" - async) - -if theme.darkmode.enable - script. - var themeNow = document.documentElement.getAttribute('data-theme') === 'dark' ? '#{theme.utterances.dark_theme}' : '#{theme.utterances.light_theme}' - document.getElementById('utterances_comment').setAttribute('theme',themeNow) - - function utterancesTheme () { - var theme = document.documentElement.getAttribute('data-theme') === 'dark' ? '#{theme.utterances.dark_theme}' : '#{theme.utterances.light_theme}' - const message = { - type: 'set-theme', - theme: theme - }; - const iframe = document.querySelector('.utterances-frame'); - iframe.contentWindow.postMessage(message, 'https://utteranc.es'); - } diff --git a/layout/includes/comments/valine.pug b/layout/includes/comments/valine.pug deleted file mode 100644 index d5c7493..0000000 --- a/layout/includes/comments/valine.pug +++ /dev/null @@ -1,35 +0,0 @@ -- let emojiMaps = '""' -if site.data.valine - - emojiMaps = JSON.stringify(site.data.valine) - -#vcomment.vcomment -script(src=url_for(theme.CDN.valine)) -script. - var requestSetting = function (from,set) { - var from = from - var setting = set.split(',').filter(function(item){ - return from.indexOf(item) > -1 - }); - setting = setting.length == 0 ? from :setting; - return setting - } - - var guestInfo = requestSetting(['nick','mail','link'],'#{ theme.valine.guest_info }') - var requiredFields = requestSetting(['nick','mail'],'#{ theme.valine.requiredFields }') - - window.valine = new Valine({ - el:'#vcomment', - appId: '#{theme.valine.appId}', - appKey: '#{theme.valine.appKey}', - placeholder: '#{theme.valine.placeholder}', - avatar: '#{theme.valine.avatar}', - meta: guestInfo, - pageSize: '#{theme.valine.pageSize}', - lang: '#{theme.valine.lang}', - recordIP: #{theme.valine.recordIP}, - serverURLs: '#{theme.valine.serverURLs}', - emojiCDN: '#{theme.valine.emojiCDN}', - emojiMaps: !{emojiMaps}, - enableQQ: #{theme.valine.enableQQ}, - requiredFields: requiredFields - }); diff --git a/layout/includes/footer.pug b/layout/includes/footer.pug index c1e710d..405c90c 100644 --- a/layout/includes/footer.pug +++ b/layout/includes/footer.pug @@ -1,24 +1,23 @@ #footer-wrap - - var now = new Date() - - var nowYear = now.getFullYear() - if theme.since && theme.since != nowYear - .copyright!= `©${theme.since} - ${nowYear} By ${config.author}` - else - .copyright!= `©${nowYear} By ${config.author}` - if theme.footer_copyright + if theme.footer.owner.enable + - var now = new Date() + - var nowYear = now.getFullYear() + if theme.footer.owner.since && theme.footer.owner.since != nowYear + .copyright!= `©${theme.footer.owner.since} - ${nowYear} By ${config.author}` + else + .copyright!= `©${nowYear} By ${config.author}` + if theme.footer.copyright .framework-info - span= _p('footer.driven') + ' ' - a(href='https://hexo.io') - span Hexo + span= _p('footer.framework') + ' ' + a(href='https://hexo.io')= 'Hexo' span.footer-separator | span= _p('footer.theme') + ' ' - a(href='https://github.com/jerryc127/hexo-theme-butterfly') - span Butterfly - if theme.footer_custom_text - .footer_custom_text!=`${theme.footer_custom_text}` - if theme.ICP.enable + a(href='https://github.com/jerryc127/hexo-theme-butterfly')= 'Butterfly' + if theme.footer.custom_text + .footer_custom_text!=`${theme.footer.custom_text}` + if theme.footer.ICP.enable .icp - a(href=theme.ICP.url) - if theme.ICP.icon - img.icp-icon(src=url_for(theme.ICP.icon)) - span=theme.ICP.text + 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 diff --git a/layout/includes/head.pug b/layout/includes/head.pug index bb40a6c..ea3808f 100644 --- a/layout/includes/head.pug +++ b/layout/includes/head.pug @@ -35,10 +35,6 @@ if theme.disable_baidu_transformation meta(http-equiv="Cache-Control" content="no-transform") meta(http-equiv="Cache-Control" content="no-siteapp") -if theme.douban - if theme.douban.meta && (is_current('/movies/', [strict]) || is_current('/books/', [strict]) || is_current('/games/', [strict])) - meta(name="referrer" content="no-referrer") - //- 預解析 !=partial('includes/head/preconnect', {}, {cache:theme.fragment_cache}) @@ -48,6 +44,11 @@ if theme.douban //- Open_Graph include ./head/Open_Graph.pug +if theme.facebook_comments.app_id + 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) + //- PWA if (theme.pwa && theme.pwa.enable) !=partial('includes/head/pwa', {}, {cache:theme.fragment_cache}) @@ -65,19 +66,10 @@ if theme.fancybox if (theme.snackbar && theme.snackbar.enable) link(rel='stylesheet', href=url_for(theme.CDN.snackbar_css)) -if is_post() - if(page.prev) - link(rel="prev" title=page.prev.title href=url_for(page.prev.permalink) ) - if(page.next) - link(rel="next" title=page.next.title href=url_for(page.next.permalink) ) - if theme.algolia_search.enable - link(rel="stylesheet" type="text/css" href=url_for(theme.CDN.algolia_search_css)) + link(rel='stylesheet' href=url_for(theme.CDN.algolia_search_css)) script(src=url_for(theme.CDN.algolia_search) defer) -//- comment css -include ./head/comment.pug - //- google_adsense !=partial('includes/head/google_adsense', {}, {cache:theme.fragment_cache}) @@ -96,5 +88,3 @@ include ./head/noscript.pug !=fragment_cache('injectHead', function(){return injectHtml(theme.inject.head)}) -if page.aplayer - include ./head/aplayer.pug \ No newline at end of file diff --git a/layout/includes/head/analytics.pug b/layout/includes/head/analytics.pug index 768b3e6..01b0469 100644 --- a/layout/includes/head/analytics.pug +++ b/layout/includes/head/analytics.pug @@ -9,14 +9,12 @@ if theme.baidu_analytics })(); if theme.google_analytics + script(async src=`https://www.googletagmanager.com/gtag/js?id=${theme.google_analytics}`) script. - (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=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;m.parentNode.insertBefore(a,m) - })(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); - - ga('create', '!{theme.google_analytics}', 'auto'); - ga('send', 'pageview'); + window.dataLayer = window.dataLayer || []; + function gtag(){dataLayer.push(arguments);} + gtag('js', new Date()); + gtag('config', '!{theme.google_analytics}'); if theme.tencent_analytics - script(src=`https://tajs.qq.com/stats?sId=${theme.tencent_analytics}` charset="UTF-8") + script(src=`https://tajs.qq.com/stats?sId=${theme.tencent_analytics}` charset="UTF-8" data-pjax) diff --git a/layout/includes/head/comment.pug b/layout/includes/head/comment.pug deleted file mode 100644 index 3597780..0000000 --- a/layout/includes/head/comment.pug +++ /dev/null @@ -1,14 +0,0 @@ -if (theme.facebook_comments.enable && page.comments !== false && !is_tag() && !is_category() && !is_archive() && !is_home()) - if theme.facebook_comments.app_id - 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) - -if (theme.disqusjs && theme.disqusjs.enable && page.comments !== false && !is_tag() && !is_category() && !is_archive() && !is_home()) - link(rel="stylesheet" type="text/css" href=url_for(theme.CDN.disqusjs_css)) - -if (theme.gitalk && theme.gitalk.enable && page.comments !== false && !is_tag() && !is_category() && !is_archive() && !is_home()) - link(rel="stylesheet" type="text/css" href=url_for(theme.CDN.gitalk_css)) - script(src=url_for(theme.CDN.gitalk)) - script(src=url_for(theme.CDN.blueimp_md5)) - diff --git a/layout/includes/head/config.pug b/layout/includes/head/config.pug index 3ffe6d2..3ad380a 100644 --- a/layout/includes/head/config.pug +++ b/layout/includes/head/config.pug @@ -36,14 +36,15 @@ }) } - var copyright = 'undefined' ; - if (theme.copy.enable && theme.copy.copyright){ - copyright = JSON.stringify({ + var copyright = 'undefined'; + if (theme.copy.enable && theme.copy.copyright.enable){ + copyright = JSON.stringify({ + limitCount: theme.copy.copyright.limit_count, languages: { - author: _p("copy_copyright.author") + ': ' + config.author, - link: _p("copy_copyright.link") + ': ', - source: _p("copy_copyright.source") + ': ' + config.title, - info: _p("copy_copyright.info") + author: _p("copy_copyright.author") + ': ' + config.author, + link: _p("copy_copyright.link") + ': ', + source: _p("copy_copyright.source") + ': ' + config.title, + info: _p("copy_copyright.info") } }) } @@ -74,12 +75,23 @@ }) } + var noticeOutdate = 'undefined'; + if (theme.noticeOutdate && theme.noticeOutdate.enable) { + noticeOutdate = JSON.stringify({ + limitDay: theme.noticeOutdate.limit_day, + position: theme.noticeOutdate.position, + messagePrev: theme.noticeOutdate.message_prev, + messageNext: theme.noticeOutdate.message_next, + }) + } + script. var GLOBAL_CONFIG = { root: '!{config.root}', algolia: !{algolia}, localSearch: !{localSearch}, translate: !{translate}, + noticeOutdate: !{noticeOutdate}, copy: { success: '!{_p("copy.success")}', error: '!{_p("copy.error")}', diff --git a/layout/includes/head/config_site.pug b/layout/includes/head/config_site.pug index 84167e8..c896b48 100644 --- a/layout/includes/head/config_site.pug +++ b/layout/includes/head/config_site.pug @@ -1,17 +1,19 @@ - let isHighlightShrink if (theme.highlight_shrink == 'none') isHighlightShrink = 'undefined' - else if (page.highlight_shrink !== null && page.toc !== undefined ) isHighlightShrink = page.highlight_shrink + else if (page.highlight_shrink === true || page.highlight_shrink === false) isHighlightShrink = page.highlight_shrink else isHighlightShrink = theme.highlight_shrink - const pageToc = page.toc !== null && page.toc !== undefined ? page.toc : theme.toc.enable + const pageToc = page.toc === true || page.toc === false ? page.toc : theme.toc.enable const showToc = is_post() && pageToc && (toc(page.content) !== '' || page.encrypt == true ) - -script. - var GLOBAL_CONFIG_SITE = { - isPost: !{is_post()}, - isHome: !{is_home()}, - isHighlightShrink: !{isHighlightShrink}, - isSidebar: !{showToc} +script#config_change + . + var GLOBAL_CONFIG_SITE = { + isPost: !{is_post()}, + isHome: !{is_home()}, + isHighlightShrink: !{isHighlightShrink}, + isSidebar: !{showToc}, + postUpdate: '!{full_date(page.updated)}' } diff --git a/layout/includes/head/google_adsense.pug b/layout/includes/head/google_adsense.pug index b3210ef..3ef1af9 100644 --- a/layout/includes/head/google_adsense.pug +++ b/layout/includes/head/google_adsense.pug @@ -1,7 +1,9 @@ if (theme.google_adsense && theme.google_adsense.enable) script(async src=theme.google_adsense.js) - script. - (adsbygoogle = window.adsbygoogle || []).push({ - google_ad_client: '!{theme.google_adsense.client}', - enable_page_level_ads: '!{theme.google_adsense.enable_page_level_ads}' - }); \ No newline at end of file + + if theme.google_adsense.auto_ads + script. + (adsbygoogle = window.adsbygoogle || []).push({ + google_ad_client: '!{theme.google_adsense.client}', + enable_page_level_ads: '!{theme.google_adsense.enable_page_level_ads}' + }); \ No newline at end of file diff --git a/layout/includes/head/noscript.pug b/layout/includes/head/noscript.pug index 761826c..bf995d7 100644 --- a/layout/includes/head/noscript.pug +++ b/layout/includes/head/noscript.pug @@ -3,7 +3,7 @@ noscript. #nav { opacity: 1 } - .justified-gallery img{ + .justified-gallery img { opacity: 1 } \ No newline at end of file diff --git a/layout/includes/head/pwa.pug b/layout/includes/head/pwa.pug index ca927dc..f318808 100644 --- a/layout/includes/head/pwa.pug +++ b/layout/includes/head/pwa.pug @@ -1,13 +1,13 @@ -link(rel="manifest" href=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) meta(name="msapplication-TileColor" content=theme.pwa.theme_color) if(theme.pwa.apple_touch_icon) - link(rel="apple-touch-icon" sizes="180x180" href=theme.pwa.apple_touch_icon) + link(rel="apple-touch-icon" sizes="180x180" href=url_for(theme.pwa.apple_touch_icon)) if(theme.pwa.favicon_32_32) - link(rel="icon" type="image/png" sizes="32x32" href=theme.pwa.favicon_32_32) + link(rel="icon" type="image/png" sizes="32x32" href=url_for(theme.pwa.favicon_32_32)) if(theme.pwa.favicon_16_16) - link(rel="icon" type="image/png" sizes="16x16" href=theme.pwa.favicon_16_16) + link(rel="icon" type="image/png" sizes="16x16" href=url_for(theme.pwa.favicon_16_16)) if(theme.pwa.mask_icon) - link(rel="mask-icon" href=theme.pwa.mask_icon color="#5bbad5") + link(rel="mask-icon" href=url_for(theme.pwa.mask_icon) color="#5bbad5") diff --git a/layout/includes/head/site_verification.pug b/layout/includes/head/site_verification.pug index 969883b..cae5742 100644 --- a/layout/includes/head/site_verification.pug +++ b/layout/includes/head/site_verification.pug @@ -9,3 +9,6 @@ if 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) \ No newline at end of file diff --git a/layout/includes/head/subtitle.pug b/layout/includes/head/subtitle.pug deleted file mode 100644 index 8f73b82..0000000 --- a/layout/includes/head/subtitle.pug +++ /dev/null @@ -1,130 +0,0 @@ -if theme.subtitle.enable - - var source = theme.subtitle.source - - var subtitleEffect = theme.subtitle.effect - - if subtitleEffect - script(src=url_for(theme.CDN.typed)) - - if source == '1' - script. - var subtitleType = function () { - var subtitleEffect = !{ subtitleEffect } - fetch('https://api.btstu.cn/yan/api.php?charset=utf-8&encode=json',) - .then(function (res) { - return res.json() - }) - .then(function (data) { - if (subtitleEffect) { - var sub = "!{theme.subtitle.sub}".length == 0 ? new Array() : "!{theme.subtitle.sub}".split(',') - var both = sub.unshift(data.text) - var typed = new Typed('#subtitle', { - strings: sub, - startDelay: 300, - typeSpeed: 150, - loop: !{theme.subtitle.loop}, - backSpeed: 50, - }) - } else { - document.getElementById('subtitle').innerHTML = data.text - } - }) - .catch(function (err) { - console.error(err) - }) - } - window.addEventListener('load', subtitleType) - - else if source == '2' - script. - var subtitleType = function () { - var subtitleEffect = !{ subtitleEffect } - fetch('https://v1.hitokoto.cn') - .then(function (res) { - return res.json() - }) - .then(function (data) { - if (subtitleEffect) { - var from = '出自 ' + data.from - var sub = "!{theme.subtitle.sub}".length == 0 ? new Array() : "!{theme.subtitle.sub}".split(',') - var both = sub.unshift(data.hitokoto, from) - var typed = new Typed('#subtitle', { - strings: sub, - startDelay: 300, - typeSpeed: 150, - loop: !{theme.subtitle.loop}, - backSpeed: 50, - }) - } else { - document.getElementById('subtitle').innerHTML = data.hitokoto - } - }) - .catch(function (err) { - console.error(err) - }) - } - window.addEventListener('load', subtitleType) - - else if source == '3' - script. - var subtitleType = function () { - loadScript('http://yijuzhan.com/api/word.php?m=js', function () { - var subtitleEffect = !{ subtitleEffect } - var con = str[0] - if (subtitleEffect) { - var from = '出自 ' + str[1] - var sub = "!{theme.subtitle.sub}".length == 0 ? new Array() : "!{theme.subtitle.sub}".split(',') - var both = sub.unshift(con, from) - var typed = new Typed('#subtitle', { - strings: sub, - startDelay: 300, - typeSpeed: 150, - loop: !{theme.subtitle.loop}, - backSpeed: 50, - }) - } else { - document.getElementById('subtitle').innerHTML = con - } - }) - } - window.addEventListener('load', subtitleType) - - else if source == '4' - script. - var subtitleType = function () { - loadScript('https://sdk.jinrishici.com/v2/browser/jinrishici.js',function () { - var subtitleEffect = !{ subtitleEffect } - jinrishici.load(function (result) { - if (subtitleEffect) { - var sub = "!{theme.subtitle.sub}".length == 0 ? new Array() : "!{theme.subtitle.sub}".split(',') - var content = result.data.content - var both = sub.unshift(content) - var typed = new Typed('#subtitle', { - strings: sub, - startDelay: 300, - typeSpeed: 150, - loop: !{theme.subtitle.loop}, - backSpeed: 50, - }) - } else { - document.getElementById('subtitle').innerHTML = result.data.content - } - }) - } - ) - } - window.addEventListener('load', subtitleType) - - else - script. - var subtitleEffect = !{subtitleEffect} - if (subtitleEffect) { - var typed = new Typed("#subtitle", { - strings: "!{theme.subtitle.sub}".split(","), - startDelay: 300, - typeSpeed: 150, - loop: !{theme.subtitle.loop}, - backSpeed: 50 - }) - } else { - document.getElementById("subtitle").innerHTML = '!{theme.subtitle.sub[0]}' - } diff --git a/layout/includes/header/menu_item.pug b/layout/includes/header/menu_item.pug index f029ad0..8b58c96 100644 --- a/layout/includes/header/menu_item.pug +++ b/layout/includes/header/menu_item.pug @@ -1,22 +1,23 @@ -.menus_items - each value, label in theme.menu - if !Array.isArray(value) - .menus_item - a.site-page(href=url_for(trim(value.split('||')[0]))) - if value.split('||')[1] - i.fa-fw(class=trim(value.split('||')[1])) - span=' '+label - else - .menus_item - a.site-page - if label.split('||')[1] - i.fa-fw(class=trim(label.split('||')[1]) ) - span=' '+ trim(label.split('||')[0]) - i.fas.fa-chevron-down.menus-expand - ul.menus_item_child - each i in value - li - a.site-page(href=url_for(trim(i.split('||')[1]))) - if i.split('||')[2] - i.fa-fw(class=trim(i.split('||')[2])) - span=' '+trim(i.split('||')[0]) \ No newline at end of file +if theme.menu + .menus_items + each value, label in theme.menu + if !Array.isArray(value) + .menus_item + a.site-page(href=url_for(trim(value.split('||')[0]))) + if value.split('||')[1] + i.fa-fw(class=trim(value.split('||')[1])) + span=' '+label + else + .menus_item + a.site-page(href='javascript:void(0);') + if label.split('||')[1] + i.fa-fw(class=trim(label.split('||')[1])) + span=' '+ trim(label.split('||')[0]) + i.fas.fa-chevron-down.expand + ul.menus_item_child + each i in value + li + a.site-page(href=url_for(trim(i.split('||')[1]))) + if i.split('||')[2] + i.fa-fw(class=trim(i.split('||')[2])) + span=' '+trim(i.split('||')[0]) \ No newline at end of file diff --git a/layout/includes/header/nav.pug b/layout/includes/header/nav.pug index 79bf9d6..eab38aa 100644 --- a/layout/includes/header/nav.pug +++ b/layout/includes/header/nav.pug @@ -3,7 +3,7 @@ nav#nav a#site-name.blog_title(href=url_for('/')) #[=config.title] span.pull-right.menus - if (theme.algolia_search.enable || theme.local_search && theme.local_search.enable) + if (theme.algolia_search.enable || theme.local_search.enable) #search_button a.site-page.social-icon.search i.fas.fa-search.fa-fw diff --git a/layout/includes/header/post-info.pug b/layout/includes/header/post-info.pug index 63439df..9fe7134 100644 --- a/layout/includes/header/post-info.pug +++ b/layout/includes/header/post-info.pug @@ -5,84 +5,79 @@ #post-meta .meta-firstline if (theme.post_meta.post.date_type) - if (theme.post_meta.post.date_type === 'both') - time.post-meta__date - span.post-meta__date-created(title= _p('post.created')+' '+full_date(page.date)) - i.far.fa-calendar-alt.fa-fw - =' '+_p('post.created')+' '+date(page.date, config.date_format) - span.post-meta__separator | - span.post-meta__date-updated(title= _p('post.updated')+' '+full_date(page.updated)) - i.fas.fa-history.fa-fw - =' '+_p('post.updated')+' '+date(page.updated, config.date_format) - else - - var data_type_update = theme.post_meta.post.date_type === 'updated' - - var date_type = data_type_update ? 'updated' : 'date' - - var date_icon = data_type_update ? 'fas fa-history' :'far fa-calendar-alt' - - var data_info = data_type_update ? _p('post.updated') : _p('post.created') - time.post-meta__date(title=data_info + ' ' + full_date(page[date_type])) - i.fa-fw(class=date_icon) - =' ' + data_info + ' ' + date(page[date_type], config.date_format) - + span.post-meta-date + if (theme.post_meta.post.date_type === 'both') + i.far.fa-calendar-alt.fa-fw.post-meta-icon + span.post-meta-label= _p('post.created') + time.post-meta-date-created(datetime=date_xml(page.date) title=_p('post.created') + ' ' + full_date(page.date))=date(page.date, config.date_format) + span.post-meta-separator | + i.fas.fa-history.fa-fw.post-meta-icon + span.post-meta-label= _p('post.updated') + time.post-meta-date-updated(datetime=date_xml(page.updated) title=_p('post.updated') + ' ' + full_date(page.updated))=date(page.updated, config.date_format) + else + - let data_type_update = theme.post_meta.post.date_type === 'updated' + - let date_type = data_type_update ? 'updated' : 'date' + - let date_icon = data_type_update ? 'fas fa-history' :'far fa-calendar-alt' + - let data_info = data_type_update ? _p('post.updated') : _p('post.created') + i.fa-fw.post-meta-icon(class=date_icon) + 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) if (theme.post_meta.post.categories && page.categories.data.length > 0) - span.post-meta__categories + span.post-meta-categories if (theme.post_meta.post.date_type) - span.post-meta__separator | + span.post-meta-separator | each item, index in page.categories.data - i.fas.fa-inbox.fa-fw.post-meta__icon - a(href=url_for(item.path)).post-meta__categories #[=item.name] + i.fas.fa-inbox.fa-fw.post-meta-icon + a(href=url_for(item.path)).post-meta-categories #[=item.name] if (index < page.categories.data.length - 1) - i.fas.fa-angle-right.post-meta__separator + i.fas.fa-angle-right.post-meta-separator .meta-secondline - let postWordcount = theme.wordcount.enable && (theme.wordcount.post_wordcount || theme.wordcount.min2read) if (postWordcount) + span.post-meta-separator | span.post-meta-wordcount if theme.wordcount.post_wordcount - i.far.fa-file-word.fa-fw.post-meta__icon - span= _p('post.wordcount') + ':' + i.far.fa-file-word.fa-fw.post-meta-icon + span.post-meta-label= _p('post.wordcount') + ':' span.word-count= wordcount(page.content) if theme.wordcount.min2read - span.post-meta__separator | + span.post-meta-separator | if theme.wordcount.min2read - i.far.fa-clock.fa-fw.post-meta__icon - span= _p('post.min2read', min2read(page.content, {cn: 350, en: 160})) + i.far.fa-clock.fa-fw.post-meta-icon + span.post-meta-label= _p('post.min2read') + ':' + span= min2read(page.content, {cn: 350, en: 160}) + _p('post.min2read_unit') - .meta-thirdline - span.post-meta-pv-cv - if (postWordcount && theme.busuanzi.page_pv) - span.post-meta__separator | - if theme.busuanzi.page_pv - i.far.fa-eye.fa-fw.post-meta__icon - span=_p('post.page_pv') + ':' + if theme.busuanzi.page_pv + span.post-meta-separator | + span.post-meta-pv-cv + i.far.fa-eye.fa-fw.post-meta-icon + span.post-meta-label=_p('post.page_pv') + ':' span#busuanzi_value_page_pv - span.post-meta-commentcount - if ((theme.disqus && theme.disqus.enable && theme.disqus.count && page.comments !== false) || (theme.disqusjs && theme.disqusjs.enable && theme.disqusjs.count && page.comments !== false)) - if (postWordcount || theme.busuanzi.page_pv) - span.post-meta__separator | - i.far.fa-comments.fa-fw.post-meta__icon - span= _p('post.comments') + ':' - span.disqus-comment-count.comment-count - a(href=full_url_for(page.path) + '#disqus_thread') - else if (theme.valine && theme.valine.enable && theme.valine.count && page.comments !== false) - if (postWordcount || theme.busuanzi.page_pv) - span.post-meta__separator | - i.far.fa-comments.fa-fw.post-meta__icon - span= _p('post.comments') + ':' - a(href=url_for(page.path) + '#post-comment' itemprop="discussionUrl") - span.valine-comment-count.comment-count(data-xid=url_for(page.path) itemprop="commentCount") - else if (theme.gitalk && theme.gitalk.enable && theme.gitalk.count && page.comments !== false) - if (postWordcount || theme.busuanzi.page_pv) - span.post-meta__separator | - i.far.fa-comments.fa-fw.post-meta__icon - span= _p('post.comments') + ':' - a(href=url_for(page.path) + '#post-comment') - span.gitalk-comment-count.comment-count - else if theme.facebook_comments.enable && theme.facebook_comments.count && page.comments !== false - if (postWordcount || theme.busuanzi.page_pv) - span.post-meta__separator | - i.far.fa-comments.fa-fw.post-meta__icon - span= _p('post.comments') + ':' - a.comment-count(href=url_for(page.path) + '#post-comment') - span.fb-comments-count(data-href=urlNoIndex()) \ No newline at end of file + if !theme.comments.lazyload && page.comments !== false && theme.comments.use && theme.comments.count + - var whichCount = theme.comments.use[0] + if whichCount !== 'Livere' && whichCount !== 'Utterances' + span.post-meta-separator | + 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 + span.post-meta-label= _p('post.comments') + ':' + a(href=url_for(page.path) + '#post-comment' itemprop="discussionUrl") + span.valine-comment-count.comment-count(data-xid=url_for(page.path) itemprop="commentCount") + else if whichCount === 'Gitalk' + i.far.fa-comments.fa-fw.post-meta-icon + span.post-meta-label= _p('post.comments') + ':' + 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()) \ No newline at end of file diff --git a/layout/includes/layout.pug b/layout/includes/layout.pug index dae1612..467aca9 100644 --- a/layout/includes/layout.pug +++ b/layout/includes/layout.pug @@ -1,6 +1,4 @@ - var hideAside = !theme.aside.enable || page.aside === false ? 'hide-aside' : '' -- var pageHighlightShrinkSet = page.highlight_shrink !== undefined ? page.highlight_shrink : theme.highlight_shrink -- var pageHighlightShrink = theme.highlight_shrink !== 'none' && pageHighlightShrinkSet ? 'code-close' : '' doctype html html(lang=config.language data-theme=theme.display_mode) @@ -10,18 +8,14 @@ html(lang=config.language data-theme=theme.display_mode) if theme.preloader !=partial('includes/loading/loading', {}, {cache:theme.fragment_cache}) - if theme.fireworks && theme.fireworks.enable - canvas.fireworks - !=partial('includes/mobile-sidebar/index', {}, {cache:theme.fragment_cache}) - include ./sidebar.pug - - #body-wrap(class=pageHighlightShrink) + #body-wrap if theme.background - var is_photo = theme.background.startsWith('url') ? 'photo':'color' #web_bg(data-type=is_photo) + include ./sidebar.pug include ./header/index.pug if (!is_post()) @@ -44,5 +38,5 @@ html(lang=config.language data-theme=theme.display_mode) !=partial('includes/footer', {}, {cache:theme.fragment_cache}) include ./rightside.pug - !=partial('includes/search/index', {}, {cache:theme.fragment_cache}) + !=partial('includes/third-party/search/index', {}, {cache:theme.fragment_cache}) include ./additional-js.pug \ No newline at end of file diff --git a/layout/includes/math/mathjax.pug b/layout/includes/math/mathjax.pug deleted file mode 100644 index a28d1c0..0000000 --- a/layout/includes/math/mathjax.pug +++ /dev/null @@ -1,27 +0,0 @@ -script(type="text/x-mathjax-config"). - MathJax.Hub.Config({ - tex2jax: { - inlineMath: [ ['$','$'], ["\\(","\\)"] ], - processEscapes: true, - skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code'] - }, - CommonHTML: { - linebreaks: { automatic: true, width: "90% container" } - }, - "HTML-CSS": { - linebreaks: { automatic: true, width: "90% container" } - }, - "SVG": { - linebreaks: { automatic: true, width: "90% container" } - } - }); - -script(type="text/x-mathjax-config"). - MathJax.Hub.Queue(function() { - var all = MathJax.Hub.getAllJax(), i; - for (i=0; i < all.length; i += 1) { - all[i].SourceElement().parentNode.className += ' has-jax'; - } - }); - -script(src=theme.CDN.mathjax) \ No newline at end of file diff --git a/layout/includes/math/mermaid.pug b/layout/includes/math/mermaid.pug deleted file mode 100644 index 7984358..0000000 --- a/layout/includes/math/mermaid.pug +++ /dev/null @@ -1,8 +0,0 @@ -script. - if (document.getElementsByClassName('mermaid').length) { - loadScript('!{theme.CDN.mermaid}',function () { - mermaid.initialize({ - theme: '!{theme.mermaid.theme}', - }) - }) - } \ No newline at end of file diff --git a/layout/includes/mixins/article-sort.pug b/layout/includes/mixins/article-sort.pug index 22b35a2..c2f1b5e 100644 --- a/layout/includes/mixins/article-sort.pug +++ b/layout/includes/mixins/article-sort.pug @@ -2,19 +2,22 @@ mixin articleSort(posts) .article-sort - var year - posts.each(function (article) { - - var tempYear = date(article.date, 'YYYY') - - var no_cover = article.cover === false || !theme.cover.archives_enable ? 'no-article-cover' : '' + - let tempYear = date(article.date, 'YYYY') + - let no_cover = article.cover === false || !theme.cover.archives_enable ? 'no-article-cover' : '' + - let title = article.title || _p('no_title') if tempYear !== year - year = tempYear .article-sort-item.year= year .article-sort-item(class=no_cover) if article.cover && theme.cover.archives_enable - .article-sort-img - a.article-sort-item__img(href=url_for(article.path)) - img(src=url_for(article.cover) alt=article.title || 'No Title' onerror=`this.onerror=null;this.src='`+ url_for(theme.error_img.post_page) + `'`) - .article-sort-post - a.article-sort-item__post(href=url_for(article.path)) + a.article-sort-item-img(href=url_for(article.path) title=title) + if theme.lazyload.enable + img(data-lazy-src=url_for(article.cover) alt=title onerror=`this.onerror=null;this.src='${url_for(theme.error_img.post_page)}'`) + else + 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-time i.far.fa-calendar-alt - time.article-sort-item__time(title=_p('post.created') + ' ' + full_date(article.date))= date(article.date, config.date_format) - .article-sort-item__title= article.title || 'No Title' + time.post-meta-date-created(datetime=date_xml(article.date) title=_p('post.created') + ' ' + full_date(article.date))= date(article.date, config.date_format) + a.article-sort-item-title(href=url_for(article.path) title=title)= title - }) \ No newline at end of file diff --git a/layout/includes/mixins/post-ui.pug b/layout/includes/mixins/post-ui.pug index e9455d0..51543c6 100644 --- a/layout/includes/mixins/post-ui.pug +++ b/layout/includes/mixins/post-ui.pug @@ -1,16 +1,16 @@ mixin postUI(posts) each article , index in page.posts.data .recent-post-item - - var link = article.link || article.path - - var title = article.title || _p('no_title') - - var leftOrRight = index%2 == 0 ? 'left_radius' : 'right_radius' - - var post_cover = article.cover - - var no_cover = article.cover === false || !theme.cover.index_enable ? 'no-cover' : '' + - let link = article.link || article.path + - let title = article.title || _p('no_title') + - let leftOrRight = index%2 == 0 ? 'left_radius' : 'right_radius' + - let post_cover = article.cover + - let no_cover = article.cover === false || !theme.cover.index_enable ? 'no-cover' : '' if post_cover && theme.cover.index_enable .post_cover(class=leftOrRight) a(href=url_for(link) title=title) if theme.lazyload.enable - img.post_bg(data-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 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) @@ -22,23 +22,23 @@ mixin postUI(posts) span.sticky= _p('sticky') span.article-meta__separator | if (theme.post_meta.page.date_type) - if (theme.post_meta.page.date_type === 'both') - time.post-meta__date - span.post-meta__date-created(title=_p('post.created') + ' ' + full_date(article.date)) - i.far.fa-calendar-alt - =date(article.date, config.date_format) + span.post-meta-date + if (theme.post_meta.page.date_type === 'both') + i.far.fa-calendar-alt + 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) span.article-meta__separator | - span.post-meta__date-updated(title=_p('post.updated') + ' ' + full_date(article.updated)) - i.fas.fa-history - =date(article.updated, config.date_format) - else - - var data_type_updated = theme.post_meta.page.date_type === 'updated' - - var date_type = data_type_updated ? 'updated' : 'date' - - var date_icon = data_type_updated ? 'fas fa-history' :'far fa-calendar-alt' - - var date_title = data_type_updated ? _p('post.updated') : _p('post.created') - time.post-meta__date(title=date_title + ' ' + full_date(article[date_type])) + i.fas.fa-history + 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) + else + - let data_type_updated = theme.post_meta.page.date_type === 'updated' + - let date_type = data_type_updated ? 'updated' : 'date' + - let date_icon = data_type_updated ? 'fas fa-history' :'far fa-calendar-alt' + - let date_title = data_type_updated ? _p('post.updated') : _p('post.created') i(class=date_icon) - =date(article[date_type], config.date_format) + span.article-meta-label=date_title + 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) span.article-meta span.article-meta__separator | diff --git a/layout/includes/mobile-sidebar/mobile-menus.pug b/layout/includes/mobile-sidebar/mobile-menus.pug index ac562cd..42a0bed 100644 --- a/layout/includes/mobile-sidebar/mobile-menus.pug +++ b/layout/includes/mobile-sidebar/mobile-menus.pug @@ -1,6 +1,9 @@ #mobile-sidebar-menus .mobile_author_icon - img.avatar-img(src=url_for(theme.avatar.img) onerror=`onerror=null;src='${theme.error_img.flink}'` alt="avatar") + 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 diff --git a/layout/includes/pagination.pug b/layout/includes/pagination.pug index 0783343..ab09c1a 100644 --- a/layout/includes/pagination.pug +++ b/layout/includes/pagination.pug @@ -18,7 +18,7 @@ else - var pagination_cover = page.prev.cover === false ? page.prev.randomcover : page.prev.cover a(href=url_for(page.prev.path)) if theme.lazyload.enable - img.prev-cover(data-src=url_for(pagination_cover) onerror=`onerror=null;src='${url_for(theme.error_img.post_page)}'` ) + img.prev-cover(data-lazy-src=url_for(pagination_cover) onerror=`onerror=null;src='${url_for(theme.error_img.post_page)}'` ) else img.prev-cover(src=url_for(pagination_cover) onerror=`onerror=null;src='${url_for(theme.error_img.post_page)}'` ) .pagination-info @@ -31,7 +31,7 @@ else .next-post(class=hasPagePrev) a(href=url_for(page.next.path)) if theme.lazyload.enable - img.next-cover(data-src=url_for(pagination_cover) onerror=`onerror=null;src='${url_for(theme.error_img.post_page)}'`) + img.next-cover(data-lazy-src=url_for(pagination_cover) onerror=`onerror=null;src='${url_for(theme.error_img.post_page)}'`) else img.next-cover(src=url_for(pagination_cover) onerror=`onerror=null;src='${url_for(theme.error_img.post_page)}'`) .pagination-info diff --git a/layout/includes/post/post-copyright.pug b/layout/includes/post/post-copyright.pug index ee8c659..dfa346d 100644 --- a/layout/includes/post/post-copyright.pug +++ b/layout/includes/post/post-copyright.pug @@ -1,13 +1,17 @@ -if (theme.post_copyright && theme.post_copyright.enable && page.copyright != false) +if theme.post_copyright.enable && page.copyright !== false + - let author = page.copyright_author ? page.copyright_author : config.author + - let authorHref = page.copyright_author_href ? page.copyright_author_href : `mailto:${config.email}` + - let url = page.copyright_url ? page.copyright_url : page.permalink + - 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__author span.post-copyright-meta= _p('post.copyright.author') + ": " span.post-copyright-info - a(href=`mailto:${config.email}`) #[=config.author] + a(href=authorHref)=author .post-copyright__type span.post-copyright-meta= _p('post.copyright.link') + ": " span.post-copyright-info - a(href=url_for(page.permalink))= theme.post_copyright.decode ? decodeURI(page.permalink) : page.permalink + a(href=url_for(url))= theme.post_copyright.decode ? decodeURI(url) : url .post-copyright__notice span.post-copyright-meta= _p('post.copyright.copyright_notice') + ": " - span.post-copyright-info!= _p('post.copyright.copyright_content', theme.post_copyright.license_url, theme.post_copyright.license, config.url, config.title) + span.post-copyright-info!= info diff --git a/layout/includes/post/reward.pug b/layout/includes/post/reward.pug index 3c5ac28..1bf9381 100644 --- a/layout/includes/post/reward.pug +++ b/layout/includes/post/reward.pug @@ -1,5 +1,5 @@ .post-reward - button.reward-button + .reward-button i.fas.fa-qrcode = ' ' + _p('donate') .reward-main @@ -7,6 +7,10 @@ each item in theme.reward.QR_code - var clickTo = (item.itemlist||item).link ? (item.itemlist||item).link : (item.itemlist||item).img li.reward-item - img.post-qr-code__img(src=url_for((item.itemlist||item).img) alt=(item.itemlist||item).text onclick=`window.open('${url_for(clickTo)}')`) - .post-qr-code__desc=(item.itemlist||item).text + a(href=clickTo target='_blank') + if theme.lazyload.enable + 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 diff --git a/layout/includes/rightside.pug b/layout/includes/rightside.pug index 90e0dc0..7a7f99c 100644 --- a/layout/includes/rightside.pug +++ b/layout/includes/rightside.pug @@ -1,32 +1,32 @@ -section#rightside.rightside +section#rightside #rightside-config-hide if is_post() if theme.readmode - button#readmode(title=_p('rightside.readmode_title')) + button#readmode(type="button" title=_p('rightside.readmode_title')) i.fas.fa-book-open - button#font_plus(title=_p('rightside.font_plus_title')) + button#font_plus(type="button" title=_p('rightside.font_plus_title')) i.fas.fa-plus - button#font_minus(title=_p('rightside.font_minus_title')) + button#font_minus(type="button" title=_p('rightside.font_minus_title')) i.fas.fa-minus if theme.translate && theme.translate.enable - button#translateLink.translate_chn_to_cht(title=_p('rightside.translate_title'))= theme.translate.default + button#translateLink(type="button" title=_p('rightside.translate_title'))= theme.translate.default if theme.darkmode.enable && theme.darkmode.button - button#darkmode(title=_p('rightside.night_mode_title')) + button#darkmode(type="button" title=_p('rightside.night_mode_title')) i.fas.fa-adjust #rightside-config-show - button#rightside_config(title=_p("rightside.setting")) + button#rightside_config(type="button" title=_p("rightside.setting")) i.fas.fa-cog - if is_post() && page.comments !== false && isComment + if is_post() && page.comments !== false && theme.comments.use a#to_comment(href="#post-comment" title=_p("rightside.scroll_to_comment")) - i.scroll_to_comment.fas.fa-comments + i.fas.fa-comments if showToc - button#mobile-toc-button.close(title=_p("rightside.toc")) + button#mobile-toc-button.close(type="button" title=_p("rightside.toc")) i.fas.fa-list-ul - if theme.chat_btn && (theme.chatra.enable || theme.tidio.enable || theme.daovoice.enable || theme.gitter.enable) - button#chat_btn(title=_p("rightside.chat_btn")) + if theme.chat_btn + button#chat_btn(type="button" title=_p("rightside.chat_btn")) i.fas.fa-sms - button#go-up(title=_p("rightside.back_to_top")) + button#go-up(type="button" title=_p("rightside.back_to_top")) i.fas.fa-arrow-up diff --git a/layout/includes/search/index.pug b/layout/includes/search/index.pug deleted file mode 100644 index 19dd228..0000000 --- a/layout/includes/search/index.pug +++ /dev/null @@ -1,5 +0,0 @@ -if (theme.algolia_search.enable) - include ./algolia.pug -if (theme.local_search) - if (!theme.algolia_search.enable && theme.local_search.enable) - include ./local-search.pug \ No newline at end of file diff --git a/layout/includes/share/index.pug b/layout/includes/share/index.pug deleted file mode 100644 index 7b29796..0000000 --- a/layout/includes/share/index.pug +++ /dev/null @@ -1,7 +0,0 @@ -.post_share - if theme.addThis.enable - include ./add-this.pug - else if theme.sharejs && theme.sharejs.enable - include ./share-js.pug - else if theme.addtoany.enable - include ./addtoany.pug diff --git a/layout/includes/share/share-js.pug b/layout/includes/share/share-js.pug deleted file mode 100644 index 85f84dd..0000000 --- a/layout/includes/share/share-js.pug +++ /dev/null @@ -1,4 +0,0 @@ -if (theme.sharejs && theme.sharejs.enable) - .social-share(data-image=url_for(page.cover|| theme.avatar.img) data-sites= theme.sharejs.sites) - link(rel="stylesheet" href=url_for(theme.CDN.sharejs_css)) - script(src=url_for(theme.CDN.sharejs)) \ No newline at end of file diff --git a/layout/includes/sidebar.pug b/layout/includes/sidebar.pug index c155dab..ed56729 100644 --- a/layout/includes/sidebar.pug +++ b/layout/includes/sidebar.pug @@ -5,8 +5,8 @@ - if(showToc) - i.fas.fa-arrow-right#toggle-sidebar(class=autoOpenSidebar) #sidebar + i.fas.fa-arrow-right#toggle-sidebar(class=autoOpenSidebar) .sidebar-toc div.sidebar-toc__title= _p('sidebar.catalog') div.sidebar-toc__progress diff --git a/layout/includes/third-party/canvas-nest.pug b/layout/includes/third-party/canvas-nest.pug deleted file mode 100644 index bb790be..0000000 --- a/layout/includes/third-party/canvas-nest.pug +++ /dev/null @@ -1 +0,0 @@ -script#canvas_nest(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)) \ No newline at end of file diff --git a/layout/includes/third-party/canvas-ribbon-piao.pug b/layout/includes/third-party/canvas-ribbon-piao.pug deleted file mode 100644 index 505af83..0000000 --- a/layout/includes/third-party/canvas-ribbon-piao.pug +++ /dev/null @@ -1 +0,0 @@ -script(id="ribbon_piao" mobile=`${theme.canvas_ribbon_piao.mobile}` src=url_for(theme.CDN.canvas_ribbon_piao)) \ No newline at end of file diff --git a/layout/includes/third-party/canvas-ribbon.pug b/layout/includes/third-party/canvas-ribbon.pug deleted file mode 100644 index 9fc03fc..0000000 --- a/layout/includes/third-party/canvas-ribbon.pug +++ /dev/null @@ -1,3 +0,0 @@ -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}`) - diff --git a/layout/includes/chat/chatra.pug b/layout/includes/third-party/chat/chatra.pug similarity index 86% rename from layout/includes/chat/chatra.pug rename to layout/includes/third-party/chat/chatra.pug index 0566392..b6c1201 100644 --- a/layout/includes/chat/chatra.pug +++ b/layout/includes/third-party/chat/chatra.pug @@ -12,10 +12,13 @@ script. })(document, window, 'Chatra'); if (!{theme.chat_btn}) { - var chatBtn = document.getElementById("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 () { diff --git a/layout/includes/third-party/chat/crisp.pug b/layout/includes/third-party/chat/crisp.pug new file mode 100644 index 0000000..cc57e8d --- /dev/null +++ b/layout/includes/third-party/chat/crisp.pug @@ -0,0 +1,36 @@ +script. + window.$crisp = []; + window.CRISP_WEBSITE_ID = "!{theme.crisp.website_id}"; + (function () { + d = document; + s = d.createElement("script"); + s.src = "https://client.crisp.chat/l.js"; + s.async = 1; + d.getElementsByTagName("head")[0].appendChild(s); + })(); + $crisp.push(["safe", true]) + + if (!{theme.chat_btn}) { + $crisp.push(["do", "chat:hide"]) + $crisp.push(["on", "chat:closed", function() { + $crisp.push(["do", "chat:hide"]) + }]) + var chatBtnFn = () => { + var chatBtn = document.getElementById("chat_btn") + chatBtn.addEventListener("click", function(){ + $crisp.push(["do", "chat:show"]) + $crisp.push(["do", "chat:open"]) + + }); + } + chatBtnFn() + } else { + if (!{theme.chat_hide_show}) { + function chatBtnHide () { + $crisp.push(["do", "chat:hide"]) + } + function chatBtnShow () { + $crisp.push(["do", "chat:show"]) + } + } + } \ No newline at end of file diff --git a/layout/includes/chat/daovoice.pug b/layout/includes/third-party/chat/daovoice.pug similarity index 85% rename from layout/includes/chat/daovoice.pug rename to layout/includes/third-party/chat/daovoice.pug index dd0e047..3c6b064 100644 --- a/layout/includes/chat/daovoice.pug +++ b/layout/includes/third-party/chat/daovoice.pug @@ -13,10 +13,13 @@ script. daovoice('update'); if (isChatBtn) { - var chatBtn = document.getElementById("chat_btn") - chatBtn.addEventListener("click", function(){ - daovoice('show') - }); + var chatBtnFn = () => { + var chatBtn = document.getElementById("chat_btn") + chatBtn.addEventListener("click", function(){ + daovoice('show') + }); + } + chatBtnFn() } else { if (!{theme.chat_hide_show}) { function chatBtnHide () { diff --git a/layout/includes/third-party/chat/gitter.pug b/layout/includes/third-party/chat/gitter.pug new file mode 100644 index 0000000..05c5bc4 --- /dev/null +++ b/layout/includes/third-party/chat/gitter.pug @@ -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) diff --git a/layout/includes/chat/index.pug b/layout/includes/third-party/chat/index.pug similarity index 73% rename from layout/includes/chat/index.pug rename to layout/includes/third-party/chat/index.pug index 48b8585..db78a34 100644 --- a/layout/includes/chat/index.pug +++ b/layout/includes/third-party/chat/index.pug @@ -5,4 +5,6 @@ else if theme.tidio && theme.tidio.enable else if theme.daovoice && theme.daovoice.enable include ./daovoice.pug else if theme.gitter && theme.gitter.enable - include ./gitter.pug \ No newline at end of file + include ./gitter.pug +else if theme.crisp && theme.crisp.enable + include ./crisp.pug \ No newline at end of file diff --git a/layout/includes/third-party/chat/tidio.pug b/layout/includes/third-party/chat/tidio.pug new file mode 100644 index 0000000..6b0097f --- /dev/null +++ b/layout/includes/third-party/chat/tidio.pug @@ -0,0 +1,41 @@ +script(src=`//code.tidio.co/${theme.tidio.public_key}.js` async) + +if theme.chat_btn + script. + function onTidioChatApiReady() { + window.tidioChatApi.hide(); + window.tidioChatApi.on("close", function() { + window.tidioChatApi.hide(); + }); + } + if (window.tidioChatApi) { + window.tidioChatApi.on("ready", onTidioChatApiReady); + } else { + document.addEventListener("tidioChat-ready", onTidioChatApiReady); + } + + var chatBtnFn = () => { + document.getElementById("chat_btn").addEventListener("click", function(){ + window.tidioChatApi.show(); + window.tidioChatApi.open(); + }); + } + chatBtnFn() + +else if theme.chat_hide_show + script. + function chatBtnHide () { + if (window.tidioChatApi) { + //- 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' + } + } + + diff --git a/layout/includes/third-party/comments/disqus.pug b/layout/includes/third-party/comments/disqus.pug new file mode 100644 index 0000000..dcbe896 --- /dev/null +++ b/layout/includes/third-party/comments/disqus.pug @@ -0,0 +1,45 @@ +script. + function loadDisqus () { + var disqus_config = function () { + this.page.url = '!{ page.permalink }' + this.page.identifier = '!{ page.path }' + this.page.title = '!{ page.title }' + }; + + window.disqusReset = () => { + DISQUS.reset({ + reload: true, + config: disqus_config + }) + } + + if (window.DISQUS) disqusReset() + else { + (function() { + var d = document, s = d.createElement('script'); + s.src = 'https://!{theme.disqus.shortname}.disqus.com/embed.js'; + s.setAttribute('data-timestamp', +new Date()); + (d.head || d.body).appendChild(s); + })(); + } + } + + if ('!{theme.comments.use[0]}' === 'Disqus' || !!{theme.comments.lazyload}) { + if (!{theme.comments.lazyload}) loadComment(document.getElementById('disqus_thread'), loadDisqus) + else loadDisqus() + } else { + 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}); + } diff --git a/layout/includes/third-party/comments/disqusjs.pug b/layout/includes/third-party/comments/disqusjs.pug new file mode 100644 index 0000000..76d7b85 --- /dev/null +++ b/layout/includes/third-party/comments/disqusjs.pug @@ -0,0 +1,57 @@ +script. + function loadDisqusjs () { + function addDisqusjsCSS () { + const ele = document.createElement('link') + ele.rel = 'stylesheet' + ele.href= '!{url_for(theme.CDN.disqusjs_css)}' + 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 }', + title: '!{ page.title }', + api: '!{theme.disqusjs.api}', + apikey: '!{theme.disqusjs.apikey}', + nocomment: '!{theme.disqusjs.nocomment}', + admin: '!{theme.disqusjs.admin}', + adminLabel: '!{theme.disqusjs.adminLabel}' + }); + } + + window.disqusReset = initDisqusjs + + if (window.disqusJsLoad) initDisqusjs() + else { + addDisqusjsCSS() + $.getScript('!{url_for(theme.CDN.disqusjs)}', initDisqusjs) + window.disqusJsLoad = true + } + } + + if ('!{theme.comments.use[0]}' === 'Disqusjs' || !!{theme.comments.lazyload}) { + if (!{theme.comments.lazyload}) loadComment(document.getElementById('disqus_thread'), loadDisqusjs) + else loadDisqusjs() + } + else { + function loadOtherComment () { + loadDisqusjs() + } + } + + +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 { + DISQUSWIDGETS.getCount({reset: true}); + } + diff --git a/layout/includes/third-party/comments/facebook_comments.pug b/layout/includes/third-party/comments/facebook_comments.pug new file mode 100644 index 0000000..65a1fbd --- /dev/null +++ b/layout/includes/third-party/comments/facebook_comments.pug @@ -0,0 +1,26 @@ +#fb-root +script. + function loadFBComment () { + var themeNow = document.documentElement.getAttribute('data-theme') === 'dark' ? 'dark' : 'light' + document.getElementsByClassName('fb-comments')[0].setAttribute('data-colorscheme',themeNow) + + if (typeof FB === 'object') FB.XFBML.parse() + else { + let ele = document.createElement('script') + ele.setAttribute('src','https://connect.facebook.net/!{theme.facebook_comments.lang}/sdk.js#xfbml=1&version=v7.0') + ele.setAttribute('async', 'true') + ele.setAttribute('defer', 'true') + ele.setAttribute('crossorigin', 'anonymous') + document.getElementById('fb-root').insertAdjacentElement('afterbegin',ele) + } + } + + if ('!{theme.comments.use[0]}' === 'Facebook Comments' || !!{theme.comments.lazyload}) { + if (!{theme.comments.lazyload}) loadComment(document.querySelector('#post-comment .fb-comments'), loadFBComment) + else loadFBComment() + } else { + function loadOtherComment () { + loadFBComment() + } + } + diff --git a/layout/includes/third-party/comments/gitalk.pug b/layout/includes/third-party/comments/gitalk.pug new file mode 100644 index 0000000..834b42a --- /dev/null +++ b/layout/includes/third-party/comments/gitalk.pug @@ -0,0 +1,52 @@ +script. + function addGitalkSource () { + const ele = document.createElement('link') + ele.rel = 'stylesheet' + ele.href= '!{url_for(theme.CDN.gitalk_css)}' + document.getElementsByTagName('head')[0].appendChild(ele) + } + + 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') + } + + if (typeof Gitalk === 'function') initGitalk() + else { + addGitalkSource() + $.getScript('!{url_for(theme.CDN.gitalk)}', initGitalk) + } + } + + function commentCount(n){ + let isCommentCount = document.querySelector('#post-meta .gitalk-comment-count') + if (isCommentCount) { + isCommentCount.innerHTML= n + } + } + + if ('!{theme.comments.use[0]}' === 'Gitalk' || !!{theme.comments.lazyload}) { + if (!{theme.comments.lazyload}) loadComment(document.getElementById('gitalk-container'), loadGitalk) + else loadGitalk() + } else { + function loadOtherComment () { + loadGitalk() + } + } + + + diff --git a/layout/includes/third-party/comments/index.pug b/layout/includes/third-party/comments/index.pug new file mode 100644 index 0000000..b8ae62f --- /dev/null +++ b/layout/includes/third-party/comments/index.pug @@ -0,0 +1,38 @@ +- let defaultComment = theme.comments.use[0] +hr +#post-comment + .comment-head + .comment-headline + i.fas.fa-comments.fa-fw + span= ' ' + _p('comment') + + if theme.comments.use.length > 1 + .comment-switch + span.first-comment=defaultComment + label + input#switch-comments-btn(type="checkbox") + span.slider + span.second-comment=theme.comments.use[1] + + + .comment-wrap + each name in theme.comments.use + div + case name + when 'Disqus' + #disqus_thread + when 'Valine' + #vcomment.vcomment + when 'Disqusjs' + #disqus_thread + when 'Livere' + #lv-container(data-id="city" data-uid=theme.livere.uid) + when 'Gitalk' + #gitalk-container + when 'Utterances' + #utterances-wrap + when 'Facebook Comments' + .fb-comments(data-colorscheme = theme.display_mode === 'dark' ? 'dark' : 'light' + data-numposts= theme.facebook_comments.pageSize || 10 + data-order-by= theme.facebook_comments.order_by || 'social' + data-width="100%") diff --git a/layout/includes/third-party/comments/js.pug b/layout/includes/third-party/comments/js.pug new file mode 100644 index 0000000..23f9d71 --- /dev/null +++ b/layout/includes/third-party/comments/js.pug @@ -0,0 +1,16 @@ +each name in theme.comments.use + case name + when 'Valine' + !=partial('includes/third-party/comments/valine', {}, {cache:theme.fragment_cache}) + when 'Disqus' + include ./disqus.pug + when 'Disqusjs' + include ./disqusjs.pug + when 'Livere' + !=partial('includes/third-party/comments/livere', {}, {cache:theme.fragment_cache}) + when 'Gitalk' + include ./gitalk.pug + when 'Utterances' + !=partial('includes/third-party/comments/utterances', {}, {cache:theme.fragment_cache}) + when 'Facebook Comments' + !=partial('includes/third-party/comments/facebook_comments', {}, {cache:theme.fragment_cache}) diff --git a/layout/includes/comments/livere.pug b/layout/includes/third-party/comments/livere.pug similarity index 50% rename from layout/includes/comments/livere.pug rename to layout/includes/third-party/comments/livere.pug index f530901..faaa60e 100644 --- a/layout/includes/comments/livere.pug +++ b/layout/includes/third-party/comments/livere.pug @@ -1,5 +1,5 @@ -#lv-container(data-id="city" data-uid=theme.livere.uid) - script. +script. + function loadLivere () { (function(d, s) { var j, e = d.getElementsByTagName(s)[0]; if (typeof LivereTower === 'function') { return; } @@ -8,3 +8,14 @@ j.async = true; e.parentNode.insertBefore(j, e); })(document, 'script'); + } + + if ('!{theme.comments.use[0]}' === 'Livere' || !!{theme.comments.lazyload}) { + if (!{theme.comments.lazyload}) loadComment(document.getElementById('lv-container'), loadLivere) + else loadLivere() + } + else { + function loadOtherComment () { + loadLivere() + } + } \ No newline at end of file diff --git a/layout/includes/third-party/comments/utterances.pug b/layout/includes/third-party/comments/utterances.pug new file mode 100644 index 0000000..7911a3e --- /dev/null +++ b/layout/includes/third-party/comments/utterances.pug @@ -0,0 +1,34 @@ +script. + function loadUtterances () { + let ele = document.createElement('script') + ele.setAttribute('id', 'utterances_comment') + ele.setAttribute('src', '!{url_for(theme.CDN.utterances)}') + ele.setAttribute('repo', '!{theme.utterances.repo}') + ele.setAttribute('issue-term', '!{theme.utterances.issue_term}') + let nowTheme = document.documentElement.getAttribute('data-theme') === 'dark' ? '#{theme.utterances.dark_theme}' : '#{theme.utterances.light_theme}' + ele.setAttribute('theme', nowTheme) + ele.setAttribute('crossorigin', 'anonymous') + ele.setAttribute('async', 'true') + document.getElementById('utterances-wrap').insertAdjacentElement('afterbegin',ele) + } + + function utterancesTheme () { + if (document.querySelector('.utterances-frame')) { + const theme = document.documentElement.getAttribute('data-theme') === 'dark' ? '#{theme.utterances.dark_theme}' : '#{theme.utterances.light_theme}' + const message = { + type: 'set-theme', + theme: theme + }; + const iframe = document.querySelector('.utterances-frame'); + iframe.contentWindow.postMessage(message, 'https://utteranc.es'); + } + } + + if ('!{theme.comments.use[0]}' === 'Utterances' || !!{theme.comments.lazyload}) { + if (!{theme.comments.lazyload}) loadComment(document.getElementById('utterances-wrap'), loadUtterances) + else loadUtterances() + } else { + function loadOtherComment () { + loadUtterances() + } + } diff --git a/layout/includes/third-party/comments/valine.pug b/layout/includes/third-party/comments/valine.pug new file mode 100644 index 0000000..a547529 --- /dev/null +++ b/layout/includes/third-party/comments/valine.pug @@ -0,0 +1,40 @@ +- let emojiMaps = '""' +if site.data.valine + - emojiMaps = JSON.stringify(site.data.valine) + +script. + function loadValine () { + function initValine () { + window.valine = new Valine({ + el: '#vcomment', + appId: '#{theme.valine.appId}', + appKey: '#{theme.valine.appKey}', + placeholder: '#{theme.valine.placeholder}', + 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}, + enableQQ: #{theme.valine.enableQQ}, + path: window.location.pathname, + }); + if ('#{theme.valine.requiredFields}') { valine.config.requiredFields= '#{theme.valine.requiredFields}'.split(',') } + } + + if (typeof Valine === 'function') initValine() + else $.getScript('!{url_for(theme.CDN.valine)}', initValine) + } + + if ('!{theme.comments.use[0]}' === 'Valine' || !!{theme.comments.lazyload}) { + if (!{theme.comments.lazyload}) loadComment(document.querySelector('#vcomment'),loadValine) + else setTimeout(() => loadValine(), 0) + } else { + function loadOtherComment () { + loadValine() + } + } + + diff --git a/layout/includes/third-party/effect.pug b/layout/includes/third-party/effect.pug new file mode 100644 index 0000000..335a70c --- /dev/null +++ b/layout/includes/third-party/effect.pug @@ -0,0 +1,28 @@ +if theme.fireworks && theme.fireworks.enable + canvas.fireworks + script(src=url_for(theme.CDN.anime)) + script(src=url_for(theme.CDN.fireworks)) + +if (theme.canvas_ribbon && theme.canvas_ribbon.enable) + 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}`) + +if (theme.canvas_ribbon_piao && theme.canvas_ribbon_piao.enable) + 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) + 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 + script(src=url_for(theme.CDN.activate_power_mode)) + script. + POWERMODE.colorful = #{theme.activate_power_mode.colorful}; + POWERMODE.shake = #{theme.activate_power_mode.shake}; + document.body.addEventListener('input', POWERMODE); + +//- 鼠標特效 +if theme.click_heart + script(src=url_for(theme.CDN.click_heart) async) + +if theme.ClickShowText && theme.ClickShowText.enable + script(src=url_for(theme.CDN.ClickShowText) async) diff --git a/layout/includes/math/index.pug b/layout/includes/third-party/math/index.pug similarity index 89% rename from layout/includes/math/index.pug rename to layout/includes/third-party/math/index.pug index 68b3416..4ce6692 100644 --- a/layout/includes/math/index.pug +++ b/layout/includes/third-party/math/index.pug @@ -13,3 +13,6 @@ if theme.katex && theme.katex.enable else if page.katex include ./katex.pug + +if theme.mermaid.enable + include ./mermaid.pug \ No newline at end of file diff --git a/layout/includes/math/katex.pug b/layout/includes/third-party/math/katex.pug similarity index 100% rename from layout/includes/math/katex.pug rename to layout/includes/third-party/math/katex.pug diff --git a/layout/includes/third-party/math/mathjax.pug b/layout/includes/third-party/math/mathjax.pug new file mode 100644 index 0000000..b2b0747 --- /dev/null +++ b/layout/includes/third-party/math/mathjax.pug @@ -0,0 +1,45 @@ +//- 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. + if (!window.MathJax) { + window.MathJax = { + loader: { + source: { + '[tex]/amsCd': '[tex]/amscd' + } + }, + tex: { + inlineMath: [ ['$','$'], ["\\(","\\)"]], + tags: 'ams' + }, + options: { + renderActions: { + findScript: [10, doc => { + for (const node of document.querySelectorAll('script[type^="math/tex"]')) { + const display = !!node.type.match(/; *mode=display/) + const math = new doc.options.MathItem(node.textContent, doc.inputJax[0], display) + const text = document.createTextNode('') + node.parentNode.replaceChild(text, node) + math.start = {node: text, delim: '', n: 0} + math.end = {node: text, delim: '', n: 0} + doc.math.push(math) + } + }, ''] + } + } + } + + var script = document.createElement('script') + script.src = '!{theme.CDN.mathjax}' + script.id = 'MathJax-script' + script.async = true + document.head.appendChild(script) + } else { + MathJax.startup.document.state(0) + MathJax.texReset() + MathJax.typeset() + } \ No newline at end of file diff --git a/layout/includes/third-party/math/mermaid.pug b/layout/includes/third-party/math/mermaid.pug new file mode 100644 index 0000000..0d46012 --- /dev/null +++ b/layout/includes/third-party/math/mermaid.pug @@ -0,0 +1,15 @@ +script. + if (document.getElementsByClassName('mermaid').length) { + if (window.mermaidJsLoad) mermaid.init() + else { + $.getScript('!{theme.CDN.mermaid}', function () { + window.mermaidJsLoad = true + mermaid.initialize({ + theme: '!{theme.mermaid.theme}', + }) + !{theme.pjax} && mermaid.init() + }) + } + } + + diff --git a/layout/includes/third-party/pangu.pug b/layout/includes/third-party/pangu.pug index 8477369..229c69b 100644 --- a/layout/includes/third-party/pangu.pug +++ b/layout/includes/third-party/pangu.pug @@ -1,12 +1,19 @@ -script(src=url_for(theme.CDN.pangu)) -if theme.pangu.field === 'post' && is_post() - script. - document.addEventListener('DOMContentLoaded', function() { - pangu.autoSpacingPage() - }) -else if theme.pangu.field === 'site' - script. - document.addEventListener('DOMContentLoaded', function() { - pangu.autoSpacingPage() - }) +script. + function panguFn () { + if (typeof pangu === 'object') pangu.spacingElementById('content-inner') + else { + $.getScript('!{url_for(theme.CDN.pangu)}', () => { + pangu.spacingElementById('content-inner') + }) + } + } + function panguInit () { + if (!{theme.pangu.field === 'post'}){ + GLOBAL_CONFIG_SITE.isPost && panguFn() + } else { + panguFn() + } + } + + document.addEventListener('DOMContentLoaded', panguFn) diff --git a/layout/includes/third-party/pjax.pug b/layout/includes/third-party/pjax.pug new file mode 100644 index 0000000..b15b058 --- /dev/null +++ b/layout/includes/third-party/pjax.pug @@ -0,0 +1,56 @@ +script(src=url_for(theme.CDN.pjax)) +script. + var pjax = new Pjax({ + elements: 'a:not([target="_blank"])', + selectors: [ + 'title', + 'meta[name=description]', + '#config_change', + '#body-wrap', + '#rightside-config-hide', + '#rightside-config-show', + '.js-pjax' + ], + cacheBust: false, + }) + + document.addEventListener('pjax:complete', function () { + refreshFn() + + $('script[data-pjax]').each(function () { + $(this).parent().append($(this).remove()) + }) + + GLOBAL_CONFIG.islazyload && lazyLoadInstance.update() + + typeof chatBtnFn === 'function' && chatBtnFn() + typeof panguInit === 'function' && panguInit() + + if (typeof gtag === 'function') { + gtag('config', '!{theme.google_analytics}', {'page_path': window.location.pathname}); + } + + typeof loadMeting === 'function' && document.getElementsByClassName('aplayer').length && loadMeting() + + }) + + document.addEventListener('pjax:send', function () { + if (window.aplayers) { + for (let i = 0; i < window.aplayers.length; i++) { + if (!window.aplayers[i].options.fixed) { + window.aplayers[i].destroy() + } + } + } + + typeof typed === 'object' && typed.destroy() + + $(window).off('scroll') + + //reset readmode + $('body').hasClass('read-mode') && $('body').removeClass('read-mode') + + //reset font-size + $('body').css('font-size') !== originFontSize && $('body').css('font-size', parseFloat(originFontSize)) + }) + diff --git a/layout/includes/search/algolia.pug b/layout/includes/third-party/search/algolia.pug similarity index 95% rename from layout/includes/search/algolia.pug rename to layout/includes/third-party/search/algolia.pug index 7041dc1..15cbb9d 100644 --- a/layout/includes/search/algolia.pug +++ b/layout/includes/third-party/search/algolia.pug @@ -9,4 +9,4 @@ #algolia-stats span.search-close-button i.fas.fa-times -.search-mask +#search-mask diff --git a/layout/includes/third-party/search/index.pug b/layout/includes/third-party/search/index.pug new file mode 100644 index 0000000..c1bd03a --- /dev/null +++ b/layout/includes/third-party/search/index.pug @@ -0,0 +1,4 @@ +if theme.algolia_search.enable + include ./algolia.pug +else if theme.local_search.enable + include ./local-search.pug \ No newline at end of file diff --git a/layout/includes/search/local-search.pug b/layout/includes/third-party/search/local-search.pug similarity index 98% rename from layout/includes/search/local-search.pug rename to layout/includes/third-party/search/local-search.pug index 74ca4c7..545d775 100644 --- a/layout/includes/search/local-search.pug +++ b/layout/includes/third-party/search/local-search.pug @@ -20,4 +20,4 @@ | #[a(href="https://github.com/wzpan/hexo-generator-search" style={'color': '#49B1F5'}) hexo-generator-search] span.search-close-button i.fas.fa-times -.search-mask \ No newline at end of file +#search-mask \ No newline at end of file diff --git a/layout/includes/share/add-this.pug b/layout/includes/third-party/share/add-this.pug similarity index 100% rename from layout/includes/share/add-this.pug rename to layout/includes/third-party/share/add-this.pug diff --git a/layout/includes/share/addtoany.pug b/layout/includes/third-party/share/addtoany.pug similarity index 100% rename from layout/includes/share/addtoany.pug rename to layout/includes/third-party/share/addtoany.pug diff --git a/layout/includes/third-party/share/index.pug b/layout/includes/third-party/share/index.pug new file mode 100644 index 0000000..41892a6 --- /dev/null +++ b/layout/includes/third-party/share/index.pug @@ -0,0 +1,7 @@ +.post_share + if theme.addThis.enable + !=partial('includes/third-party/share/add-this', {}, {cache:theme.fragment_cache}) + else if theme.sharejs.enable + include ./share-js.pug + else if theme.addtoany.enable + !=partial('includes/third-party/share/addtoany', {}, {cache:theme.fragment_cache}) diff --git a/layout/includes/third-party/share/share-js.pug b/layout/includes/third-party/share/share-js.pug new file mode 100644 index 0000000..538c905 --- /dev/null +++ b/layout/includes/third-party/share/share-js.pug @@ -0,0 +1,3 @@ +.social-share(data-image=url_for(page.cover|| theme.avatar.img) data-sites= theme.sharejs.sites) +link(rel="stylesheet" href=url_for(theme.CDN.sharejs_css)) +script(src=url_for(theme.CDN.sharejs) defer) \ No newline at end of file diff --git a/layout/includes/third-party/subtitle.pug b/layout/includes/third-party/subtitle.pug new file mode 100644 index 0000000..05b95fc --- /dev/null +++ b/layout/includes/third-party/subtitle.pug @@ -0,0 +1,137 @@ +- var source = theme.subtitle.source +if source == '1' + script. + function subtitleType () { + $.getJSON('https://api.btstu.cn/yan/api.php?charset=utf-8&encode=json',function (data) { + if (!{theme.subtitle.effect}) { + var sub = "!{theme.subtitle.sub}".length == 0 ? new Array() : "!{theme.subtitle.sub}".split(',') + var both = sub.unshift(data.text) + typed = new Typed('#subtitle', { + strings: sub, + startDelay: 300, + typeSpeed: 150, + loop: !{theme.subtitle.loop}, + backSpeed: 50, + }) + } else { + document.getElementById('subtitle').innerHTML = data.text + } + }) + } + + if (!{theme.subtitle.effect}) { + if (typeof Typed === 'function') subtitleType() + else $.getScript('!{url_for(theme.CDN.typed)}', subtitleType) + } else { + subtitleType() + } + +else if source == '2' + script. + function subtitleType () { + $.getJSON('https://v1.hitokoto.cn', function (data) { + if (!{theme.subtitle.effect}) { + var from = '出自 ' + data.from + var sub = "!{theme.subtitle.sub}".length == 0 ? new Array() : "!{theme.subtitle.sub}".split(',') + var both = sub.unshift(data.hitokoto, from) + var typed = new Typed('#subtitle', { + strings: sub, + startDelay: 300, + typeSpeed: 150, + loop: !{theme.subtitle.loop}, + backSpeed: 50, + }) + } else { + document.getElementById('subtitle').innerHTML = data.hitokoto + } + }) + } + + if (!{theme.subtitle.effect}) { + if (typeof Typed === 'function') subtitleType() + else $.getScript('!{url_for(theme.CDN.typed)}', subtitleType) + } else { + subtitleType() + } + +else if source == '3' + script. + function subtitleType () { + $.getScript('http://yijuzhan.com/api/word.php?m=js', function () { + var con = str[0] + if (!{theme.subtitle.effect}) { + var from = '出自 ' + str[1] + var sub = "!{theme.subtitle.sub}".length == 0 ? new Array() : "!{theme.subtitle.sub}".split(',') + var both = sub.unshift(con, from) + var typed = new Typed('#subtitle', { + strings: sub, + startDelay: 300, + typeSpeed: 150, + loop: !{theme.subtitle.loop}, + backSpeed: 50, + }) + } else { + document.getElementById('subtitle').innerHTML = con + } + }) + } + + if (!{theme.subtitle.effect}) { + if (typeof Typed === 'function') subtitleType() + else $.getScript('!{url_for(theme.CDN.typed)}', subtitleType) + } else { + subtitleType() + } + +else if source == '4' + script. + function subtitleType () { + $.getScript('https://sdk.jinrishici.com/v2/browser/jinrishici.js',function () { + jinrishici.load(function (result) { + if (!{theme.subtitle.effect}) { + var sub = "!{theme.subtitle.sub}".length == 0 ? new Array() : "!{theme.subtitle.sub}".split(',') + var content = result.data.content + var both = sub.unshift(content) + var typed = new Typed('#subtitle', { + strings: sub, + startDelay: 300, + typeSpeed: 150, + loop: !{theme.subtitle.loop}, + backSpeed: 50, + }) + } else { + document.getElementById('subtitle').innerHTML = result.data.content + } + }) + }) + } + + if (!{theme.subtitle.effect}) { + if (typeof Typed === 'function') subtitleType() + else $.getScript('!{url_for(theme.CDN.typed)}', subtitleType) + } else { + subtitleType() + } + +else + script. + function subtitleType () { + if (!{theme.subtitle.effect}) { + var typed = new Typed("#subtitle", { + strings: "!{theme.subtitle.sub}".split(","), + startDelay: 300, + typeSpeed: 150, + loop: !{theme.subtitle.loop}, + backSpeed: 50 + }) + } else { + document.getElementById("subtitle").innerHTML = '!{theme.subtitle.sub[0]}' + } + } + + if (!{theme.subtitle.effect}) { + if (typeof Typed === 'function') subtitleType() + else $.getScript('!{url_for(theme.CDN.typed)}', subtitleType) + } else { + subtitleType() + } \ No newline at end of file diff --git a/layout/includes/widget/card_author.pug b/layout/includes/widget/card_author.pug index 95fea9d..57b69c3 100644 --- a/layout/includes/widget/card_author.pug +++ b/layout/includes/widget/card_author.pug @@ -1,7 +1,10 @@ .card-widget.card-info .card-content .card-info-avatar.is-center - img.avatar-img(src=url_for(theme.avatar.img) onerror=`this.onerror=null;this.src='` + url_for(theme.error_img.flink) + `'` alt="avatar") + if theme.lazyload.enable + img.avatar-img(data-lazy-src=url_for(theme.avatar.img) onerror=`this.onerror=null;this.src='` + url_for(theme.error_img.flink) + `'` alt="avatar") + else + img.avatar-img(src=url_for(theme.avatar.img) onerror=`this.onerror=null;this.src='` + url_for(theme.error_img.flink) + `'` alt="avatar") .author-info__name= config.author .author-info__description!= theme.aside.card_author.description || config.description @@ -19,15 +22,14 @@ .length_num= site.tags.length if site.categories.length - .card-info-data-item.is-center + .card-info-data-item.is-center a(href=url_for(config.category_dir)) .headline= _p('aside.categories') .length_num= site.categories.length - .card-info-bookmark.is-center - button#bookmark-it.button--animated(title= _p('aside.card_bookmark')) - i.fas.fa-bookmark - span= _p('aside.card_bookmark') || 'Follow Me' + a#card-info-btn.button--animated(href=theme.aside.card_author.button.link) + i(class=theme.aside.card_author.button.icon) + span=theme.aside.card_author.button.text if(theme.social) .card-info-social-icons.is-center diff --git a/layout/includes/widget/card_recent_post.pug b/layout/includes/widget/card_recent_post.pug index 5995c45..1b5e9ba 100644 --- a/layout/includes/widget/card_recent_post.pug +++ b/layout/includes/widget/card_recent_post.pug @@ -4,23 +4,24 @@ i.fas.fa-history span= _p('aside.card_recent_post') .aside-recent-item - - var postLimit = theme.aside.card_recent_post.limit === 0 ? site.posts.length : theme.aside.card_recent_post.limit || 5 - - site.posts.sort('date', -1).limit(postLimit).each(function(article){ + - let postLimit = theme.aside.card_recent_post.limit === 0 ? site.posts.length : theme.aside.card_recent_post.limit || 5 + - let sort = theme.aside.card_recent_post.sort === 'updated' ? 'updated' : 'date' + - site.posts.sort(sort, -1).limit(postLimit).each(function(article){ .aside-recent-post - - var link = article.link || article.path - - var title = article.title || _p('no_title') - - var no_cover = article.cover === false || !theme.cover.aside_enable ? 'no-aside-cover' : '' - - var post_cover = article.cover - - a(href=url_for(link)) - if post_cover && theme.cover.aside_enable - .aside-post-cover - if theme.lazyload.enable - img.aside-post-bg(data-src=url_for(post_cover) onerror=`this.onerror=null;this.src='`+ url_for(theme.error_img.post_page) + `'` title=title alt=title) - else - img.aside-post-bg(src=url_for(post_cover) onerror=`this.onerror=null;this.src='`+ url_for(theme.error_img.post_page) + `'` title=title alt=title) - .aside-post-title(class=no_cover) - .aside-post_title(href=url_for(link) title=article.title || _p('no_title'))= article.title || _p('no_title') - time.aside-post_meta.post-meta__date(title=_p('post.created') + ' ' + full_date(article.date)) #[=date(article.date, config.date_format)] - + - let link = article.link || article.path + - let title = article.title || _p('no_title') + - let no_cover = article.cover === false || !theme.cover.aside_enable ? 'no-aside-cover' : '' + - let post_cover = article.cover + if post_cover && theme.cover.aside_enable + a.aside-post-cover(href=url_for(link) title=title) + if theme.lazyload.enable + img.aside-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 + img.aside-post-bg(src=url_for(post_cover) onerror=`this.onerror=null;this.src='${url_for(theme.error_img.post_page)}'` alt=title) + .aside-post-info(class=no_cover) + a.aside-post-title(href=url_for(link) title=title)= title + if theme.aside.card_recent_post.sort === 'updated' + time.aside-post_meta.post-meta-updated(datetime=date_xml(article.updated) title=_p('post.updated') + ' ' + full_date(article.updated)) #[=date(article.updated, config.date_format)] + else + time.aside-post_meta.post-meta-date(datetime=date_xml(article.date) title=_p('post.created') + ' ' + full_date(article.date)) #[=date(article.date, config.date_format)] - }) diff --git a/layout/page.pug b/layout/page.pug index ff3aa6f..099db09 100644 --- a/layout/page.pug +++ b/layout/page.pug @@ -8,8 +8,9 @@ block content span.tag-cloud__amount= site.tags.length .tag-cloud-tags !=cloudTags({source: site.tags, minfontsize: 15, maxfontsize: 30, limit: 0}) - if page.comments !== false - include includes/comments/index.pug + if page.comments !== false && theme.comments && theme.comments.use + - var commentsJsLoad = true + !=partial('includes/third-party/comments/index', {}, {cache:theme.fragment_cache}) else if page.type === 'link' include flink.pug else if page.type === 'categories' @@ -19,10 +20,15 @@ block content | - span.category__amount= site.categories.length div!= list_categories() - if page.comments !== false - include includes/comments/index.pug + if page.comments !== false && theme.comments && theme.comments.use + - var commentsJsLoad = true + !=partial('includes/third-party/comments/index', {}, {cache:theme.fragment_cache}) else #page + if theme.douban && theme.douban.meta + if (is_current('/movies/', [strict]) || is_current('/books/', [strict]) || is_current('/games/', [strict])) + meta(name="referrer" content="no-referrer") #article-container!= page.content - if page.comments !== false - include includes/comments/index.pug \ No newline at end of file + if page.comments !== false && theme.comments && theme.comments.use + - var commentsJsLoad = true + !=partial('includes/third-party/comments/index', {}, {cache:theme.fragment_cache}) \ No newline at end of file diff --git a/layout/post.pug b/layout/post.pug index 56b1859..aef16e0 100644 --- a/layout/post.pug +++ b/layout/post.pug @@ -9,7 +9,7 @@ block content .post-meta__tag-list each item, index in page.tags.data a(href=url_for(item.path)).post-meta__tags #[=item.name] - !=partial('includes/share/index', {}, {cache:theme.fragment_cache}) + include includes/third-party/share/index.pug if theme.reward.enable !=partial('includes/post/reward', {}, {cache:theme.fragment_cache}) @@ -21,5 +21,8 @@ block content include includes/pagination.pug if theme.related_post && theme.related_post.enable != related_posts(page,site.posts) - if page.comments !== false - include includes/comments/index.pug \ No newline at end of file + + if page.comments !== false && theme.comments && theme.comments.use + - var commentsJsLoad = true + !=partial('includes/third-party/comments/index', {}, {cache:theme.fragment_cache}) + \ No newline at end of file diff --git a/package.json b/package.json index 641ee07..baa77f4 100644 --- a/package.json +++ b/package.json @@ -1,18 +1,32 @@ { "name": "hexo-theme-butterfly", - "version": "3.0.0-rc-1", - "private": true, - "engines": { - "node": ">=8.10.0" - }, + "version": "3.0.0-rc2", "description": "A Simple and Card UI Design theme for Hexo", + "main": "package.json", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, "keywords": [ "hexo", "theme", "butterfly", - "Card UI Design" + "Card UI Design", + "Jerry", + "hexo-theme-butterfly" ], - "repository": "https://github.com/jerryc127/hexo-theme-butterfly.git", + "repository": { + "type" : "git", + "url" : "https://github.com/jerryc127/hexo-theme-butterfly.git" + }, + "bugs": { + "url": "https://github.com/jerryc127/hexo-theme-butterfly/issues", + "email": "wong@jerryc.me" + }, + "dependencies": { + "hexo-renderer-marked": "^3.0.0", + "hexo-renderer-pug": "^1.0.0" + }, + "homepage": "https://demo.jerryc.me/", "author": "Jerry ", - "license": "MIT" -} \ No newline at end of file + "license": "Apache-2.0" +} diff --git a/scripts/filters/post_lazyload.js b/scripts/filters/post_lazyload.js index 3ae664c..b5cb3b1 100644 --- a/scripts/filters/post_lazyload.js +++ b/scripts/filters/post_lazyload.js @@ -1,23 +1,15 @@ /** * Butterfly * lazyload - * replace src to data-src + * replace src to data-lazy-src */ -//
'use strict' const urlFor = require('hexo-util').url_for.bind(hexo) -function lazyProcess (htmlContent) { - var bg = hexo.theme.config.lazyload.post ? urlFor(hexo.theme.config.lazyload.post) : 'data:image/gif;base64,R0lGODdhAQABAPAAAMPDwwAAACwAAAAAAQABAAACAkQBADs=' - return htmlContent.replace(/( { if (!hexo.theme.config.lazyload.enable) return - data.content = lazyProcess.call(this, data.content) - return data -} - -hexo.extend.filter.register('after_post_render', processPost) + const bg = hexo.theme.config.lazyload.post ? urlFor(hexo.theme.config.lazyload.post) : 'data:image/gif;base64,R0lGODdhAQABAPAAAMPDwwAAACwAAAAAAQABAAACAkQBADs=' + return data.content.replace(/( { @@ -35,19 +35,19 @@ hexo.extend.helper.register('aside_categories', function (categories, options) { const hierarchicalList = (t, level, parent, topparent = true) => { let result = '' - var isTopParent = topparent + const isTopParent = topparent if (t > 0) { prepareQuery(parent).forEach((cat, i) => { if (t > 0) { t = t - 1 let child if (!depth || level + 1 < depth) { - var childList = hierarchicalList(t, level + 1, cat._id, false) + const childList = hierarchicalList(t, level + 1, cat._id, false) child = childList[0] t = childList[1] } - var parentClass = isExpand && isTopParent && child ? 'parent' : '' + const parentClass = isExpand && isTopParent && child ? 'parent' : '' result += `
  • ` @@ -79,8 +79,8 @@ hexo.extend.helper.register('aside_categories', function (categories, options) { const list = hierarchicalList(limit, 0) - var moreButton = function () { - var moreHtml = '' + const moreButton = function () { + let moreHtml = '' if (categories.length <= limit) return '' moreHtml += '
  • ' moreHtml += ` diff --git a/scripts/helpers/page.js b/scripts/helpers/page.js index 74e7674..f827ccf 100644 --- a/scripts/helpers/page.js +++ b/scripts/helpers/page.js @@ -9,6 +9,7 @@ 'use strict' const { stripHTML, escapeHTML } = require('hexo-util') +const crypto = require('crypto') hexo.extend.helper.register('page_description', function () { const { config, page } = this @@ -25,7 +26,7 @@ hexo.extend.helper.register('page_description', function () { hexo.extend.helper.register('injectHtml', function (data) { let result = '' if (!data) return '' - for (var i = 0; i < data.length; i++) { + for (let i = 0; i < data.length; i++) { result += data[i] } return result @@ -41,8 +42,8 @@ hexo.extend.helper.register('cloudTags', function (options = {}) { let result = '' const tagLimit = limit === 0 ? source.length : limit source.sort('name').limit(tagLimit).forEach(function (tags) { - var fontSize = Math.floor(Math.random() * (maxfontsize - minfontsize) + minfontsize) + 'px' - var color = 'rgb(' + Math.floor(Math.random() * 201) + ', ' + Math.floor(Math.random() * 201) + ', ' + Math.floor(Math.random() * 201) + ')' // 0,0,0 -> 200,200,200 + const fontSize = Math.floor(Math.random() * (maxfontsize - minfontsize) + minfontsize) + 'px' + const color = 'rgb(' + Math.floor(Math.random() * 201) + ', ' + Math.floor(Math.random() * 201) + ', ' + Math.floor(Math.random() * 201) + ')' // 0,0,0 -> 200,200,200 result += `${tags.name}` }) return result @@ -56,3 +57,7 @@ hexo.extend.helper.register('urlNoIndex', function () { } return url }) + +hexo.extend.helper.register('md5', function (path) { + return crypto.createHash('md5').update(decodeURI(this.url_for(path))).digest('hex') +}) diff --git a/scripts/helpers/related_post.js b/scripts/helpers/related_post.js index 60c1e6c..4fa0c69 100644 --- a/scripts/helpers/related_post.js +++ b/scripts/helpers/related_post.js @@ -7,11 +7,11 @@ 'use strict' hexo.extend.helper.register('related_posts', function (currentPost, allPosts) { - var relatedPosts = [] + let relatedPosts = [] currentPost.tags.forEach(function (tag) { allPosts.forEach(function (post) { if (isTagRelated(tag.name, post.tags)) { - var relatedPost = { + const relatedPost = { title: post.title, path: post.path, cover: post.cover, @@ -20,7 +20,7 @@ hexo.extend.helper.register('related_posts', function (currentPost, allPosts) { updated: post.updated, created: post.date } - var index = findItem(relatedPosts, 'path', post.path) + const index = findItem(relatedPosts, 'path', post.path) if (index !== -1) { relatedPosts[index].weight += 1 } else { @@ -34,14 +34,14 @@ hexo.extend.helper.register('related_posts', function (currentPost, allPosts) { if (relatedPosts.length === 0) { return '' } - var result = '' + let result = '' const hexoConfig = hexo.theme.config.rootConfig const config = hexo.theme.config - var limitNum = config.related_post.limit || 6 - var dateType = config.related_post.date_type || 'created' - var headlineLang = this._p('post.recommend') - var lazySrc = config.lazyload.enable ? 'data-src' : 'src' + const limitNum = config.related_post.limit || 6 + const dateType = config.related_post.date_type || 'created' + const headlineLang = this._p('post.recommend') + const lazySrc = config.lazyload.enable ? 'data-lazy-src' : 'src' relatedPosts = relatedPosts.sort(compare('weight')) @@ -54,8 +54,8 @@ hexo.extend.helper.register('related_posts', function (currentPost, allPosts) { '' result += '