diff --git a/.github/stale.yml b/.github/stale.yml index 9e65d06..355bbee 100644 --- a/.github/stale.yml +++ b/.github/stale.yml @@ -4,9 +4,12 @@ daysUntilStale: 30 daysUntilClose: 7 # Issues with these labels will never be considered stale exemptLabels: + - pinned + - security - bug - - documentation - enhancement + - Solved + - documentation # Label to use when marking an issue as stale staleLabel: wontfix # Comment to post when marking an issue as stale. Set to `false` to disable @@ -15,4 +18,4 @@ markComment: > recent activity. It will be closed if no further activity occurs. Thank you for your contributions. # Comment to post when closing a stale issue. Set to `false` to disable -closeComment: false +closeComment: false \ No newline at end of file diff --git a/README.md b/README.md index a1162e4..6c4b6da 100644 --- a/README.md +++ b/README.md @@ -1,30 +1,15 @@ # hexo-theme-butterfly -Version +Version Author -Hexo -node.js - -Demo: https://demo.jerryc.me/ +Hexo +node.js +Demo: https://demo.jerryc.me/ JerryC: https://jerryc.me/ - - Based on [hexo-theme-melody](https://github.com/Molunerfinn/hexo-theme-melody) theme. -> If you update to hexo 4.2.0,it will be something's wrong -> -> ``` -> Error: Cannot find module 'cheerio' -> ``` -> -> please install cheerio -> -> ``` -> npm install cheerio@0.22.0 --save -> ``` - ## Installation Stable branch: @@ -51,7 +36,7 @@ git clone -b dev https://github.com/jerryc127/hexo-theme-butterfly.git themes/Bu ## Documentation - Documentation is [here](https://jerryc.me/posts/21cfbf15). it supports `zh-TW` +Find in [hexo-theme-butterfly docs](https://docs.jerryc.me) and [JerryC](https://jerryc.me/posts/21cfbf15). it supports `zh-TW` ## Screenshots diff --git a/README_CN.md b/README_CN.md index 3f11bd4..e74e055 100644 --- a/README_CN.md +++ b/README_CN.md @@ -1,31 +1,19 @@ # hexo-theme-butterfly -Version +Version Author -Hexo -node.js +Hexo +node.js Demo: https://demo.jerryc.me/ - JerryC: https://jerryc.me/ + 一款基於[hexo-theme-melody](https://github.com/Molunerfinn/hexo-theme-melody)修改的主題 -> 如果升級到hexo 4.2.0 ,會出現報錯 -> -> ``` -> Error: Cannot find module 'cheerio' -> ``` -> -> 請在博客根目錄安裝cheerio -> -> ``` -> npm install cheerio@0.22.0 --save -> ``` - ## 安裝 -在你的博客根目錄裏 +在你的博客根目錄裡 ``` git clone -b master https://github.com/jerryc127/hexo-theme-butterfly.git themes/Butterfly @@ -48,7 +36,7 @@ theme: Butterfly ## 文檔 -可查看[這裏](https://jerryc.me/posts/21cfbf15) +可查看[hexo-theme-butterfly docs](https://docs.jerryc.me) 和 [JerryC](https://jerryc.me/posts/21cfbf15) ## 截圖 ![image](https://user-images.githubusercontent.com/16351105/58887365-1272f780-8718-11e9-9329-3292c6ba20d4.png) diff --git a/_config.yml b/_config.yml index 1330538..a60630f 100644 --- a/_config.yml +++ b/_config.yml @@ -42,9 +42,9 @@ code_word_wrap: false # copy setting # 是否禁止複製(如果禁止,highlight_copy的功能將無效) -# copyright 複製的内容後面加上版權信息 +# copyright 複製的內容後面加上版權信息 copy: - enable: true # true 開啓 / false 禁止 + enable: true # true 開啟 / false 禁止 copyright: false # social settings @@ -96,43 +96,79 @@ katex: per_page: false hide_scrollbar: true +# mermaid +# see https://github.com/knsv/mermaid +# ------------------------------- +mermaid: + enable: false + # built-in themes: default/forest/dark/neutral + theme: default + # Post info settings # --------------- -avatar: /img/avatar.png +avatar: + img: /img/avatar.png + effect: false # 頭像會一直轉圈 # the banner image of index -index_img: https://cdn.jsdelivr.net/gh/jerryc127/butterfly_cdn@2.1.0/top_img/index.jpg +index_img: # if the banner of page not setting,it will show the top_img -default_top_img: https://cdn.jsdelivr.net/gh/jerryc127/butterfly_cdn@2.1.0/top_img/index.jpg - -# the default cover of the post -default_cover: https://cdn.jsdelivr.net/gh/jerryc127/butterfly_cdn@2.1.0/top_img/default.png +default_top_img: /img/index.jpg # the banner image of archive page -archive_img: https://cdn.jsdelivr.net/gh/jerryc127/butterfly_cdn@2.1.0/top_img/archive.jpg +archive_img: # the banner image of tag page -tag_img: https://cdn.jsdelivr.net/gh/jerryc127/butterfly_cdn@2.1.0/top_img/tag.png +# tag page, look like https://xxxxxxxxx.com/tags/butterfly +tag_img: # the banner image of category page -category_img: https://cdn.jsdelivr.net/gh/jerryc127/butterfly_cdn@2.1.0/top_img/category.jpg +# category page, look like https://xxxxxxxxx.com/categories/butterfly +category_img: -# 如果你有使用hexo-douban去生成movie界面,可配置這個 -movies_img: https://cdn.jsdelivr.net/gh/jerryc127/butterfly_cdn@2.1.0/top_img/movie.jpg +# 如果你有使用hexo-douban,可配置這個 +# douban: +# meta: false +# movies_img: +# books_img: +# games_img: + +cover: + # 是否顯示文章封面 + index_enable: true + aside_enable: true + archives_enable: true + # 封面顯示的位置 + # 三個值可配置 left , right , both + position: both + # 當沒有設置cover時,默認的封面顯示 + default_cover: + - /img/post.jpg # if the photo link cannot connect,it will show that lodding_bg: - flink: /img/friend_404.gif #404后圖片 - post_page: /img/404.jpg #404后圖片 + flink: /img/friend_404.gif #404後圖片 + post_page: /img/404.jpg #404後圖片 # post: /img/loading.gif ##加載動畫 -post_meta: - date_type: both # or created or updated 文章日期是创建日或者更新日或都显示 - categories: true # or false 是否显示分类 - tags: true # or false 是否显示标签 +# A simple 404 page +error_404: + enable: false + subtitle: "Page Not Found" + background: -# Please see doc for more details: https://jerryc.me/posts/21cfbf15/#字数统计 +post_meta: + page: + date_type: created # created or updated or both 主頁文章日期是創建日或者更新日或都顯示 + categories: true # true or false 主頁是否顯示分類 + tags: false # true or false 主頁是否顯示標籤 + post: + date_type: both # created or updated or both 文章頁日期是創建日或者更新日或都顯示 + categories: true # true or false 文章頁是否顯示分類 + tags: true # true or false 文章頁是否顯示標籤 + +# Please see doc for more details: https://jerryc.me/posts/21cfbf15/#字數統計 wordcount: enable: false @@ -146,6 +182,7 @@ auto_open_sidebar: post_copyright: enable: true + decode: false license: CC BY-NC-SA 4.0 license_url: https://creativecommons.org/licenses/by-nc-sa/4.0/ @@ -178,22 +215,23 @@ addtoany: #### Comments System #### # ------------------------------------ -# Disqus 官方版評論系統 disqus: enable: false shortname: count: false # top_img顯示評論數 -# Disqus.js 版評論系統,應對大陸長城的折中方案,兼容原版:https://github.com/SukkaW/DisqusJS +# Disqus.js版評論系統,應對大陸長城的折中方案,兼容原版:https://github.com/SukkaW/DisqusJS # API 申請地址:https://disqus.com/api/applications/ # 與 disqus 共用樣式 disqusjs: - enable: false #開啓改爲 true - shortname: - siteName: - apikey: + enable: false + shortname: + siteName: + apikey: api: https://disqus.skk.moe/disqus/ #一般情況下無需修改 API 地址 - count: false # top_img顯示評論數 + admin: + adminLabel: + count: true # top_img顯示評論數 laibili: enable: false @@ -206,8 +244,12 @@ gitalk: repo: owner: admin: - language: # en , zh-CN , zh-TW - count: false # top_img顯示評論數 + language: zh-CN # en , zh-CN , zh-TW + perPage: 10 # Pagination size, with maximum 100. + 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: true # top_img顯示評論數 # valine comment system. https://valine.js.org valine: @@ -221,12 +263,25 @@ valine: lang: en # i18n: zh-cn/en placeholder: Please leave your footprints # valine comment input placeholder(like: Please leave your footprints ) guest_info: nick,mail,link #valine comment header info + 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: /img/comment_bg.png # valine background - count: false # top_img顯示評論數 + count: true # top_img顯示評論數 + +# utterances +# https://utteranc.es/ +utterances: + enable: false + repo: + # 可選 pathname/url/title/og:title + issue_term: pathname + # 可選 github-light/github-dark/github-dark-orange/icy-dark/dark-blue/photon-dark + light_theme: github-light + dark_theme: photon-dark ##### Footer Settings #### # ------------------------------------ -since: 2019 +since: 2020 footer_custom_text: @@ -275,16 +330,6 @@ baidu_site_verification: # see http://zhanzhang.so.com/ qihu_site_verification: -# 友情鏈接界面設置 -Flink: - headline: 友情鏈接 - info_headline: 我的Blog資料 - name: Blog 名字: JerryC - address: Blog 地址: https://jerryc.me/ - avatar: Blog 頭像: https://jerryc.me/img/avatar.png - info: Blog 簡介: 今日事,今日畢 - comment: 如果需要交換友鏈,請留言 - # 打賞按鈕 reward: enable: true @@ -300,7 +345,7 @@ reward: related_post: enable: true limit: 6 # 顯示推薦文章數目 - date_type: created # or created or updated 文章日期顯示创建日或者更新日 + date_type: created # or created or updated 文章日期顯示創建日或者更新日 #### 美化/效果 #### #-------------------------------- @@ -315,20 +360,19 @@ related_post: # button_hover: "#FF7242" # text_selection: "#00c4b6" # link_color: "#99a9bf" -# meta_color: '#858585' +# meta_color: "#858585" # hr_color: "#A4D8FA" -# read-mode-bg_color: '#FAF9DE' -# inline-code-color: '#F47466' +# code_foreground: "#F47466" +# code_background: "rgba(27, 31, 35, .05)" +# toc_color: "#00c4b6" +# blockquote_padding_color: "#49b1f5" +# blockquote_background_color: "#49b1f5" # 主頁設置 # 默認top_img全屏,site_info在中間 # 使用默認, 都無需填寫(建議默認) -index_top_img_height: #主頁top_img高度 例如 300px/300em/300rem 不能使用百分比 - -# 主頁文章COVER顯示位置 -# 三個值可配置 left , right , both -# left(全部圖片顯示在左邊),right(全部圖片顯示在右邊),both(左右左右順序顯示) -index_post_cover: both +index_site_info_top: # 主頁標題距離頂部距離 例如 300px/300em/300rem/10% +index_top_img_height: # 主頁top_img高度 例如 300px/300em/300rem 不能使用百分比 # category和tag頁的UI設置 # index 值代表 UI將與首頁的UI一樣 @@ -347,7 +391,7 @@ background: footer_bg: false # 背景特效 -# 避免卡頓,建議只開啓一個 +# 避免卡頓,建議只開啟一個 # canvas_ribbon 禁止彩帶背景 # See: https://github.com/hustcc/ribbon.js canvas_ribbon: @@ -380,8 +424,8 @@ activate_power_mode: shake: true # 抖動特效 # 鼠標點擊效果 -# 避免卡頓,建議只開啓一個 -# 點擊烟火特效 +# 避免卡頓,建議只開啟一個 +# 點擊煙火特效 fireworks: enable: false @@ -393,30 +437,17 @@ click_heart: ClickShowText: enable: false text: - - 富强 - - 民主 - - 文明 - - 和谐 - - 自由 - - 平等 - - 公正 - - 法治 - - 爱国 - - 敬业 - - 诚信 - - 友善 + - 本人 + - 超帥 fontSize: 15px -# 頭像會一直轉圈 -avatar_effect: false - # 網站顯示模式 # light 默認模式 # dark 黑暗模式(不建議) display_mode: light -# 美化post頁顯示 -post_beautify: +# 美化頁面顯示 +beautify: enable: false title-prefix-icon: '\f0c1' title-prefix-icon-color: "#F47466" @@ -440,29 +471,37 @@ hr: icon-top: -20px # 主頁subtitle -# 打字效果 subtitle: enable: true + # 打字效果 + effect: true + # 循環或者只打字一次 + loop: false # source調用第三方服務 # source: false 關閉調用 # source: 1 調用金山詞霸的每日一句(簡體) - # source: 2 調用一言网的一句話(簡體) #https://hitokoto.cn/ - # source: 3 調用一句网(簡體) http://yijuzhan.com/ + # source: 2 調用一言網的一句話(簡體) #https://hitokoto.cn/ + # source: 3 調用一句網(簡體) http://yijuzhan.com/ # source: 4 調用今日詩詞(簡體) https://www.jinrishici.com/ - # subtitle 會先顯示 source , 再顯示 sub 的内容 + # subtitle 會先顯示 source , 再顯示 sub 的內容 source: false # (如果有英文逗號' , ',請使用轉義字符 ,) + # 如果關閉打字效果,subtitle只會顯示sub的第一行文字 sub: - 今日事,今日畢 - Never put off till tomorrow what you can do today +# fontawesome圖標 +# 默認使用的是 fontawesome v4版本的圖標 +fontawesome_v5: + enable: false + #### 側邊欄 #### #------------------------------------- -# 手機頁面( 顯示寬度 < 768px )是否顯示aside内容 -aside_mobile: true - # 側邊欄顯示設置 aside: + enable: true + mobile: true # 手機頁面( 顯示寬度 < 768px )是否顯示aside內容 position: right # left or right card_author: true card_announcement: true @@ -497,30 +536,31 @@ translate: enable: true # 默認按鈕顯示文字 default: 繁 - #网站默认语言,1: 繁體中文, 2: 简体中文 + #網站默認語言,1: 繁體中文, 2: 簡體中文 defaultEncoding: 2 - #延迟时间,若不在前, 要设定延迟翻译时间, 如100表示100ms,默认为0 + #延遲時間,若不在前, 要設定延遲翻譯時間, 如100表示100ms,默認為0 translateDelay: 0 - #博客网址 + #博客網址 cookieDomain: "https://xxx/" #當文字是簡體時,按鈕顯示的文字 msgToTraditionalChinese: "繁" #當文字是繁體時,按鈕顯示的文字 - msgToSimplifiedChinese: "简" + msgToSimplifiedChinese: "簡" #閲讀模式 readmode: enable: true -# 夜間模式 +# dark mode darkmode: enable: true - -# 自動切換 dark mode和 light mode -# autoChangeMode: 1 跟隨系統而變化,不支持的瀏覽器/系統將按照時間晚上6點到早上6點之間切換為 dark mode -# autoChangeMode: 2 只按照時間晚上6點到早上6點之間切換為 dark mode -# autoChangeMode: false 取消自動切換 -autoChangeMode: false + # dark mode和 light mode切換按鈕 + button: true + # 自動切換 dark mode和 light mode + # autoChangeMode: 1 跟隨系統而變化,不支持的瀏覽器/系統將按照時間晚上6點到早上6點之間切換為 dark mode + # autoChangeMode: 2 只按照時間晚上6點到早上6點之間切換為 dark mode + # autoChangeMode: false 取消自動切換 + autoChangeMode: 1 #### other #### #------------------------------------------------ @@ -556,6 +596,12 @@ baidu_push: instantpage: enable: true +# https://github.com/vinta/pangu.js +# 中英文之間添加空格 +pangu: + enable: false + field: page # page/post + # Note (Bootstrap Callout) # https://muse.theme-next.org/docs/tag-plugins/note note: @@ -590,14 +636,15 @@ twitter_meta: true # https://i.loli.net/2019/09/08/2wbFJEKloisRvhj.png Open_Graph_meta: true +# 開啟hexo自帶的緩存,加快生成速度 +fragment_cache: true + # CDN # 網站必須 # 可根據需要自行添加js/css CDN_USE: css: - /css/index.css - - https://cdn.jsdelivr.net/npm/font-awesome@latest/css/font-awesome.min.css - # - https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css #fontawesomeV5_css js: - https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js #/js/third-party/jquery.min.js @@ -607,52 +654,65 @@ CDN_USE: # CDN # 非必要不要修改 CDN: - #comments - blueimp_md5: https://cdn.jsdelivr.net/npm/blueimp-md5@2.10.0/js/md5.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 + disqusjs: https://cdn.jsdelivr.net/npm/disqusjs@1.2/dist/disqus.js + disqusjs_css: https://cdn.jsdelivr.net/npm/disqusjs@1.2/dist/disqusjs.css + utterances: https://utteranc.es/client.js # share addtoany: https://static.addtoany.com/menu/page.js sharejs: https://cdn.jsdelivr.net/npm/social-share.js/dist/js/social-share.min.js sharejs_css: https://cdn.jsdelivr.net/npm/social-share.js/dist/css/share.min.css - #search + # search + local_search: /js/search/local-search.js + algolia_js: /js/search/algolia.js algolia_search: https://cdn.jsdelivr.net/npm/instantsearch.js@2.10.5/dist/instantsearch.min.js 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 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 + mermaid: https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js - #不蒜子計數器 + # count busuanzi: //busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js - # 背景特效 - canvas_ribbon: https://cdn.jsdelivr.net/gh/jerryc127/butterfly_cdn@2.1.0/js/canvas-ribbon.js - canvas_ribbon_piao: https://cdn.jsdelivr.net/gh/jerryc127/butterfly_cdn@2.1.0/js/piao.js - canvas_nest: https://cdn.jsdelivr.net/gh/jerryc127/butterfly_cdn@2.1.0/js/canvas-nest.js + # background effect + canvas_ribbon: /js/third-party/canvas-ribbon.js + canvas_ribbon_piao: /js/third-party/piao.js + canvas_nest: /js/third-party/canvas-nest.js lazyload: https://cdn.jsdelivr.net/npm/lazysizes@latest/lazysizes.min.js instantpage: https://cdn.jsdelivr.net/npm/instant.page@latest/instantpage.min.js - typed: https://cdn.jsdelivr.net/npm/typed.js js_cookies: https://cdn.jsdelivr.net/npm/js-cookie/dist/js.cookie.min.js + pangu: https://cdn.jsdelivr.net/npm/pangu/dist/browser/pangu.min.js + # photo fancybox_css: https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.css fancybox: https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.js medium_zoom: https://cdn.jsdelivr.net/npm/medium-zoom/dist/medium-zoom.min.js + # snackbar snackbar_css: https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.css snackbar: https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.js - #鼠标点击特效 + # 鼠標點擊特效 anime: https://cdn.jsdelivr.net/npm/animejs@latest/anime.min.js - activate_power_mode: https://cdn.jsdelivr.net/npm/activate-power-mode/dist/activate-power-mode.min.js - fireworks: https://cdn.jsdelivr.net/gh/jerryc127/butterfly_cdn@2.1.0/js/fireworks.js - click_heart: https://cdn.jsdelivr.net/gh/jerryc127/butterfly_cdn@2.1.0/js/click_heart.js - ClickShowText: https://cdn.jsdelivr.net/gh/jerryc127/butterfly_cdn@2.1.0/js/ClickShowText.js + activate_power_mode: /js/third-party/activate-power-mode.js + fireworks: /js/third-party/fireworks.js + click_heart: /js/third-party/click_heart.js + ClickShowText: /js/third-party/ClickShowText.js + + # fontawesome + fontawesome_v4: https://cdn.jsdelivr.net/npm/font-awesome@latest/css/font-awesome.min.css + fontawesome_v5: https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css translate: /js/tw_cn.js diff --git a/languages/default.yml b/languages/default.yml index d74e13b..29894f9 100644 --- a/languages/default.yml +++ b/languages/default.yml @@ -19,7 +19,6 @@ page: sticky: Sticky no_title: No title -archives: Archives post: created: Created @@ -27,12 +26,13 @@ post: wordcount: Word count min2read: "Reading time: %s min" page_pv: Post View - comments: comments + comments: Comments copyright: author: Author link: Link copyright_notice: Copyright Notice copyright_content: 'All articles in this blog are licensed under %s unless stating additionally.' + recommend: Recommend search: Search algolia_search: @@ -71,11 +71,9 @@ aside: donate: Donate share: Share - bookmark: title: Bookmark - rightside: readmode_title: Read Mode font_plus_title: Increase font size @@ -101,5 +99,7 @@ Snackbar: message_next: to bookmark this page chs_to_cht: Traditional Chinese Activated Manually cht_to_chs: Simplified Chinese Activated Manually - day_to_night: Light Mode Activated Manually - night_to_day: Dark Mode Activated Manually + day_to_night: Dark Mode Activated Manually + night_to_day: Light Mode Activated Manually + +error_title: Page not found diff --git a/languages/en.yml b/languages/en.yml index d79d1dc..29894f9 100644 --- a/languages/en.yml +++ b/languages/en.yml @@ -19,7 +19,6 @@ page: sticky: Sticky no_title: No title -archives: Archives post: created: Created @@ -27,12 +26,13 @@ post: wordcount: Word count min2read: "Reading time: %s min" page_pv: Post View - comments: comments + comments: Comments copyright: author: Author link: Link copyright_notice: Copyright Notice copyright_content: 'All articles in this blog are licensed under %s unless stating additionally.' + recommend: Recommend search: Search algolia_search: @@ -101,3 +101,5 @@ Snackbar: cht_to_chs: Simplified Chinese Activated Manually day_to_night: Dark Mode Activated Manually night_to_day: Light Mode Activated Manually + +error_title: Page not found diff --git a/languages/zh-CN.yml b/languages/zh-CN.yml index e804c47..9b4e224 100644 --- a/languages/zh-CN.yml +++ b/languages/zh-CN.yml @@ -19,7 +19,6 @@ page: sticky: 置顶 no_title: 无题 -archives: 时间轴 post: created: 发表于 @@ -32,7 +31,9 @@ post: author: 文章作者 link: 文章链接 copyright_notice: 版权声明 - copyright_content: '本博客所有文章除特别声明外,均采用 %s 许可协议。转载请注明来自 %s!' + copyright_content: '本博客所有文章除特别声明外,均采用 + %s 许可协议。转载请注明来自 %s!' + recommend: 相关推荐 search: 搜索 algolia_search: @@ -75,7 +76,6 @@ share: 分享 bookmark: title: 添加书签 - rightside: readmode_title: 阅读模式 font_plus_title: 放大字体 @@ -103,3 +103,5 @@ Snackbar: cht_to_chs: 你已切换为简体 day_to_night: 你已切换为深色模式 night_to_day: 你已切换为浅色模式 + +error_title: 页面没有找到 diff --git a/languages/zh-TW.yml b/languages/zh-TW.yml index 0bd13d5..8aad902 100644 --- a/languages/zh-TW.yml +++ b/languages/zh-TW.yml @@ -15,11 +15,10 @@ page: articles: 文章總覽 tag: 標籤 category: 分類 - archives: 時間軸 + archives: 歸檔 sticky: 置頂 no_title: 無題 -archives: 時間軸 post: created: 發表於 @@ -34,6 +33,7 @@ post: copyright_notice: 版權聲明 copyright_content: '本博客所有文章除特別聲明外,均採用 %s 許可協議。轉載請註明來自 %s!' + recommend: 相關推薦 search: 搜索 algolia_search: @@ -76,7 +76,6 @@ share: 分享 bookmark: title: 添加書籤 - rightside: readmode_title: 閲讀模式 font_plus_title: 放大字體 @@ -105,4 +104,6 @@ Snackbar: day_to_night: 你已切換為深色模式 night_to_day: 你已切換為淺色模式 +error_title: 頁面沒有找到 + diff --git a/layout/404.pug b/layout/404.pug new file mode 100644 index 0000000..8ae9438 --- /dev/null +++ b/layout/404.pug @@ -0,0 +1,87 @@ +doctype html +html(lang=config.language data-theme=theme.display_mode) + head + - var pageTitle = _p('error_title') + - var tabTitle = pageTitle + ' | ' + config.title + - var pageDescription = page.description || page.title || config.description + - var pageKeywords = Array.isArray(config.keywords) ? (config.keywords).join(','): ([]).join(',') || config.keywords + - var pageAuthor = config.email ? config.author + ',' + config.email : config.author + - var pageCopyright = config.copyright || config.author + - var without_html = url.replace('index.html', '') + - var top_img = theme.error_404.background || theme.default_top_img + - var bg_img = `background-image: url(${top_img})` + + + meta(charset='UTF-8') + meta(http-equiv="X-UA-Compatible" content="IE=edge") + meta(name="viewport" content="width=device-width, initial-scale=1, maximum-scale=5") + title= tabTitle + meta(name="description" content=pageDescription) + if pageKeywords + meta(name="keywords" content=pageKeywords) + meta(name="author" content=pageAuthor) + meta(name="copyright" content=pageCopyright) + meta(name ="format-detection" content="telephone=no") + !=favicon_tag(theme.favicon || config.favicon) + //- 預解析 + include includes/head/dns_prefetch.pug + //- 網站驗證 + include includes/head/site_verification.pug + //- Open_Graph + include includes/head/Open_Graph.pug + //- PWA + if (theme.pwa && theme.pwa.enable) + include includes/head/pwa + + script(src=url_for(theme.CDN.js_cookies)) + + if theme.darkmode.enable + include includes/head/darkmode.pug + + each item in theme.CDN_USE.css + link(rel='stylesheet', href=url_for(item)) + + if theme.fontawesome_v5 && theme.fontawesome_v5.enable + link(rel='stylesheet', href=url_for(theme.CDN.fontawesome_v5)) + else + link(rel='stylesheet', href=url_for(theme.CDN.fontawesome_v4)) + + if (theme.snackbar && theme.snackbar.enable) + link(rel='stylesheet', href=url_for(theme.CDN.snackbar_css)) + + if theme.canonical + link(rel="canonical" href=without_html) + + if theme.algolia_search.enable + link(rel="stylesheet" type="text/css" href=url_for(theme.CDN.algolia_search_css)) + script(src=url_for(theme.CDN.algolia_search) defer) + + //- google_adsense + include includes/head/google_adsense.pug + + //- analytics + include includes/head/analytics.pug + + if theme.blog_title_font.font_link + link(rel='stylesheet', href=url_for(theme.blog_title_font.font_link)) + + include includes/head/config.pug + include includes/head/config_site.pug + + body + if theme.fireworks && theme.fireworks.enable + canvas.fireworks + nav#nav.error-no-found(style=bg_img) + include includes/header/header.pug + #error_info.is-center + h1#error_title= '404' + #error_subtitle= theme.error_404.subtitle + include includes/mobile-sidebar/index.pug + include includes/rightside.pug + each item in theme.CDN_USE.js + script(src=url_for(item)) + include includes/additional-js.pug + include includes/search/index.pug + + + diff --git a/layout/archive.pug b/layout/archive.pug index 84d7cd7..faa485c 100644 --- a/layout/archive.pug +++ b/layout/archive.pug @@ -1,4 +1,3 @@ - extends includes/layout.pug block content @@ -6,6 +5,4 @@ block content #archive .article-sort-title= _p('page.articles') + ' - ' + site.posts.length +articleSort(page.posts) - include includes/pagination.pug - #aside_content.aside_content - include includes/widget/index.pug + include includes/pagination.pug \ No newline at end of file diff --git a/layout/category.pug b/layout/category.pug index aadf5b0..c8b5cb3 100644 --- a/layout/category.pug +++ b/layout/category.pug @@ -5,15 +5,10 @@ block content include ./includes/mixins/UI.pug #recent-posts.recent-posts.category_ui +UI_NEW(page.posts) - include includes/pagination.pug - #aside_content.aside_content - include includes/widget/index.pug + include includes/pagination.pug else include ./includes/mixins/article-sort.pug #category .article-sort-title= _p('page.category') + ' - ' + page.category +articleSort(page.posts) - include includes/pagination.pug - #aside_content.aside_content - include includes/widget/index.pug - \ No newline at end of file + include includes/pagination.pug \ No newline at end of file diff --git a/layout/flink.pug b/layout/flink.pug index b88ac37..532dcc5 100644 --- a/layout/flink.pug +++ b/layout/flink.pug @@ -1,30 +1,20 @@ -.flink - each i in site.data.link - h1= i.class_name - .post-cards - ul.md-links - each item in i.link_list - li.md-links-item - a(href=item.link title=item.name target="_blank") - if theme.lazyload.enable - img.lazyload(data-src=item.avatar onerror=`this.onerror=null;this.src='` + url_for(theme.lodding_bg.flink) + `'` alt=item.name ) - else - img(src=item.avatar onerror=`this.onerror=null;this.src='` + url_for(theme.lodding_bg.flink) + `'` alt=item.name ) - .md-links-title= item.name - .md-links-des= item.descr - - hr - div - h2= theme.Flink.info_headline - ul - li= theme.Flink.name - li= theme.Flink.address - li= theme.Flink.avatar - li= theme.Flink.info - - hr - .comment_int - p.comment-word= theme.Flink.comment - +#page + .flink#article-container + each i in site.data.link + h2= i.class_name + .post-cards + .md-links + each item in i.link_list + .md-links-item + a(href=item.link title=item.name target="_blank") + if theme.lazyload.enable + img.lazyload(data-src=item.avatar onerror=`this.onerror=null;this.src='` + url_for(theme.lodding_bg.flink) + `'` alt=item.name ) + else + img(src=item.avatar onerror=`this.onerror=null;this.src='` + url_for(theme.lodding_bg.flink) + `'` alt=item.name ) + .md-links-title= item.name + .md-links-des= item.descr + != page.content + if page.comments !== false + include includes/comments/index.pug diff --git a/layout/includes/additional-js.pug b/layout/includes/additional-js.pug index dec18e5..9f7804a 100644 --- a/layout/includes/additional-js.pug +++ b/layout/includes/additional-js.pug @@ -26,12 +26,10 @@ if (theme.canvas_nest && theme.canvas_nest.enable) include ./third-party/canvas-nest.pug if theme.activate_power_mode.enable - - var colorful = theme.activate_power_mode.colorful == false ? false : true - - var shake = theme.activate_power_mode.shake == false ? false : true script(src=url_for(theme.CDN.activate_power_mode)) script. - POWERMODE.colorful = !{colorful}; - POWERMODE.shake = !{shake}; + POWERMODE.colorful = #{theme.activate_power_mode.colorful}; + POWERMODE.shake = #{theme.activate_power_mode.shake}; document.body.addEventListener('input', POWERMODE); if theme.busuanzi.site_uv || theme.busuanzi.site_pv || theme.busuanzi.page_pv @@ -50,5 +48,18 @@ if theme.click_heart && theme.click_heart.enable if theme.ClickShowText && theme.ClickShowText.enable script(src=url_for(theme.CDN.ClickShowText)) +if theme.pangu && theme.pangu.enable + include ./third-party/pangu.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)) + +//- mermaid +if theme.mermaid.enable + include ./math/mermaid.pug + if is_home() include index-js.pug \ No newline at end of file diff --git a/layout/includes/comments/disqus.pug b/layout/includes/comments/disqus.pug index 1e0c01c..e4c3937 100644 --- a/layout/includes/comments/disqus.pug +++ b/layout/includes/comments/disqus.pug @@ -1,13 +1,23 @@ -if theme.disqus && theme.disqus.enable - #disqus_thread - script. - var unused = null; - var disqus_config = function () { - this.page.url = '!{ page.permalink }'; - this.page.identifier = '!{ page.path }'; - this.page.title = '!{ page.title }'; - } +#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); \ No newline at end of file + s.src = 'https://!{theme.disqus.shortname}.disqus.com/embed.js'; + s.setAttribute('data-timestamp', +new Date()); + (d.head || d.body).appendChild(s); + })(); + +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 index aaa7504..8b9edbe 100644 --- a/layout/includes/comments/disqusjs.pug +++ b/layout/includes/comments/disqusjs.pug @@ -1,16 +1,23 @@ -if theme.disqusjs && theme.disqusjs.enable - #disqus_thread - link(href=('https://cdn.jsdelivr.net/npm/disqusjs@1.2/dist/disqusjs.css') rel='stylesheet') - script(src=('https://cdn.jsdelivr.net/npm/disqusjs@1.2/dist/disqus.js')) - 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}', - admin: '', - adminLabel: '' - }); \ No newline at end of file +#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}', + admin: '!{theme.disqusjs.admin}', + adminLabel: '!{theme.disqusjs.adminLabel}' + }); + +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/gitalk.pug b/layout/includes/comments/gitalk.pug index c2f27a6..d4551a2 100644 --- a/layout/includes/comments/gitalk.pug +++ b/layout/includes/comments/gitalk.pug @@ -1,20 +1,23 @@ -if theme.gitalk && theme.gitalk.enable - #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}', - updateCountCallback: commentCount - }) - gitalk.render('gitalk-container') +#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){ - document.getElementsByClassName('gitalk-comment-count')[0].innerHTML= n - } + function commentCount(n){ + document.getElementsByClassName('gitalk-comment-count')[0].innerHTML= n + } diff --git a/layout/includes/comments/index.pug b/layout/includes/comments/index.pug index ac01ec5..030ae23 100644 --- a/layout/includes/comments/index.pug +++ b/layout/includes/comments/index.pug @@ -3,8 +3,10 @@ - var l = theme.laibili && theme.laibili.enable - var gt = theme.gitalk && theme.gitalk.enable - var v = theme.valine && theme.valine.enable +- var u = theme.utterances && theme.utterances.enable +- var isComment = d || dj || l || gt || v || u -if d || dj || l || gt || v +if isComment hr #post-comment .comment_headling @@ -19,4 +21,6 @@ if d || dj || l || gt || v else if gt include ./gitalk.pug else if v - include ./valine.pug \ No newline at end of file + include ./valine.pug + else if u + include ./utterances.pug \ No newline at end of file diff --git a/layout/includes/comments/laibili.pug b/layout/includes/comments/laibili.pug index 334aab8..cd0fc75 100644 --- a/layout/includes/comments/laibili.pug +++ b/layout/includes/comments/laibili.pug @@ -1,11 +1,10 @@ -if theme.laibili && theme.laibili.enable - #lv-container(data-id="city" data-uid=theme.laibili.uid) - script. - (function(d, s) { - var j, e = d.getElementsByTagName(s)[0]; - if (typeof LivereTower === 'function') { return; } - j = d.createElement(s); - j.src = 'https://cdn-city.livere.com/js/embed.dist.js'; - j.async = true; - e.parentNode.insertBefore(j, e); - })(document, 'script'); +#lv-container(data-id="city" data-uid=theme.laibili.uid) + script. + (function(d, s) { + var j, e = d.getElementsByTagName(s)[0]; + if (typeof LivereTower === 'function') { return; } + j = d.createElement(s); + j.src = 'https://cdn-city.livere.com/js/embed.dist.js'; + j.async = true; + e.parentNode.insertBefore(j, e); + })(document, 'script'); diff --git a/layout/includes/comments/utterances.pug b/layout/includes/comments/utterances.pug new file mode 100644 index 0000000..acb865a --- /dev/null +++ b/layout/includes/comments/utterances.pug @@ -0,0 +1,19 @@ +script#utterances_comment(src=theme.CDN.utterances + repo=theme.utterances.repo + issue-term=theme.utterances.issue_term + theme=theme.utterances.light_theme + crossorigin="anonymous" + async) +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 index 59a524f..71a771c 100644 --- a/layout/includes/comments/valine.pug +++ b/layout/includes/comments/valine.pug @@ -1,25 +1,23 @@ -if theme.valine && theme.valine.enable - #vcomment.vcomment - script(src=url_for(theme.CDN.valine)) - script. - var notify = #{ theme.valine.notify } == true ? true : false; - var verify = #{ theme.valine.verify } == true ? true : false; - var GUEST_INFO = ['nick','mail','link']; - var guest_info = '#{ theme.valine.guest_info }'.split(',').filter(function(item){ - return GUEST_INFO.indexOf(item) > -1 - }); - guest_info = guest_info.length == 0 ? GUEST_INFO :guest_info; +#vcomment.vcomment +script(src=url_for(theme.CDN.valine)) +script. + var GUEST_INFO = ['nick','mail','link']; + var guest_info = '#{ theme.valine.guest_info }'.split(',').filter(function(item){ + return GUEST_INFO.indexOf(item) > -1 + }); + guest_info = guest_info.length == 0 ? GUEST_INFO :guest_info; - window.valine = new Valine({ - el:'#vcomment', - notify:notify, - verify:verify, - appId:'#{theme.valine.appId}', - appKey:'#{theme.valine.appKey}', - placeholder:'#{theme.valine.placeholder}', - avatar:'#{theme.valine.avatar}', - guest_info:guest_info, - pageSize:'#{theme.valine.pageSize}', - lang:'#{theme.valine.lang}', - recordIP: true - }); + window.valine = new Valine({ + el:'#vcomment', + notify: #{theme.valine.notify}, + verify: #{theme.valine.verify}, + appId: '#{theme.valine.appId}', + appKey: '#{theme.valine.appKey}', + placeholder: '#{theme.valine.placeholder}', + avatar: '#{theme.valine.avatar}', + meta: guest_info, + pageSize: '#{theme.valine.pageSize}', + lang: '#{theme.valine.lang}', + recordIP: #{theme.valine.recordIP}, + serverURLs: '#{theme.valine.serverURLs}' + }); diff --git a/layout/includes/footer.pug b/layout/includes/footer.pug index 81a7e46..30b238f 100644 --- a/layout/includes/footer.pug +++ b/layout/includes/footer.pug @@ -8,7 +8,7 @@ if theme.footer_copyright.enable .framework-info span= _p('footer.driven') + ' ' - a(href='http://hexo.io') + a(href='https://hexo.io') span Hexo span.footer-separator | span= _p('footer.theme') + ' ' diff --git a/layout/includes/head.pug b/layout/includes/head.pug index de8c8f4..ddbb16f 100644 --- a/layout/includes/head.pug +++ b/layout/includes/head.pug @@ -1,31 +1,31 @@ -if is_home() - - var top_img = theme.index_img || theme.default_top_img -else if is_archive() - - var top_img = theme.archive_img || theme.default_top_img -else if is_tag() - - var top_img = theme.tag_img || theme.default_top_img -else if is_category() - - var top_img = theme.category_img || theme.default_top_img -else if is_current('/movies/', [strict]) - - var top_img = theme.movies_img || theme.default_top_img -else if !is_post() - - var top_img = page.top_img || theme.default_top_img +- var pageTitle = page.title || config.title || '' +- if (is_archive()) pageTitle = _p('page.archives') +- if (is_tag()) pageTitle = _p('page.tag') + ': ' + page.tag +- if (is_category()) pageTitle = _p('page.category') + ': ' + page.category +- if (is_month()) pageTitle += ': ' + page.month + '/' + page.year +- if (is_year()) pageTitle += ': ' + page.year +- var isSubtitle = config.subtitle ? ' - ' + config.subtitle : '' +- var tabTitle = is_home() || !pageTitle ? config.title + isSubtitle : pageTitle + ' | ' + config.title +- pageTitle ? '' : pageTitle = config.title || '' -- var without_index = url.replace('index.html', '') -- var without_html = without_index.replace('.html', '') +- var pageDescription = page.description || page.title || config.description +- var pageKeywords = Array.isArray(config.keywords) ? (config.keywords).join(','): ([]).join(',') || config.keywords +- if (page.tags && page.tags.data) pageKeywords = page.tags.data.map(function(tag) {return tag.name;}).join(',') +- var pageAuthor = config.email ? config.author + ',' + config.email : config.author +- var pageCopyright = config.copyright || config.author +- var without_html = url.replace('index.html', '') -//- 預解析 -include ./head/dns_prefetch.pug - -//- PWA -if (theme.pwa && theme.pwa.enable) - include ./head/pwa.pug - -//- 網站驗證 -include ./head/site_verification.pug - -//- Open_Graph -include ./head/Open_Graph.pug +meta(charset='UTF-8') +meta(http-equiv="X-UA-Compatible" content="IE=edge") +meta(name="viewport" content="width=device-width,initial-scale=1") +title= tabTitle +meta(name="description" content=pageDescription) +if pageKeywords + meta(name="keywords" content=pageKeywords) +meta(name="author" content=pageAuthor) +meta(name="copyright" content=pageCopyright) +meta(name ="format-detection" content="telephone=no") +!=favicon_tag(theme.favicon || config.favicon) if theme.disable_baidu_transformation meta(http-equiv="Cache-Control" content="no-transform") @@ -34,14 +34,35 @@ if theme.disable_baidu_transformation if page.hide == true meta(name="robots" content="noindex") +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/dns_prefetch', {}, {cache:theme.fragment_cache}) + +//- 網站驗證 +!=partial('includes/head/site_verification', {}, {cache:theme.fragment_cache}) + +//- Open_Graph +include ./head/Open_Graph.pug + +//- PWA +if (theme.pwa && theme.pwa.enable) + !=partial('includes/head/pwa', {}, {cache:theme.fragment_cache}) + script(src=url_for(theme.CDN.js_cookies)) -if (theme.darkmode && theme.darkmode.enable) || theme.autoChangeMode !== false - include ./head/darkmode.pug +if theme.darkmode.enable + !=partial('includes/head/darkmode', {}, {cache:theme.fragment_cache}) each item in theme.CDN_USE.css link(rel='stylesheet', href=url_for(item)) +if theme.fontawesome_v5 && theme.fontawesome_v5.enable + link(rel='stylesheet', href=url_for(theme.CDN.fontawesome_v5)) +else + link(rel='stylesheet', href=url_for(theme.CDN.fontawesome_v4)) + if (theme.fancybox && theme.fancybox.enable) link(rel='stylesheet', href=url_for(theme.CDN.fancybox_css)) @@ -61,19 +82,18 @@ if theme.algolia_search.enable link(rel="stylesheet" type="text/css" href=url_for(theme.CDN.algolia_search_css)) script(src=url_for(theme.CDN.algolia_search) defer) -if (theme.gitalk && theme.gitalk.enable) - 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)) +//- comment css +include ./head/comment.pug //- google_adsense -include ./head/google_adsense.pug +!=partial('includes/head/google_adsense', {}, {cache:theme.fragment_cache}) //- analytics -include ./head/analytics.pug - -if !is_post() - link(rel="preload" href=url_for(top_img) as="image" ) +!=partial('includes/head/analytics', {}, {cache:theme.fragment_cache}) if theme.blog_title_font.font_link - link(rel='stylesheet', href=url_for(theme.blog_title_font.font_link)) \ No newline at end of file + link(rel='stylesheet', href=url_for(theme.blog_title_font.font_link)) + +//- global config +!=partial('includes/head/config', {}, {cache:theme.fragment_cache}) +include ./head/config_site.pug diff --git a/layout/includes/head/Open_Graph.pug b/layout/includes/head/Open_Graph.pug index 54cecee..ff4a39b 100644 --- a/layout/includes/head/Open_Graph.pug +++ b/layout/includes/head/Open_Graph.pug @@ -1,19 +1,17 @@ -- var photo_check = is_post() ? page.cover || theme.avatar : theme.avatar -- var photo_link = url_check (photo_check) ? photo_check : config.url + photo_check - var contentType = is_post() ? 'article' : 'website' //- twitter meta if theme.twitter_meta meta(name="twitter:card" content="summary") - meta(name="twitter:title" content=pageTitle_no_include_blog_name) + meta(name="twitter:title" content=pageTitle) meta(name="twitter:description" content=pageDescription) - meta(name="twitter:image" content=photo_link) + meta(name="twitter:image" content=full_url_for(page.cover || theme.avatar.img)) //- Open_Graph if theme.Open_Graph_meta meta(property="og:type" content=contentType) - meta(property="og:title" content=pageTitle_no_include_blog_name) + meta(property="og:title" content=pageTitle) meta(property="og:url" content=without_html) meta(property="og:site_name" content=config.title) meta(property="og:description" content=pageDescription) - meta(property="og:image" content=photo_link) + meta(property="og:image" content=full_url_for(page.cover || theme.avatar.img)) diff --git a/layout/includes/head/analytics.pug b/layout/includes/head/analytics.pug index a0115f4..768b3e6 100644 --- a/layout/includes/head/analytics.pug +++ b/layout/includes/head/analytics.pug @@ -19,4 +19,4 @@ if theme.google_analytics ga('send', 'pageview'); 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") diff --git a/layout/includes/head/comment.pug b/layout/includes/head/comment.pug new file mode 100644 index 0000000..91d5cf0 --- /dev/null +++ b/layout/includes/head/comment.pug @@ -0,0 +1,8 @@ +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/config.pug b/layout/includes/head/config.pug similarity index 90% rename from layout/includes/config.pug rename to layout/includes/head/config.pug index 3bd7bb7..88a8633 100644 --- a/layout/includes/config.pug +++ b/layout/includes/head/config.pug @@ -76,12 +76,14 @@ }) } + var highlightCopy = theme.highlight_copy + var highlightLang = theme.highlight_lang + var highlightShrink = theme.highlight_shrink var runtime = theme.runtimeshow.enable var fancybox = theme.fancybox.enable var medium_zoom = theme.medium_zoom.enable var baiduPush = theme.baidu_push && theme.baidu_push.enable - var isHome = is_home() ? true : false - var isPost = is_post() ? true : false + var isFontAwesomeV5 = theme.fontawesome_v5 && theme.fontawesome_v5.enable script. @@ -108,8 +110,10 @@ script. fancybox: !{fancybox}, Snackbar: !{Snackbar}, baiduPush: !{baiduPush}, - isHome: !{isHome}, - isPost: !{isPost} + highlightCopy: !{highlightCopy}, + highlightLang: !{highlightLang}, + highlightShrink: !{highlightShrink}, + isFontAwesomeV5: !{isFontAwesomeV5} } diff --git a/layout/includes/head/config_site.pug b/layout/includes/head/config_site.pug new file mode 100644 index 0000000..1e5ed9e --- /dev/null +++ b/layout/includes/head/config_site.pug @@ -0,0 +1,6 @@ +script. + var GLOBAL_CONFIG_SITE = { + isPost: !{is_post()}, + isHome: !{is_home()} + } + diff --git a/layout/includes/head/darkmode.pug b/layout/includes/head/darkmode.pug index 72b1f16..e6adeab 100644 --- a/layout/includes/head/darkmode.pug +++ b/layout/includes/head/darkmode.pug @@ -1,25 +1,24 @@ script. - const autoChangeMode = '#{theme.autoChangeMode}' - var t = Cookies.get("theme"); + const autoChangeMode = '#{theme.darkmode.autoChangeMode}' + var t = Cookies.get("theme") if (autoChangeMode == '1'){ - const isDarkMode = window.matchMedia("(prefers-color-scheme: dark)").matches - const isLightMode = window.matchMedia("(prefers-color-scheme: light)").matches - const isNotSpecified = window.matchMedia("(prefers-color-scheme: no-preference)").matches - const hasNoSupport = !isDarkMode && !isLightMode && !isNotSpecified - - if (t === undefined){ - if (isLightMode) activateLightMode() - else if (isDarkMode) activateDarkMode() - else if (isNotSpecified || hasNoSupport){ - console.log('You specified no preference for a color scheme or your browser does not support it. I Schedule dark mode during night time.') - now = new Date(); - hour = now.getHours(); - isNight = hour < 6 || hour >= 18 - isNight ? activateDarkMode() : activateLightMode() - } - } else if (t == 'light') activateLightMode() - else activateDarkMode() + const isDarkMode = window.matchMedia("(prefers-color-scheme: dark)").matches + const isLightMode = window.matchMedia("(prefers-color-scheme: light)").matches + const isNotSpecified = window.matchMedia("(prefers-color-scheme: no-preference)").matches + const hasNoSupport = !isDarkMode && !isLightMode && !isNotSpecified + if (t === undefined){ + if (isLightMode) activateLightMode() + else if (isDarkMode) activateDarkMode() + else if (isNotSpecified || hasNoSupport){ + console.log('You specified no preference for a color scheme or your browser does not support it. I Schedule dark mode during night time.') + now = new Date(); + hour = now.getHours(); + isNight = hour < 6 || hour >= 18 + isNight ? activateDarkMode() : activateLightMode() + } + } else if (t == 'light') activateLightMode() + else activateDarkMode() } else if (autoChangeMode == '2'){ now = new Date(); diff --git a/layout/includes/header.pug b/layout/includes/header.pug deleted file mode 100644 index 28458d4..0000000 --- a/layout/includes/header.pug +++ /dev/null @@ -1,16 +0,0 @@ -header - #page-header - span#blog_name.pull_left - a#site-name.blog_title(href=url_for('/')) #[=config.title] - span.toggle-menu.pull_right.close - a.site-page - i.fa.fa-bars.fa-fw(aria-hidden="true") - span.pull_right.menus - .menus_items - include menu_item.pug - - if (theme.algolia_search.enable || theme.local_search && theme.local_search.enable) - span#search_button.pull_right - a.site-page.social-icon.search - i.fa.fa-search.fa-fw - span=' '+_p('search') diff --git a/layout/includes/header/header.pug b/layout/includes/header/header.pug new file mode 100644 index 0000000..9346dd0 --- /dev/null +++ b/layout/includes/header/header.pug @@ -0,0 +1,15 @@ +#page-header + span#blog_name.pull_left + a#site-name.blog_title(href=url_for('/')) #[=config.title] + span.toggle-menu.pull_right.close + a.site-page + i.fa.fa-bars.fa-fw(aria-hidden="true") + span.pull_right.menus + .menus_items + include ./menu_item.pug + + if (theme.algolia_search.enable || theme.local_search && theme.local_search.enable) + span#search_button.pull_right + a.site-page.social-icon.search + i.fa.fa-search.fa-fw + span=' '+_p('search') diff --git a/layout/includes/header/index.pug b/layout/includes/header/index.pug new file mode 100644 index 0000000..b3c9d9d --- /dev/null +++ b/layout/includes/header/index.pug @@ -0,0 +1,45 @@ +if is_home() + - var top_img = theme.index_img || theme.default_top_img +else if is_post() + - var top_img = page.top_img || page.cover || page.randomcover || theme.default_top_img +else if is_archive() + - var top_img = theme.archive_img || theme.default_top_img +else if is_tag() + - var top_img = theme.tag_img || theme.default_top_img +else if is_category() + - var top_img = theme.category_img || theme.default_top_img +else + - var top_img = page.top_img || theme.default_top_img + +if theme.douban + if is_current('/movies/', [strict]) + - var top_img = theme.douban.movies_img || theme.default_top_img + else if is_current('/books/', [strict]) + - var top_img = theme.douban.books_img || theme.default_top_img + else if is_current('/games/', [strict]) + - var top_img = theme.douban.games_img || theme.default_top_img + +- var bg_img = top_img && top_img !== true ? `background-image: url(${top_img})` : '' +- var site_title = is_archive() ? _p('page.archives') : page.title || page.tag || page.category || config.title +- var isHomeClass = is_home() ? 'full_page' : 'not-index-bg' +- is_post() ? isHomeClass = 'post-bg' : isHomeClass + +#nav(class=isHomeClass style=bg_img) + !=partial('includes/header/header', {}, {cache:theme.fragment_cache}) + if is_home() + #site-info + h1#site_title=site_title + #site_subtitle + span#subtitle + if(theme.social) + #site_social_icons + each url, icon in theme.social + a.social-icon(href=url target="_blank") + i(class=icon aria-hidden="true") + #scroll_down + i.fa.fa-angle-down.scroll-down-effects + else if is_post() + include ./post-info.pug + else + #page_site-info + h1#site_title=site_title diff --git a/layout/includes/menu_item.pug b/layout/includes/header/menu_item.pug similarity index 100% rename from layout/includes/menu_item.pug rename to layout/includes/header/menu_item.pug diff --git a/layout/includes/header/post-info.pug b/layout/includes/header/post-info.pug new file mode 100644 index 0000000..86629b2 --- /dev/null +++ b/layout/includes/header/post-info.pug @@ -0,0 +1,65 @@ +#post-info + #post-title + .posttitle= page.title || _p('no_title') + #post-meta + if (theme.post_meta.post.date_type) + if (theme.post_meta.post.date_type === 'both') + time.post-meta__date + i.fa.fa-calendar.fa-fw(aria-hidden="true") + =' '+_p('post.created')+' '+date(page.date, config.date_format) + span.post-meta__separator | + i.fa.fa-history.fa-fw(aria-hidden="true") + =' '+_p('post.updated')+' '+date(page.updated, config.date_format) + else + - var date_type = theme.post_meta.post.date_type === 'updated' ? 'updated' : 'date' + time.post-meta__date #[i.fa.fa-calendar.fa-fw(aria-hidden="true")] #[=date(page[date_type], config.date_format)] + + if (theme.post_meta.post.categories && page.categories.data.length > 0) + if (theme.post_meta.post.date_type) + span.post-meta__separator | + span + each item, index in page.categories.data + i.fa.fa-inbox.post-meta__icon.fa-fw(aria-hidden="true") + a(href=url_for(item.path)).post-meta__categories #[=item.name] + if (index < page.categories.data.length - 1) + i.fa.fa-angle-right.fa-fw(aria-hidden="true") + .post-meta-wordcount + if (theme.wordcount && theme.wordcount.enable) + - var wordCountIcon = theme.fontawesome_v5 && theme.fontawesome_v5.enable ? 'far fa-file-word' : 'fa fa-file-word-o' + i.post-meta__icon.fa-fw(class=wordCountIcon aria-hidden="true") + span= _p('post.wordcount') + ':' + span.word-count= wordcount(page.content) + span.post-meta__separator | + - var readCountIcon = theme.fontawesome_v5 && theme.fontawesome_v5.enable ? 'far fa-clock' : 'fa fa-clock-o' + i.post-meta__icon.fa-fw(class=readCountIcon aria-hidden="true") + span= _p('post.min2read', min2read(page.content, {cn: 350, en: 160})) + .post-meta-pv-cv + if (theme.wordcount && theme.wordcount.enable && theme.busuanzi.page_pv) + span.post-meta__separator | + if theme.busuanzi.page_pv + i.fa.fa-eye.post-meta__icon.fa-fw(aria-hidden="true") + span=_p('post.page_pv') + ':' + span#busuanzi_value_page_pv + + - var commentCount = theme.fontawesome_v5 && theme.fontawesome_v5.enable ? 'far fa-comments' : 'fa fa-comment-o' + if ((theme.disqus && theme.disqus.enable && theme.disqus.count && page.comments !== false) || (theme.disqusjs && theme.disqusjs.enable && theme.disqusjs.count && page.comments !== false)) + if (theme.busuanzi && theme.busuanzi.page_pv) + span.post-meta__separator | + i.post-meta__icon.fa-fw(class=commentCount aria-hidden="true") + span= _p('post.comments') + ':' + span.disqus-comment-count.comment-count + a(href=full_url_for(page.path) + '#disqus_thread') + if (theme.valine && theme.valine.enable && theme.valine.count && page.comments !== false) + if (theme.busuanzi && theme.busuanzi.page_pv) + span.post-meta__separator | + i.post-meta__icon.fa-fw(class=commentCount aria-hidden="true") + 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") + if (theme.gitalk && theme.gitalk.enable && theme.gitalk.count && page.comments !== false) + if (theme.busuanzi && theme.busuanzi.page_pv) + span.post-meta__separator | + i.post-meta__icon.fa-fw(class=commentCount aria-hidden="true") + span= _p('post.comments') + ':' + a(href=url_for(page.path) + '#post-comment') + span.gitalk-comment-count.comment-count diff --git a/layout/includes/index-js.pug b/layout/includes/index-js.pug index 9c75317..cdbb734 100644 --- a/layout/includes/index-js.pug +++ b/layout/includes/index-js.pug @@ -1,90 +1,116 @@ if theme.subtitle.enable - script(src=url_for(theme.CDN.typed)) - - var source = theme.subtitle.source + - let source = theme.subtitle.source + - let subtitleEffect = theme.subtitle.effect - if source == '1' || source == '2' - script(src="https://cdn.jsdelivr.net/npm/bluebird@3/js/browser/bluebird.min.js") - script(src="https://cdn.jsdelivr.net/npm/whatwg-fetch@2.0.3/fetch.min.js") + if subtitleEffect + script(src=url_for(theme.CDN.typed)) if source == '1' script. + let subtitleEffect = !{subtitleEffect} fetch('https://api.ooopn.com/ciba/api.php',) .then(function (res){ return res.json(); }) .then(function (data) { - var sub = '!{theme.subtitle.sub}'.length == 0 ? new Array() : '!{theme.subtitle.sub}'.split(","); - var both = sub.unshift(data['ciba-en'],data.ciba) - var typed = new Typed(".subtitle", { - strings: sub, - startDelay: 300, - typeSpeed: 100, - loop: true, - backSpeed: 50 - }); + if (subtitleEffect){ + let sub = '!{theme.subtitle.sub}'.length == 0 ? new Array() : '!{theme.subtitle.sub}'.split(","); + let both = sub.unshift(data['ciba-en'],data.ciba) + let typed = new Typed("#subtitle", { + strings: sub, + startDelay: 300, + typeSpeed: 150, + loop: !{theme.subtitle.loop}, + backSpeed: 50 + }); + }else{ + document.getElementById("subtitle").innerHTML = data['ciba-en'] + } }) .catch(function (err) { console.error(err); }) + else if source == '2' script. + let subtitleEffect = !{subtitleEffect} fetch('https://v1.hitokoto.cn') .then(function (res){ return res.json(); }) .then(function (data) { - var sub = '!{theme.subtitle.sub}'.length == 0 ? new Array() : '!{theme.subtitle.sub}'.split(","); - var both = sub.unshift(data.hitokoto) - var typed = new Typed(".subtitle", { - strings: sub, - startDelay: 300, - typeSpeed: 100, - loop: true, - backSpeed: 50 - }); + if (subtitleEffect){ + let from = '出自 ' + data.from + let sub = '!{theme.subtitle.sub}'.length == 0 ? new Array() : '!{theme.subtitle.sub}'.split(","); + let both = sub.unshift(data.hitokoto,from) + let 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); }) + else if source == "3" script(type="text/javascript" src="http://yijuzhan.com/api/word.php?m=js") script. - var con = str[0]; - var author = "出自 " + str[1]; - var sub = '!{theme.subtitle.sub}'.length == 0 ? new Array() : '!{theme.subtitle.sub}'.split(","); - var both = sub.unshift(con,author) - var typed = new Typed(".subtitle", { - strings: sub, - startDelay: 300, - typeSpeed: 100, - loop: true, - backSpeed: 50 - }); + let subtitleEffect = !{subtitleEffect} + let con = str[0]; + if (subtitleEffect){ + let from = "出自 " + str[1]; + let sub = '!{theme.subtitle.sub}'.length == 0 ? new Array() : '!{theme.subtitle.sub}'.split(","); + let both = sub.unshift(con,from) + let typed = new Typed("#subtitle", { + strings: sub, + startDelay: 300, + typeSpeed: 150, + loop: !{theme.subtitle.loop}, + backSpeed: 50 + }); + }else{ + document.getElementById("subtitle").innerHTML = con + } + else if source == '4' script(type="text/javascript" src="https://sdk.jinrishici.com/v2/browser/jinrishici.js" charset="utf-8") script. + let subtitleEffect = !{subtitleEffect} jinrishici.load(function(result) { - 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: 100, - loop: true, - backSpeed: 50 - }); + if (subtitleEffect){ + let sub = '!{theme.subtitle.sub}'.length == 0 ? new Array() : '!{theme.subtitle.sub}'.split(","); + let content = result.data.content; + let both = sub.unshift(content) + let typed = new Typed("#subtitle", { + strings: sub, + startDelay: 300, + typeSpeed: 150, + loop: !{theme.subtitle.loop}, + backSpeed: 50 + }); + }else{ + document.getElementById("subtitle").innerHTML = result.data.content + } }) - + else + - var subtitle = theme.subtitle.sub[0] script. - var typed = new Typed(".subtitle", { - strings: '!{theme.subtitle.sub}'.split(","), - startDelay: 300, - typeSpeed: 100, - loop: true, - backSpeed: 50 - }); - - - + let subtitleEffect = !{subtitleEffect} + if (subtitleEffect){ + let typed = new Typed("#subtitle", { + strings: '!{theme.subtitle.sub}'.split(","), + startDelay: 300, + typeSpeed: 150, + loop: !{theme.subtitle.loop}, + backSpeed: 50 + }) + }else{ + document.getElementById("subtitle").innerHTML = '!{subtitle}' + } diff --git a/layout/includes/layout.pug b/layout/includes/layout.pug index 5c8cb3f..a56961d 100644 --- a/layout/includes/layout.pug +++ b/layout/includes/layout.pug @@ -1,85 +1,46 @@ - -- var pageTitle = page.title || config.subtitle || '' -- if (is_archive()) pageTitle = _p('page.archives') -- if (is_tag()) pageTitle = _p('page.tag') + ': ' + page.tag -- if (is_category()) pageTitle = _p('page.category') + ': ' + page.category -- if (is_month()) pageTitle += ': ' + page.month + '/' + page.year -- if (is_year()) pageTitle += ': ' + page.year -- var pageTitle_saved //- 暫時存儲pageTitle -- var pageTitle_no_include_blog_name //- 存儲pageTitle, 不帶 " | ",meta用 -- var home_subtitle_true //有subtitle -//- home時顯示config.title (JerryC),其他顯示 pageTitle。meta用 -- is_home() ? pageTitle_no_include_blog_name = config.title : pageTitle_no_include_blog_name = pageTitle -//- 暫時存儲pageTitle -- pageTitle ? pageTitle_saved = pageTitle + ' | ' + config.title : pageTitle_saved = config.title -//- 是否有 config.subtitle 是各自显示 -- config.subtitle ? home_subtitle_true = ' - ' + config.subtitle : home_subtitle_true = '' -//- home時pageTitle顯示 JerryC - subtitle,其他顯示 pageTitle | JerryC -- is_home() ? pageTitle = config.title + home_subtitle_true : pageTitle = pageTitle_saved -//- 判断keywords - -- var pageDescription = page.description || page.title || config.description -- var pageKeywords = Array.isArray(config.keywords) ? (config.keywords).join(','): ([]).join(',') || config.keywords -- if (page.tags && page.tags.data) pageKeywords = page.tags.data.map(function(tag) {return tag.name;}).join(',') -- var pageAuthor = config.email ? config.author + ',' + config.email : config.author -- var pageCopyright = config.copyright || config.author +- var hideAside = !theme.aside.enable || page.aside === false ? 'hide-aside' : '' +- var autoOpenSidebar = theme.auto_open_sidebar.enable === true ? 'on' : '' doctype html html(lang=config.language data-theme=theme.display_mode) head - meta(charset='UTF-8') - meta(http-equiv="X-UA-Compatible" content="IE=edge") - meta(name="viewport" content="width=device-width, initial-scale=1, maximum-scale=5") - title= pageTitle - meta(name="description" content=pageDescription) - if pageKeywords - meta(name="keywords" content=pageKeywords) - meta(name="author" content=pageAuthor) - meta(name="copyright" content=pageCopyright) - meta(name ="format-detection" content="telephone=no") - !=favicon_tag(config.favicon || theme.favicon || '/favicon.ico') include ./head.pug - include ./config.pug body if theme.fireworks && theme.fireworks.enable canvas.fireworks - //- !=partial('includes/header.pug', {}, {cache: true}) - include ./header.pug - include ./mobile-sidebar.pug + !=partial('includes/mobile-sidebar/index', {}, {cache:theme.fragment_cache}) + if (is_post() && page.toc != false && theme.toc.enable) + i.fa.fa-arrow-right#toggle-sidebar(aria-hidden="true" class=autoOpenSidebar) + include ./sidebar.pug #body-wrap if theme.background - - var source = theme.background - - var is_photo = source.substring(3,0) === 'url' ? 'photo':'color' + - var is_photo = theme.background.substring(3,0) === 'url' ? 'photo':'color' #web_bg(data-type=is_photo) - if (is_post() && page.toc != false && theme.toc.enable) - i.fa.fa-arrow-right#toggle-sidebar(aria-hidden="true") - include ./sidebar.pug + include ./header/index.pug + if (!is_post()) - include ./nav.pug - main#content-outer - block top_img - if (!is_post()) - #content-inner.layout_page - if body - div!= body - else - block content - else - #content-inner.layout.layout_post - if body - div!= body - else - block content + main#content-inner.layout_page(class=hideAside) + if body + div!= body + else + block content + include widget/index.pug + else + main#content-inner.layout_post + if body + div!= body + else + block content - var footer_bg = theme.footer_bg == false ? '' : bg_img - var is_bg = theme.footer_bg == false ? 'color' : 'photo' footer#footer(style=footer_bg data-type=is_bg) - include ./footer.pug + !=partial('includes/footer', {}, {cache:theme.fragment_cache}) include ./rightside.pug + !=partial('includes/search/index', {}, {cache:theme.fragment_cache}) each item in theme.CDN_USE.js script(src=url_for(item)) include ./additional-js.pug - include ./search/index.pug diff --git a/layout/includes/math/mermaid.pug b/layout/includes/math/mermaid.pug new file mode 100644 index 0000000..7984358 --- /dev/null +++ b/layout/includes/math/mermaid.pug @@ -0,0 +1,8 @@ +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/UI.pug b/layout/includes/mixins/UI.pug index 9b71751..6292c82 100644 --- a/layout/includes/mixins/UI.pug +++ b/layout/includes/mixins/UI.pug @@ -1,36 +1,48 @@ mixin UI_NEW(posts) - posts.each(function(article,index){ - .recent-post-item.article-container + .recent-post-item - var link = article.link || article.path - if index%2 == 0 - .post_cover.left_radius - a(href=url_for(link) title=article.title || _p('no_title')) - - var post_cover = article.cover - if theme.lazyload.enable - img.post_bg.lazyload(data-src=`${post_cover}` onerror=`onerror=null;src='${theme.lodding_bg.post_page}'`) - else - img.post_bg(src=`${post_cover}` onerror=`onerror=null;src='${theme.lodding_bg.post_page}'`) - else - .post_cover.right_radius - a(href=url_for(link) title=article.title || _p('no_title')) - - var post_cover = article.cover - if theme.lazyload.enable - img.post_bg.lazyload(data-src=`${post_cover}` onerror=`onerror=null;src='${theme.lodding_bg.post_page}'`) - else - img.post_bg(src=`${post_cover}` onerror=`onerror=null;src='${theme.lodding_bg.post_page}'`) - .recent-post-info - a.article-title(href=url_for(link) title= article.title || _p('no_title'))= article.title || _p('no_title') - if (theme.post_meta.date_type) - - var date_type = theme.post_meta.date_type == 'updated' ? 'updated' : 'date' - time.post-meta__date #[i.fa.fa-calendar(aria-hidden="true")] #[=date(article[date_type], config.date_format)] - if (theme.post_meta.categories && article.categories.data.length > 0) - span.article-meta - span.article-meta__separator | - each item, index in article.categories.data - i.fa.fa-inbox.article-meta__icon(aria-hidden="true") - a(href=url_for(item.path)).article-meta__categories #[=item.name] - if (index < article.categories.data.length - 1) - i.fa.fa-angle-right(aria-hidden="true") + - var post_cover = article.cover + - var title = article.title || _p('no_title') + - var leftOrRight = index%2 == 0 ? 'left_radius' : 'right_radius' + - var 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.lazyload(data-src=`${post_cover}` alt=title onerror=`this.onerror=null;this.src='`+ url_for(theme.lodding_bg.post_page) + `'`) + else + img.post_bg(src=`${post_cover}` alt=title onerror=`this.onerror=null;this.src='`+ url_for(theme.lodding_bg.post_page) + `'`) + .recent-post-info(class=no_cover) + a.article-title(href=url_for(link) title=title)= title + .article-meta-wrap + if (theme.post_meta.page.date_type) + if (theme.post_meta.page.date_type === 'both') + time.post-meta__date + i.fa.fa-calendar.fa-fw(aria-hidden="true") + =date(page.date, config.date_format) + span.article-meta__separator | + i.fa.fa-history.fa-fw(aria-hidden="true") + =date(page.updated, config.date_format) + else + - var date_type = theme.post_meta.post.date_type === 'updated' ? 'updated' : 'date' + time.post-meta__date #[i.fa.fa-calendar.fa-fw(aria-hidden="true")]#[=date(page[date_type], config.date_format)] + if (theme.post_meta.page.categories && article.categories.data.length > 0) + span.article-meta + span.article-meta__separator | + each item, index in article.categories.data + i.fa.fa-inbox.article-meta__icon(aria-hidden="true") + a(href=url_for(item.path)).article-meta__categories #[=item.name] + if (index < article.categories.data.length - 1) + i.fa.fa-angle-right(aria-hidden="true") + if (theme.post_meta.page.tags && article.tags.data.length > 0) + span.article-meta.tags + span.article-meta__separator | + each item, index in article.tags.data + i.fa.fa-tag.article-meta__icon(aria-hidden="true") + a(href=url_for(item.path)).article-meta__tags #[=item.name] + if (index < article.tags.data.length - 1) + span.article-meta__link - if theme.auto_excerpt && theme.auto_excerpt.enable - const content = strip_html(article.content) - let expert = content.substring(0, theme.auto_excerpt.length) diff --git a/layout/includes/mixins/article-sort.pug b/layout/includes/mixins/article-sort.pug index 9b534b3..41801d1 100644 --- a/layout/includes/mixins/article-sort.pug +++ b/layout/includes/mixins/article-sort.pug @@ -3,13 +3,15 @@ mixin articleSort(posts) - 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' : '' if tempYear !== year - year = tempYear .article-sort-item.year= year - .article-sort-item - .article-sort-img - a.article-sort-item__img(href=url_for(article.path)) - img(src=article.cover alt=article.title || 'No Title') + .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=article.cover alt=article.title || 'No Title' onerror=`this.onerror=null;this.src='`+ url_for(theme.lodding_bg.post_page) + `'`) .article-sort-post a.article-sort-item__post(href=url_for(article.path)) i.fa.fa-clock-o(aria-hidden="true") diff --git a/layout/includes/mobile-sidebar.pug b/layout/includes/mobile-sidebar.pug deleted file mode 100644 index 5900134..0000000 --- a/layout/includes/mobile-sidebar.pug +++ /dev/null @@ -1,46 +0,0 @@ -#mobile-sidebar - #menu_mask - #mobile-sidebar-menus - .mobile_author_icon - img.avatar-img(src=url_for(theme.avatar) onerror=`onerror=null;src='${theme.lodding_bg.flink}'` alt="avatar") - .mobile_post_data - if site.posts.length - .mobile_data_item.is-center - .mobile_data_link - a(href=url_for(config.archive_dir) + '/') - .headline= _p('aside.articles') - .length_num= site.posts.length - - if site.tags.length - .mobile_data_item.is-center - .mobile_data_link - a(href=url_for(config.tag_dir) + '/' ) - .headline= _p('aside.tags') - .length_num= site.tags.length - - if site.categories.length - .mobile_data_item.is-center - .mobile_data_link - a(href=url_for(config.category_dir) + '/') - .headline= _p('aside.categories') - .length_num= site.categories.length - hr - .menus_items - include menu_item.pug - - - - - const showToc = is_post() && page.toc != false && theme.toc.enable - - - let tocNumber - if (page.toc_number !== undefined) tocNumber = page.toc_number - else if (theme.toc.number !== undefined) tocNumber = theme.toc.number - else tocNumber = true - - - if (showToc) - #mobile-sidebar-toc - .toc_mobile_headline= _p('sidebar.catalog') - if (page.encrypt == true) - .sidebar-toc__content.toc-div-class(style="display:none")!=toc(page.origin,{"class":"toc_mobile_items",list_number:tocNumber}) - else - .sidebar-toc__content!=toc(page.content,{"class":"toc_mobile_items",list_number:tocNumber}) diff --git a/layout/includes/mobile-sidebar/index.pug b/layout/includes/mobile-sidebar/index.pug new file mode 100644 index 0000000..511a77c --- /dev/null +++ b/layout/includes/mobile-sidebar/index.pug @@ -0,0 +1,3 @@ +#mobile-sidebar + #menu_mask + include ../mobile-sidebar/mobile-menus.pug \ No newline at end of file diff --git a/layout/includes/mobile-sidebar/mobile-menus.pug b/layout/includes/mobile-sidebar/mobile-menus.pug new file mode 100644 index 0000000..55580ec --- /dev/null +++ b/layout/includes/mobile-sidebar/mobile-menus.pug @@ -0,0 +1,27 @@ +#mobile-sidebar-menus + .mobile_author_icon + img.avatar-img(src=url_for(theme.avatar.img) onerror=`onerror=null;src='${theme.lodding_bg.flink}'` alt="avatar") + .mobile_post_data + if site.posts.length + .mobile_data_item.is-center + .mobile_data_link + a(href=url_for(config.archive_dir) + '/') + .headline= _p('aside.articles') + .length_num= site.posts.length + + if site.tags.length + .mobile_data_item.is-center + .mobile_data_link + a(href=url_for(config.tag_dir) + '/' ) + .headline= _p('aside.tags') + .length_num= site.tags.length + + if site.categories.length + .mobile_data_item.is-center + .mobile_data_link + a(href=url_for(config.category_dir) + '/') + .headline= _p('aside.categories') + .length_num= site.categories.length + hr + .menus_items + include ../header/menu_item.pug diff --git a/layout/includes/nav.pug b/layout/includes/nav.pug deleted file mode 100644 index c720584..0000000 --- a/layout/includes/nav.pug +++ /dev/null @@ -1,29 +0,0 @@ - -- var bg_img = top_img && top_img !== true ? `background-image: url(${top_img})` : '' - - -if is_home() - nav#nav.full_page(style=bg_img) - #site-info - #site-title - span.blogtitle= page.title || page.tag || page.category || config.title - #site-sub-title - span.subtitle - - if(theme.social) - #site-social-icons - each url, icon in theme.social - a.social-icon(href=url target="_blank") - i(class=icon aria-hidden="true") - - .scroll-down - i.fa.fa-angle-down.scroll-down-effects - -else - nav#nav.not_index_bg(style=bg_img) - #page_site-info - #site-title - if (is_archive()) - span.blogtitle= _p('archives') - else - span.blogtitle= page.title || page.tag || page.category || config.title \ No newline at end of file diff --git a/layout/includes/page_tag.pug b/layout/includes/page_tag.pug deleted file mode 100644 index e779798..0000000 --- a/layout/includes/page_tag.pug +++ /dev/null @@ -1,6 +0,0 @@ -- site.tags.sort('path').each(function (tags){ - - var fontSize = Math.floor(Math.random() * 15 + 15) + "px"; //15 ~ 30 - - var color = "rgb(" + Math.floor(Math.random() * 201) + ", " + Math.floor(Math.random() * 201) +", " + Math.floor(Math.random() * 201) +")"; // 0,0,0 -> 200,200,200 - - a(href=url_for(tags.path) style='font-size:' + fontSize + ';color:' + color)=tags.name --}) \ No newline at end of file diff --git a/layout/includes/pagination.pug b/layout/includes/pagination.pug index faaf001..33bf9ae 100644 --- a/layout/includes/pagination.pug +++ b/layout/includes/pagination.pug @@ -13,51 +13,27 @@ if(!is_post()) else nav#pagination.pagination_post if(page.prev) - if(page.next) - .prev-post.pull_left - - var pagination_cover = page.prev.cover - a(href=url_for(page.prev.path)) - if theme.lazyload.enable - img.prev_cover.lazyload(data-src=`${pagination_cover}` onerror=`onerror=null;src='${theme.lodding_bg.post_page}'` ) - else - img.prev_cover(src=`${pagination_cover}` onerror=`onerror=null;src='${theme.lodding_bg.post_page}'` ) - + - var hasPageNext = page.prev ? 'pull_left' : 'pull-full' + .prev-post(class=hasPageNext) + - 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.lazyload(data-src=`${pagination_cover}` onerror=`onerror=null;src='${theme.lodding_bg.post_page}'` ) + else + img.prev_cover(src=`${pagination_cover}` onerror=`onerror=null;src='${theme.lodding_bg.post_page}'` ) + .pagination-info .label=_p('pagination.prev') - .prev_info - span=page.prev.title - else - .prev-post.pull-full - - var pagination_cover = page.prev.cover - a(href=url_for(page.prev.path)) - if theme.lazyload.enable - img.prev_cover.lazyload(data-src=`${pagination_cover}` onerror=`onerror=null;src='${theme.lodding_bg.post_page}'`) - else - img.prev_cover(src=`${pagination_cover}` onerror=`onerror=null;src='${theme.lodding_bg.post_page}'`) - .label=_p('pagination.prev') - .prev_info - span=page.prev.title + .prev_info=page.prev.title if(page.next) - if(page.prev) - .next-post.pull_right - - var pagination_cover = page.next.cover - a(href=url_for(page.next.path)) - if theme.lazyload.enable - img.next_cover.lazyload(data-src=`${pagination_cover}` onerror=`onerror=null;src='${theme.lodding_bg.post_page}'`) - else - img.next_cover(src=`${pagination_cover}` onerror=`onerror=null;src='${theme.lodding_bg.post_page}'`) + - var hasPagePrev = page.prev ? 'pull_right' : 'pull-full' + - var pagination_cover = page.next.cover == false ? page.next.randomcover : page.next.cover + .next-post(class=hasPagePrev) + a(href=url_for(page.next.path)) + if theme.lazyload.enable + img.next_cover.lazyload(data-src=`${pagination_cover}` onerror=`onerror=null;src='${theme.lodding_bg.post_page}'`) + else + img.next_cover(src=`${pagination_cover}` onerror=`onerror=null;src='${theme.lodding_bg.post_page}'`) + .pagination-info .label=_p('pagination.next') - .next_info - span=page.next.title - else - .next-post.pull-full - - var pagination_cover = page.next.cover - a(href=url_for(page.next.path)) - if theme.lazyload.enable - img.next_cover.lazyload(data-src=`${pagination_cover}` onerror=`onerror=null;src='${theme.lodding_bg.post_page}'`) - else - img.next_cover(src=`${pagination_cover}` onerror=`onerror=null;src='${theme.lodding_bg.post_page}'`) - .label=_p('pagination.next') - .next_info - span=page.next.title - + .next_info=page.next.title \ No newline at end of file diff --git a/layout/includes/post/post-copyright.pug b/layout/includes/post/post-copyright.pug new file mode 100644 index 0000000..ee8c659 --- /dev/null +++ b/layout/includes/post/post-copyright.pug @@ -0,0 +1,13 @@ +if (theme.post_copyright && theme.post_copyright.enable && page.copyright != false) + .post-copyright + .post-copyright__author + span.post-copyright-meta= _p('post.copyright.author') + ": " + span.post-copyright-info + a(href=`mailto:${config.email}`) #[=config.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 + .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) diff --git a/layout/includes/reward.pug b/layout/includes/post/reward.pug similarity index 100% rename from layout/includes/reward.pug rename to layout/includes/post/reward.pug diff --git a/layout/includes/recent-posts.pug b/layout/includes/recent-posts.pug index a5534a3..091bbd1 100644 --- a/layout/includes/recent-posts.pug +++ b/layout/includes/recent-posts.pug @@ -1,41 +1,52 @@ each article , index in page.posts.data - .recent-post-item.article-container + .recent-post-item - var link = article.link || article.path - var title = article.title || _p('no_title') - if index%2 == 0 - .post_cover.left_radius - a(href=url_for(link) title=title) - - var post_cover = article.cover - if theme.lazyload.enable - img.post_bg.lazyload(data-src=`${post_cover}` onerror=`this.onerror=null;this.src='`+ url_for(theme.lodding_bg.post_page) + `'` alt=title) - else - img.post_bg(src=`${post_cover}` onerror=`this.onerror=null;this.src='`+ url_for(theme.lodding_bg.post_page) + `'` alt=title) - else - .post_cover.right_radius - a(href=url_for(link) title=title) - - var post_cover = article.cover - if theme.lazyload.enable - img.post_bg.lazyload(data-src=`${post_cover}` onerror=`this.onerror=null;this.src='`+ url_for(theme.lodding_bg.post_page) + `'` alt=title) - else - img.post_bg(src=`${post_cover}` onerror=`this.onerror=null;this.src='`+ url_for(theme.lodding_bg.post_page) + `'` alt=title) - .recent-post-info + - 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' : '' + 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.lazyload(data-src=`${post_cover}` onerror=`this.onerror=null;this.src='`+ url_for(theme.lodding_bg.post_page) + `'` alt=title) + else + img.post_bg(src=`${post_cover}` onerror=`this.onerror=null;this.src='`+ url_for(theme.lodding_bg.post_page) + `'` alt=title) + .recent-post-info(class=no_cover) a.article-title(href=url_for(link) title=title)= title - if (article.top) - span.article-meta - i.fa.fa-thumb-tack.article-meta__icon.sticky - span.sticky= _p('sticky') - span.article-meta__separator(style="margin-right: 0.3rem") | - if (theme.post_meta.date_type) - - var date_type = theme.post_meta.date_type == 'updated' ? 'updated' : 'date' - time.post-meta__date #[i.fa.fa-calendar(aria-hidden="true")] #[=date(article[date_type], config.date_format)] - if (theme.post_meta.categories && article.categories.data.length > 0) - span.article-meta - span.article-meta__separator | - each item, index in article.categories.data - i.fa.fa-inbox.article-meta__icon(aria-hidden="true") - a(href=url_for(item.path)).article-meta__categories #[=item.name] - if (index < article.categories.data.length - 1) - i.fa.fa-angle-right(aria-hidden="true") + .article-meta-wrap + if (article.top) + span.article-meta + i.fa.fa-thumb-tack.article-meta__icon.sticky + span.sticky= _p('sticky') + span.article-meta__separator | + if (theme.post_meta.page.date_type) + if (theme.post_meta.page.date_type === 'both') + time.post-meta__date + i.fa.fa-calendar.fa-fw(aria-hidden="true") + =date(page.date, config.date_format) + span.article-meta__separator | + i.fa.fa-history.fa-fw(aria-hidden="true") + =date(page.updated, config.date_format) + else + - var date_type = theme.post_meta.post.date_type === 'updated' ? 'updated' : 'date' + time.post-meta__date #[i.fa.fa-calendar.fa-fw(aria-hidden="true")]#[=date(page[date_type], config.date_format)] + if (theme.post_meta.page.categories && article.categories.data.length > 0) + span.article-meta + span.article-meta__separator | + each item, index in article.categories.data + i.fa.fa-inbox.article-meta__icon(aria-hidden="true") + a(href=url_for(item.path)).article-meta__categories #[=item.name] + if (index < article.categories.data.length - 1) + i.fa.fa-angle-right(aria-hidden="true") + if (theme.post_meta.page.tags && article.tags.data.length > 0) + span.article-meta.tags + span.article-meta__separator | + each item, index in article.tags.data + i.fa.fa-tag.article-meta__icon(aria-hidden="true") + a(href=url_for(item.path)).article-meta__tags #[=item.name] + if (index < article.tags.data.length - 1) + span.article-meta__link - if theme.auto_excerpt && theme.auto_excerpt.enable - const content = strip_html(article.content) - let expert = content.substring(0, theme.auto_excerpt.length) diff --git a/layout/includes/rightside.pug b/layout/includes/rightside.pug index d7d5fa5..0c64a3e 100644 --- a/layout/includes/rightside.pug +++ b/layout/includes/rightside.pug @@ -7,13 +7,15 @@ section#rightside.rightside i#font_minus.fa.fa-minus(title=_p('rightside.font_minus_title')) if theme.translate && theme.translate.enable a#translateLink.translate_chn_to_cht(href="javascript:translatePage();" title=_p('rightside.translate_title') target="_self")= theme.translate.default - if theme.darkmode && theme.darkmode.enable - - var display_mode = theme.display_mode == 'dark' ? 'fa fa-sun-o' : 'fa fa-moon-o' + if theme.darkmode.enable && theme.darkmode.button + - var lightModeIcon = theme.fontawesome_v5 && theme.fontawesome_v5.enable ? 'far fa-sun' : 'fa fa-sun-o' + - var darkModeIcon = theme.fontawesome_v5 && theme.fontawesome_v5.enable ? 'far fa-moon' : 'fa fa-moon-o' + - var display_mode = theme.display_mode == 'dark' ? lightModeIcon : darkModeIcon i#darkmode.darkmode(class=display_mode title=_p('rightside.night_mode_title')) #rightside-config-show #rightside_config(title=_p("rightside.setting")) i.fa.fa-cog(aria-hidden="true") - if is_post() && page.comments !== false && (d || l || gt || v) + if is_post() && page.comments !== false && isComment a#to_comment(href="#post-comment" title=_p("rightside.scroll_to_comment")) i.scroll_to_comment.fa.fa-comments if is_post() && page.toc != false && theme.toc.enable diff --git a/layout/includes/search/local-search.pug b/layout/includes/search/local-search.pug index 464e8c3..1262d55 100644 --- a/layout/includes/search/local-search.pug +++ b/layout/includes/search/local-search.pug @@ -3,7 +3,7 @@ #local-input-panel #local-search-input .local-search-box - input(placeholder=_p("local_search.input_placeholder")).local-search-box--input + input(placeholder=_p("local_search.input_placeholder") type="text").local-search-box--input hr #local-search-results #local-hits diff --git a/layout/includes/share/share-js.pug b/layout/includes/share/share-js.pug index 9f78e7b..ec12a88 100644 --- a/layout/includes/share/share-js.pug +++ b/layout/includes/share/share-js.pug @@ -1,4 +1,4 @@ if (theme.sharejs && theme.sharejs.enable) - .social-share(data-image= page.cover|| theme.avatar data-sites= theme.sharejs.sites) + .social-share(data-image= 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 58b61a9..ac6d5be 100644 --- a/layout/includes/sidebar.pug +++ b/layout/includes/sidebar.pug @@ -1,7 +1,4 @@ - -- var sidebar_class = theme.auto_open_sidebar.enable === true ? 'auto_open' : '' - -#sidebar(class=sidebar_class) +#sidebar - const showToc = is_post() && page.toc != false && theme.toc.enable - let tocNumber diff --git a/layout/includes/third-party/canvas-ribbon.pug b/layout/includes/third-party/canvas-ribbon.pug index b6e1806..9fc03fc 100644 --- a/layout/includes/third-party/canvas-ribbon.pug +++ b/layout/includes/third-party/canvas-ribbon.pug @@ -1,3 +1,3 @@ -script(id="ribbon" src=url_for(theme.CDN.canvas_ribbon) size=theme.canvas_ribbon.size +script(defer id="ribbon" src=url_for(theme.CDN.canvas_ribbon) size=theme.canvas_ribbon.size alpha=theme.canvas_ribbon.alpha zIndex=theme.canvas_ribbon.zIndex mobile=`${theme.canvas_ribbon.mobile}` data-click=`${theme.canvas_ribbon.click_to_change}`) diff --git a/layout/includes/third-party/pangu.pug b/layout/includes/third-party/pangu.pug new file mode 100644 index 0000000..a3ff318 --- /dev/null +++ b/layout/includes/third-party/pangu.pug @@ -0,0 +1,13 @@ +script(src=url_for(theme.CDN.pangu)) +if theme.pangu.field === 'post' + if is_post() + script. + document.addEventListener('DOMContentLoaded', function() { + pangu.spacingElementById('content-inner') + }) +else if theme.pangu.field === 'page' + script. + document.addEventListener('DOMContentLoaded', function() { + pangu.spacingElementById('content-inner') + }) + diff --git a/layout/includes/widget/card_announcement.pug b/layout/includes/widget/card_announcement.pug index edcecd5..4194cf4 100644 --- a/layout/includes/widget/card_announcement.pug +++ b/layout/includes/widget/card_announcement.pug @@ -3,4 +3,4 @@ .item-headline i.fa.fa-bullhorn.card-announcement-animation(aria-hidden="true") span= _p('aside.card_announcement') - .announcement_content= theme.announcement.content \ No newline at end of file + .announcement_content!= theme.announcement.content \ No newline at end of file diff --git a/layout/includes/widget/card_author.pug b/layout/includes/widget/card_author.pug index f009bc8..426697d 100644 --- a/layout/includes/widget/card_author.pug +++ b/layout/includes/widget/card_author.pug @@ -1,26 +1,26 @@ .card-widget.card-info .card-content .card-info-avatar.is-center - img.avatar-img(src=url_for(theme.avatar) onerror=`this.onerror=null;this.src='` + url_for(theme.lodding_bg.flink) + `'` alt="avatar") + img.avatar-img(src=url_for(theme.avatar.img) onerror=`this.onerror=null;this.src='` + url_for(theme.lodding_bg.flink) + `'` alt="avatar") .author-info__name= config.author .author-info__description= config.description .card-info-data if site.posts.length .card-info-data-item.is-center - a(href=url_for(config.archive_dir) + '/') + a(href=url_for(config.archive_dir)) .headline= _p('aside.articles') .length_num= site.posts.length if site.tags.length .card-info-data-item.is-center - a(href=url_for(config.tag_dir) + '/' ) + a(href=url_for(config.tag_dir)) .headline= _p('aside.tags') .length_num= site.tags.length if site.categories.length .card-info-data-item.is-center - a(href=url_for(config.category_dir) + '/') + a(href=url_for(config.category_dir)) .headline= _p('aside.categories') .length_num= site.categories.length diff --git a/layout/includes/widget/card_recent_post.pug b/layout/includes/widget/card_recent_post.pug index 036837b..d82fa17 100644 --- a/layout/includes/widget/card_recent_post.pug +++ b/layout/includes/widget/card_recent_post.pug @@ -8,17 +8,20 @@ .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)) - - var post_cover = article.cover - .aside-post-cover - if theme.lazyload.enable - img.aside-post-bg.lazyload(data-src=`${post_cover}` onerror=`this.onerror=null;this.src='`+ url_for(theme.lodding_bg.post_page) + `'` title=title alt=title) - else - img.aside-post-bg(src=`${post_cover}` onerror=`this.onerror=null;this.src='`+ url_for(theme.lodding_bg.post_page) + `'` title=title alt=title) - .aside-post-title + if post_cover && theme.cover.aside_enable + .aside-post-cover + if theme.lazyload.enable + img.aside-post-bg.lazyload(data-src=`${post_cover}` onerror=`this.onerror=null;this.src='`+ url_for(theme.lodding_bg.post_page) + `'` title=title alt=title) + else + img.aside-post-bg(src=`${post_cover}` onerror=`this.onerror=null;this.src='`+ url_for(theme.lodding_bg.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') - if (theme.post_meta.date_type) - - var date_type = theme.post_meta.date_type == 'updated' ? 'updated' : 'date' + if (theme.post_meta.page.date_type) + - var date_type = theme.post_meta.page.date_type == 'updated' ? 'updated' : 'date' time.aside-post_meta.post-meta__date #[=date(article[date_type], config.date_format)] - }) diff --git a/layout/includes/widget/card_webinfo.pug b/layout/includes/widget/card_webinfo.pug index a72f5da..17903af 100644 --- a/layout/includes/widget/card_webinfo.pug +++ b/layout/includes/widget/card_webinfo.pug @@ -1,7 +1,8 @@ +- var webinfoIcon = theme.fontawesome_v5 && theme.fontawesome_v5.enable ? 'fas fa-chart-line' : 'fa fa-line-chart' .card-widget.card-webinfo .card-content .item-headline - i.fa.fa-line-chart(aria-hidden="true") + i(class=webinfoIcon aria-hidden="true") span= _p('aside.card_webinfo.headline') .webinfo .webinfo-item diff --git a/layout/includes/widget/index.pug b/layout/includes/widget/index.pug index ecceb98..1bd1b48 100644 --- a/layout/includes/widget/index.pug +++ b/layout/includes/widget/index.pug @@ -1,21 +1,17 @@ -if theme.aside.card_author - include ./card_author.pug - -if theme.aside.card_announcement - include ./card_announcement.pug - -if theme.aside.card_recent_post - include ./card_recent_post.pug - -if theme.aside.card_categories - include ./card_categories.pug - -if theme.aside.card_tags - include ./card_tags.pug - -if theme.aside.card_archives - include ./card_archives.pug - -if theme.aside.card_webinfo - include ./card_webinfo.pug - \ No newline at end of file +if theme.aside.enable + if page.aside !== false + #aside_content.aside_content + if theme.aside.card_author + !=partial('includes/widget/card_author', {}, {cache:theme.fragment_cache}) + if theme.aside.card_announcement + !=partial('includes/widget/card_announcement', {}, {cache:theme.fragment_cache}) + if theme.aside.card_recent_post + !=partial('includes/widget/card_recent_post', {}, {cache:theme.fragment_cache}) + if theme.aside.card_categories + !=partial('includes/widget/card_categories', {}, {cache:theme.fragment_cache}) + if theme.aside.card_tags + !=partial('includes/widget/card_tags', {}, {cache:theme.fragment_cache}) + if theme.aside.card_archives + !=partial('includes/widget/card_archives', {}, {cache:theme.fragment_cache}) + if theme.aside.card_webinfo + !=partial('includes/widget/card_webinfo', {}, {cache:theme.fragment_cache}) \ No newline at end of file diff --git a/layout/index.pug b/layout/index.pug index 094c7d4..36f6860 100644 --- a/layout/index.pug +++ b/layout/index.pug @@ -3,6 +3,4 @@ extends includes/layout.pug block content #recent-posts.recent-posts include includes/recent-posts.pug - include includes/pagination.pug - #aside_content.aside_content - include includes/widget/index.pug \ No newline at end of file + include includes/pagination.pug \ No newline at end of file diff --git a/layout/page-tags.pug b/layout/page-tags.pug new file mode 100644 index 0000000..47c569b --- /dev/null +++ b/layout/page-tags.pug @@ -0,0 +1,14 @@ +.tag-cloud + .tag-cloud__title= _p('page.tag') + | - + span.tag-cloud__amount= site.tags.length + .tag-cloud-tags + - site.tags.sort('path').each(function (tags){ + - var fontSize = Math.floor(Math.random() * 15 + 15) + "px"; //15 ~ 30 + - var color = "rgb(" + Math.floor(Math.random() * 201) + ", " + Math.floor(Math.random() * 201) +", " + Math.floor(Math.random() * 201) +")"; // 0,0,0 -> 200,200,200 + a(href=url_for(tags.path) style='font-size:' + fontSize + ';color:' + color)=tags.name + -}) + if page.comments !== false + include includes/comments/index.pug + + diff --git a/layout/page.pug b/layout/page.pug index a59ecf1..19411b1 100644 --- a/layout/page.pug +++ b/layout/page.pug @@ -2,25 +2,11 @@ extends includes/layout.pug block content if page.type === 'tags' - .tag-cloud - .tag-cloud__title= _p('page.tag') - | - - span.tag-cloud__amount= site.tags.length - .tag-cloud-tags - include includes/page_tag.pug - if page.comments !== false - include includes/comments/index.pug - #aside_content.aside_content - include includes/widget/index.pug - + include page-tags.pug else if page.type === 'link' include flink.pug - if page.comments !== false - include includes/comments/index.pug - #aside_content.aside_content - include includes/widget/index.pug else if page.type === 'categories' - #post-content.category-content + .category-content .category-lists .category__title= _p('page.category') | - @@ -28,14 +14,8 @@ block content div!= list_categories() if page.comments !== false include includes/comments/index.pug - #aside_content.aside_content - include includes/widget/index.pug else - article#page - h1= page.title - .article-container!= page.content - include includes/pagination.pug + #page + #article-container!= page.content if page.comments !== false - include includes/comments/index.pug - #aside_content.aside_content - include includes/widget/index.pug + include includes/comments/index.pug \ No newline at end of file diff --git a/layout/post.pug b/layout/post.pug index d82aa36..b76c765 100644 --- a/layout/post.pug +++ b/layout/post.pug @@ -1,102 +1,21 @@ extends includes/layout.pug -block top_img - - var top_img = page.top_img || page.cover || theme.post_meta.top_img || theme.default_top_img - - var bg_img = top_img !== true ? `background-image: url(${top_img})` : '' - div#top-container(style=bg_img) - #post-info - #post-title - .posttitle= page.title || _p('no_title') - #post-meta - if (theme.post_meta.date_type) - if (theme.post_meta.date_type === 'both') - time.post-meta__date - i.fa.fa-calendar.fa-fw(aria-hidden="true") - =' '+_p('post.created')+' '+date(page.date, config.date_format) - span.post-meta__separator | - i.fa.fa-history.fa-fw(aria-hidden="true") - =' '+_p('post.updated')+' '+date(page.updated, config.date_format) - else - - var date_type = theme.post_meta.date_type === 'updated' ? 'updated' : 'date' - time.post-meta__date #[i.fa.fa-calendar.fa-fw(aria-hidden="true")] #[=date(page[date_type], config.date_format)] - - if (theme.post_meta.categories && page.categories.data.length > 0) - if (theme.post_meta.date_type) - span.post-meta__separator | - span - each item, index in page.categories.data - i.fa.fa-inbox.post-meta__icon.fa-fw(aria-hidden="true") - a(href=url_for(item.path)).post-meta__categories #[=item.name] - if (index < page.categories.data.length - 1) - i.fa.fa-angle-right.fa-fw(aria-hidden="true") - .post-meta-wordcount - if (theme.wordcount && theme.wordcount.enable) - i.fa.fa-file-word-o.post-meta__icon.fa-fw(aria-hidden="true") - span= _p('post.wordcount') + ':' - span.word-count= wordcount(page.content) - span.post-meta__separator | - i.fa.fa-clock-o.post-meta__icon.fa-fw(aria-hidden="true") - span= _p('post.min2read', min2read(page.content, {cn: 350, en: 160})) - .post-meta-pv-cv - if (theme.wordcount && theme.wordcount.enable && theme.busuanzi.page_pv) - span.post-meta__separator | - if theme.busuanzi.page_pv - span - i.fa.fa-eye.post-meta__icon.fa-fw(aria-hidden="true") - =_p('post.page_pv') + ':' - span#busuanzi_value_page_pv - if (theme.disqus && theme.disqus.enable && theme.disqus.count && page.comments !== false) - if (theme.busuanzi && theme.busuanzi.page_pv) - span.post-meta__separator | - i.fa.fa-comment-o.post-meta__icon.fa-fw(aria-hidden="true") - span= _p('post.comments') + ':' - a(href=url_for(page.path) + '#post-comment') - span.disqus-comment-count(data-disqus-url=page.permalink) - if (theme.valine && theme.valine.enable && theme.valine.count && page.comments !== false) - if (theme.busuanzi && theme.busuanzi.page_pv) - span.post-meta__separator | - i.fa.fa-comments-o.post-meta__icon.fa-fw(aria-hidden="true") - 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") - if (theme.gitalk && theme.gitalk.enable && theme.gitalk.count && page.comments !== false) - if (theme.busuanzi && theme.busuanzi.page_pv) - span.post-meta__separator | - i.fa.fa-comments-o.post-meta__icon.fa-fw(aria-hidden="true") - span= _p('post.comments') + ':' - a(href=url_for(page.path) + '#post-comment') - span.gitalk-comment-count.comment-count - - block content article#post(class="") - #post-content.article-container!= page.content - if (theme.post_copyright && theme.post_copyright.enable && page.copyright != false) - .post-copyright - .post-copyright__author - span.post-copyright-meta= _p('post.copyright.author') + ": " - span.post-copyright-info - a(href=`mailto:${config.email}`) #[=config.author] - .post-copyright__type - span.post-copyright-meta= _p('post.copyright.link') + ": " - span.post-copyright-info - a(href=url_for(page.permalink)) #[=page.permalink] - .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) - - .tag_share - if (theme.post_meta.tags) - .post-meta__tag-list - each item, index in page.tags.data - a(href=url_for(item.path)).post-meta__tags #[=item.name] - include includes/share/index.pug + #article-container!=page.content + include includes/post/post-copyright.pug + .tag_share + if (theme.post_meta.post.tags) + .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}) - if theme.reward.enable - include includes/reward.pug - 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 theme.reward.enable + !=partial('includes/post/reward', {}, {cache:theme.fragment_cache}) + 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 diff --git a/layout/tag.pug b/layout/tag.pug index b90868f..ec2e31b 100644 --- a/layout/tag.pug +++ b/layout/tag.pug @@ -6,13 +6,9 @@ block content #recent-posts.recent-posts +UI_NEW(page.posts) include includes/pagination.pug - #aside_content.aside_content - include includes/widget/index.pug else include ./includes/mixins/article-sort.pug #tag .article-sort-title= _p('page.tag') + ' - ' + page.tag +articleSort(page.posts) - include includes/pagination.pug - #aside_content.aside_content - include includes/widget/index.pug + include includes/pagination.pug \ No newline at end of file diff --git a/package.json b/package.json index c0dd41d..e4c0363 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { "name": "hexo-theme-butterfly", - "version": "2.1.0", + "version": "2.2.0", "description": "A Hexo Theme: Butterfly" } \ No newline at end of file diff --git a/scripts/events/404.js b/scripts/events/404.js new file mode 100644 index 0000000..e091744 --- /dev/null +++ b/scripts/events/404.js @@ -0,0 +1,8 @@ +hexo.extend.generator.register('404', function(locals){ + if (!hexo.theme.config.error_404.enable) return + return { + path: '404.html', + data: locals.posts, + layout: ['404'] + } +}); \ No newline at end of file diff --git a/scripts/replace-config.js b/scripts/events/replace-config.js similarity index 100% rename from scripts/replace-config.js rename to scripts/events/replace-config.js diff --git a/scripts/hide_post.js b/scripts/filters/hide-post.js similarity index 100% rename from scripts/hide_post.js rename to scripts/filters/hide-post.js diff --git a/scripts/filters/post-lazyload.js b/scripts/filters/post-lazyload.js new file mode 100644 index 0000000..e3c8177 --- /dev/null +++ b/scripts/filters/post-lazyload.js @@ -0,0 +1,30 @@ +'use strict'; + +const fs = require('hexo-fs'); +const url_for = require('hexo-util').url_for.bind(hexo); + +function lazyProcess(htmlContent) { + var bg = url_for(hexo.theme.config.lodding_bg.post); + return htmlContent.replace(//gi, (str, p1, p2, p3) => { + if (/data-src/gi.test(str)) { + return str; + } + if (/class="(.*?)"/gi.test(str)){ + str = str.replace(/class="(.*?)"/gi, (classStr, p1) => { + return classStr.replace(p1, `${p1} lazyload`); + }) + str = str.replace(p2, `${bg}`) + return str.replace(p3, `${p3} data-src="${p2}"`); + } + str = str.replace(p2, `${bg}`) + return str.replace(p3, `${p3} class="lazyload" data-src="${p2}"`); + }); +} + +var processPost = function(data) { + if (!hexo.theme.config.lazyload.enable) return; + data.content = lazyProcess.call(this, data.content); + return data; +}; + +hexo.extend.filter.register('after_post_render', processPost); \ No newline at end of file diff --git a/scripts/filters/random-cover.js b/scripts/filters/random-cover.js new file mode 100644 index 0000000..f660df1 --- /dev/null +++ b/scripts/filters/random-cover.js @@ -0,0 +1,23 @@ +hexo.extend.filter.register("before_post_render", function(data) { + if (data.cover == false) { + data.randomcover = random_cover(); + return data; + } + data.cover = data.cover || random_cover(); + return data; +}); + +var random_cover = function() { + var cover; + var num; + if (!Array.isArray(hexo.theme.config.cover.default_cover)) { + cover = hexo.theme.config.cover.default_cover; + return cover; + } else { + num = Math.floor( + Math.random() * hexo.theme.config.cover.default_cover.length + ); + cover = hexo.theme.config.cover.default_cover[num]; + return cover; + } +}; diff --git a/scripts/gallery-tag.js b/scripts/gallery-tag.js deleted file mode 100644 index 2aeb719..0000000 --- a/scripts/gallery-tag.js +++ /dev/null @@ -1,6 +0,0 @@ -function gallery(args, content) { - return ``; -} - -hexo.extend.tag.register('gallery', gallery, {ends: true}); \ No newline at end of file diff --git a/scripts/list_archives.js b/scripts/helpers/list-archives.js similarity index 100% rename from scripts/list_archives.js rename to scripts/helpers/list-archives.js diff --git a/scripts/related_post.js b/scripts/helpers/related-post.js similarity index 82% rename from scripts/related_post.js rename to scripts/helpers/related-post.js index 146e51d..455eff0 100644 --- a/scripts/related_post.js +++ b/scripts/helpers/related-post.js @@ -1,5 +1,3 @@ -const moment = require('moment'); - hexo.extend.helper.register('related_posts', function (currentPost, allPosts) { var relatedPosts = []; currentPost.tags.forEach(function (tag) { @@ -9,6 +7,7 @@ hexo.extend.helper.register('related_posts', function (currentPost, allPosts) { title: post.title, path: post.path, cover: post.cover, + randomcover: post.randomcover, weight: 1, updated: post.updated, created: post.date @@ -32,17 +31,9 @@ hexo.extend.helper.register('related_posts', function (currentPost, allPosts) { const config = hexo.theme.config; var limit_num = config.related_post.limit || 6 - var lang = hexoConfig.language; var date_type = config.related_post.date_type || 'created' - var headline_lang; - if (lang === 'zh-CN') { - headline_lang = '相关推荐'; - } else if (lang === 'zh-TW') { - headline_lang = '相關推薦'; - } else { - headline_lang = 'Recommend'; - } - + var headline_lang = this._p('post.recommend') + relatedPosts = relatedPosts.sort(compare('weight')); var lazy_src = config.lazyload.enable ? lazy_src = 'data-src' : lazy_src = 'src' var lazy_class = config.lazyload.enable ? lazy_class = 'lazyload' : lazy_class = '' @@ -53,15 +44,13 @@ hexo.extend.helper.register('related_posts', function (currentPost, allPosts) { result += '