mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-08 12:07:06 +08:00
🔖 2.2.5發佈
更新内容請看 https://github.com/jerryc127/hexo-theme-butterfly/releases
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# hexo-theme-butterfly
|
||||
|
||||
<a href="https://github.com/jerryc127/hexo-theme-butterfly/releases"><img alt="Version" src="https://img.shields.io/badge/release-2.2.0-blue"/></a>
|
||||
<a href="https://github.com/jerryc127/hexo-theme-butterfly/releases"><img alt="Version" src="https://img.shields.io/badge/release-2.2.5-blue"/></a>
|
||||
<a href="https://jerryc.me"><img alt="Author" src="https://img.shields.io/badge/author-JerryC-blur"/></a>
|
||||
<a href="https://hexo.io"><img alt="Hexo" src="https://img.shields.io/badge/hexo-4.0+-0e83c"/></a>
|
||||
<a href="https://nodejs.org/"><img alt="node.js" src="https://img.shields.io/badge/node.js-8.0+-blur"/></a>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# hexo-theme-butterfly
|
||||
|
||||
<a href="https://github.com/jerryc127/hexo-theme-butterfly/releases"><img alt="Version" src="https://img.shields.io/badge/release-2.2.0-blue"/></a>
|
||||
<a href="https://github.com/jerryc127/hexo-theme-butterfly/releases"><img alt="Version" src="https://img.shields.io/badge/release-2.2.5-blue"/></a>
|
||||
<a href="https://jerryc.me"><img alt="Author" src="https://img.shields.io/badge/author-JerryC-blur"/></a>
|
||||
<a href="https://hexo.io"><img alt="Hexo" src="https://img.shields.io/badge/hexo-4.0+-0e83c"/></a>
|
||||
<a href="https://nodejs.org/"><img alt="node.js" src="https://img.shields.io/badge/node.js-8.0+-blur"/></a>
|
||||
|
||||
13
_config.yml
13
_config.yml
@@ -49,12 +49,12 @@ copy:
|
||||
|
||||
# social settings
|
||||
# formal:
|
||||
# icon: link
|
||||
# icon: link || the description
|
||||
# ---------------
|
||||
social:
|
||||
fa fa-github: https://github.com/jerryc127
|
||||
fa fa-envelope: mailto:xxxxxxxx@gmail.com
|
||||
fa fa-rss: /atom.xml
|
||||
fa fa-github: https://github.com/jerryc127 || Github
|
||||
fa fa-envelope: mailto:xxxxxxx@gmail.com || Email
|
||||
fa fa-rss: /atom.xml || RSS
|
||||
|
||||
#### search ####
|
||||
# Algolia search
|
||||
@@ -170,6 +170,7 @@ post_meta:
|
||||
|
||||
# Please see doc for more details: https://docs.jerryc.me/config.html#字數統計
|
||||
wordcount:
|
||||
enable: false
|
||||
post_wordcount: true
|
||||
min2read: true
|
||||
total_wordcount: true
|
||||
@@ -356,6 +357,10 @@ related_post:
|
||||
limit: 6 # 顯示推薦文章數目
|
||||
date_type: created # or created or updated 文章日期顯示創建日或者更新日
|
||||
|
||||
# figcaption
|
||||
# 圖片描述文字
|
||||
photofigcaption: false
|
||||
|
||||
#### 美化/效果 ####
|
||||
#--------------------------------
|
||||
|
||||
|
||||
@@ -24,8 +24,8 @@ post:
|
||||
created: 發表於
|
||||
updated: 更新於
|
||||
wordcount: 字數總計
|
||||
min2read: "閲讀時長: %s 分鐘"
|
||||
page_pv: 閲讀量
|
||||
min2read: "閱讀時長: %s 分鐘"
|
||||
page_pv: 閱讀量
|
||||
comments: 評論數
|
||||
copyright:
|
||||
author: 文章作者
|
||||
@@ -78,7 +78,7 @@ bookmark:
|
||||
title: 添加書籤
|
||||
|
||||
rightside:
|
||||
readmode_title: 閲讀模式
|
||||
readmode_title: 閱讀模式
|
||||
font_plus_title: 放大字體
|
||||
font_minus_title: 縮小字體
|
||||
translate_title: 簡繁轉換
|
||||
|
||||
@@ -1,87 +1,23 @@
|
||||
- var top_img = theme.error_404.background || theme.default_top_img
|
||||
- var bg_img = `background-image: url(${top_img})`
|
||||
|
||||
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
|
||||
|
||||
include includes/head.pug
|
||||
body
|
||||
if theme.fireworks && theme.fireworks.enable
|
||||
canvas.fireworks
|
||||
|
||||
include includes/mobile-sidebar/index.pug
|
||||
|
||||
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
|
||||
#error_subtitle= theme.error_404.subtitle
|
||||
include includes/rightside.pug
|
||||
include includes/search/index.pug
|
||||
each item in theme.CDN_USE.js
|
||||
script(src=url_for(item))
|
||||
include includes/additional-js.pug
|
||||
include includes/search/index.pug
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -62,4 +62,4 @@ if theme.mermaid.enable
|
||||
include ./math/mermaid.pug
|
||||
|
||||
if is_home()
|
||||
include index-js.pug
|
||||
include ./head/subtitle.pug
|
||||
@@ -1,16 +1,19 @@
|
||||
- var pageTitle = page.title || config.title || ''
|
||||
- var pageTitle
|
||||
- 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
|
||||
- else if (is_tag()) pageTitle = _p('page.tag') + ': ' + page.tag
|
||||
- else if (is_category()) pageTitle = _p('page.category') + ': ' + page.category
|
||||
- else if (is_month()) pageTitle += ': ' + page.month + '/' + page.year
|
||||
- else if (is_year()) pageTitle += ': ' + page.year
|
||||
- else if (is_current('/404.html', [strict])) pageTitle = _p('error_title')
|
||||
- else pageTitle = page.title || config.title || ''
|
||||
|
||||
- var isSubtitle = config.subtitle ? ' - ' + config.subtitle : ''
|
||||
- var tabTitle = is_home() || !pageTitle ? config.title + isSubtitle : pageTitle + ' | ' + config.title
|
||||
- pageTitle ? '' : pageTitle = config.title || ''
|
||||
|
||||
- var pageDescription = page.description || page.title || config.description
|
||||
- var pageKeywords = Array.isArray(config.keywords) ? (config.keywords).join(','): ([]).join(',') || config.keywords
|
||||
- var pageKeywords
|
||||
- if (page.tags && page.tags.data) pageKeywords = page.tags.data.map(function(tag) {return tag.name;}).join(',')
|
||||
- else pageKeywords = Array.isArray(config.keywords) ? (config.keywords).join(','): ([]).join(',') || config.keywords
|
||||
- var pageAuthor = config.email ? config.author + ',' + config.email : config.author
|
||||
- var pageCopyright = config.copyright || config.author
|
||||
- var without_html = url.replace('index.html', '')
|
||||
@@ -97,4 +100,6 @@ if theme.blog_title_font.font_link
|
||||
|
||||
//- global config
|
||||
!=partial('includes/head/config', {}, {cache:theme.fragment_cache})
|
||||
|
||||
include ./head/config_site.pug
|
||||
include ./head/noscript.pug
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
copyright = JSON.stringify({
|
||||
languages: {
|
||||
author: _p("copy_copyright.author") + ': ' + config.author,
|
||||
link: _p("copy_copyright.link") + ': ' + without_html,
|
||||
link: _p("copy_copyright.link") + ': ',
|
||||
source: _p("copy_copyright.source") + ': ' + config.title,
|
||||
info: _p("copy_copyright.info")
|
||||
}
|
||||
@@ -62,7 +62,6 @@
|
||||
if (theme.snackbar && theme.snackbar.enable) {
|
||||
Snackbar = JSON.stringify({
|
||||
bookmark: {
|
||||
title: _p("Snackbar.bookmark.title"),
|
||||
message_prev: _p("Snackbar.bookmark.message_prev"),
|
||||
message_next: _p("Snackbar.bookmark.message_next")
|
||||
},
|
||||
@@ -76,16 +75,6 @@
|
||||
})
|
||||
}
|
||||
|
||||
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 isFontAwesomeV5 = theme.fontawesome_v5 && theme.fontawesome_v5.enable
|
||||
|
||||
|
||||
script.
|
||||
var GLOBAL_CONFIG = {
|
||||
root: '!{config.root}',
|
||||
@@ -98,22 +87,22 @@ script.
|
||||
noSupport: '!{_p("copy.noSupport")}'
|
||||
},
|
||||
bookmark: {
|
||||
title: '!{_p("Snackbar.bookmark.title")}',
|
||||
message_prev: '!{_p("Snackbar.bookmark.message_prev")}',
|
||||
message_next: '!{_p("Snackbar.bookmark.message_next")}'
|
||||
},
|
||||
runtime_unit: '!{_p("runtime_unit")}',
|
||||
runtime: !{runtime},
|
||||
runtime: !{theme.runtimeshow.enable},
|
||||
copyright: !{copyright},
|
||||
ClickShowText: !{ClickShowText},
|
||||
medium_zoom: !{medium_zoom},
|
||||
fancybox: !{fancybox},
|
||||
medium_zoom: !{theme.medium_zoom.enable},
|
||||
fancybox: !{theme.fancybox.enable},
|
||||
Snackbar: !{Snackbar},
|
||||
baiduPush: !{baiduPush},
|
||||
highlightCopy: !{highlightCopy},
|
||||
highlightLang: !{highlightLang},
|
||||
highlightShrink: !{highlightShrink},
|
||||
isFontAwesomeV5: !{isFontAwesomeV5}
|
||||
baiduPush: !{theme.baidu_push && theme.baidu_push.enable},
|
||||
highlightCopy: !{theme.highlight_copy},
|
||||
highlightLang: !{theme.highlight_lang},
|
||||
highlightShrink: '!{theme.highlight_shrink}',
|
||||
isFontAwesomeV5: !{theme.fontawesome_v5 && theme.fontawesome_v5.enable},
|
||||
isPhotoFigcaption: !{theme.photofigcaption}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
script.
|
||||
var GLOBAL_CONFIG_SITE = {
|
||||
isPost: !{is_post()},
|
||||
isHome: !{is_home()}
|
||||
}
|
||||
isHome: !{is_home()},
|
||||
isSidebar: !{is_post() && page.toc !== false && theme.toc.enable && (toc(page.content) !== '' || page.encrypt == true )}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
script.
|
||||
const autoChangeMode = '#{theme.darkmode.autoChangeMode}'
|
||||
var 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
|
||||
var isDarkMode = window.matchMedia("(prefers-color-scheme: dark)").matches
|
||||
var isLightMode = window.matchMedia("(prefers-color-scheme: light)").matches
|
||||
var isNotSpecified = window.matchMedia("(prefers-color-scheme: no-preference)").matches
|
||||
var hasNoSupport = !isDarkMode && !isLightMode && !isNotSpecified
|
||||
|
||||
if (t === undefined){
|
||||
if (isLightMode) activateLightMode()
|
||||
else if (isDarkMode) activateDarkMode()
|
||||
else if (isNotSpecified || hasNoSupport){
|
||||
console.log('You specified no preference for a color scheme or your browser does not support it. I Schedule dark mode during night time.')
|
||||
now = new Date();
|
||||
hour = now.getHours();
|
||||
isNight = hour < 6 || hour >= 18
|
||||
var now = new Date()
|
||||
var hour = now.getHours()
|
||||
var isNight = hour < 6 || hour >= 18
|
||||
isNight ? activateDarkMode() : activateLightMode()
|
||||
}
|
||||
} else if (t == 'light') activateLightMode()
|
||||
|
||||
9
layout/includes/head/noscript.pug
Normal file
9
layout/includes/head/noscript.pug
Normal file
@@ -0,0 +1,9 @@
|
||||
noscript.
|
||||
<style>
|
||||
#page-header {
|
||||
opacity: 1
|
||||
}
|
||||
.justified-gallery img{
|
||||
opacity: 1
|
||||
}
|
||||
</style>
|
||||
@@ -1,22 +1,22 @@
|
||||
if theme.subtitle.enable
|
||||
- let source = theme.subtitle.source
|
||||
- let subtitleEffect = theme.subtitle.effect
|
||||
- var source = theme.subtitle.source
|
||||
- var subtitleEffect = theme.subtitle.effect
|
||||
|
||||
if subtitleEffect
|
||||
script(src=url_for(theme.CDN.typed))
|
||||
|
||||
if source == '1'
|
||||
script.
|
||||
let subtitleEffect = !{subtitleEffect}
|
||||
var subtitleEffect = !{subtitleEffect}
|
||||
fetch('https://api.ooopn.com/ciba/api.php',)
|
||||
.then(function (res){
|
||||
return res.json();
|
||||
})
|
||||
.then(function (data) {
|
||||
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", {
|
||||
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: 150,
|
||||
@@ -33,17 +33,17 @@ if theme.subtitle.enable
|
||||
|
||||
else if source == '2'
|
||||
script.
|
||||
let subtitleEffect = !{subtitleEffect}
|
||||
var subtitleEffect = !{subtitleEffect}
|
||||
fetch('https://v1.hitokoto.cn')
|
||||
.then(function (res){
|
||||
return res.json();
|
||||
})
|
||||
.then(function (data) {
|
||||
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", {
|
||||
var from = '出自 ' + data.from
|
||||
var sub = '!{theme.subtitle.sub}'.length == 0 ? new Array() : '!{theme.subtitle.sub}'.split(",");
|
||||
var both = sub.unshift(data.hitokoto,from)
|
||||
var typed = new Typed("#subtitle", {
|
||||
strings: sub,
|
||||
startDelay: 300,
|
||||
typeSpeed: 150,
|
||||
@@ -61,13 +61,13 @@ if theme.subtitle.enable
|
||||
else if source == "3"
|
||||
script(type="text/javascript" src="http://yijuzhan.com/api/word.php?m=js")
|
||||
script.
|
||||
let subtitleEffect = !{subtitleEffect}
|
||||
let con = str[0];
|
||||
var subtitleEffect = !{subtitleEffect}
|
||||
var 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", {
|
||||
var from = "出自 " + str[1];
|
||||
var sub = '!{theme.subtitle.sub}'.length == 0 ? new Array() : '!{theme.subtitle.sub}'.split(",");
|
||||
var both = sub.unshift(con,from)
|
||||
var typed = new Typed("#subtitle", {
|
||||
strings: sub,
|
||||
startDelay: 300,
|
||||
typeSpeed: 150,
|
||||
@@ -81,13 +81,13 @@ if theme.subtitle.enable
|
||||
else if source == '4'
|
||||
script(type="text/javascript" src="https://sdk.jinrishici.com/v2/browser/jinrishici.js" charset="utf-8")
|
||||
script.
|
||||
let subtitleEffect = !{subtitleEffect}
|
||||
var subtitleEffect = !{subtitleEffect}
|
||||
jinrishici.load(function(result) {
|
||||
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", {
|
||||
var sub = '!{theme.subtitle.sub}'.length == 0 ? new Array() : '!{theme.subtitle.sub}'.split(",");
|
||||
var content = result.data.content;
|
||||
var both = sub.unshift(content)
|
||||
var typed = new Typed("#subtitle", {
|
||||
strings: sub,
|
||||
startDelay: 300,
|
||||
typeSpeed: 150,
|
||||
@@ -102,9 +102,9 @@ if theme.subtitle.enable
|
||||
else
|
||||
- var subtitle = theme.subtitle.sub[0]
|
||||
script.
|
||||
let subtitleEffect = !{subtitleEffect}
|
||||
var subtitleEffect = !{subtitleEffect}
|
||||
if (subtitleEffect){
|
||||
let typed = new Typed("#subtitle", {
|
||||
var typed = new Typed("#subtitle", {
|
||||
strings: '!{theme.subtitle.sub}'.split(","),
|
||||
startDelay: 300,
|
||||
typeSpeed: 150,
|
||||
@@ -1,15 +1,18 @@
|
||||
#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
|
||||
if (theme.algolia_search.enable || theme.local_search && theme.local_search.enable)
|
||||
#search_button
|
||||
a.site-page.social-icon.search
|
||||
i.fa.fa-search.fa-fw
|
||||
span=' '+_p('search')
|
||||
.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')
|
||||
span.toggle-menu.close
|
||||
a.site-page
|
||||
i.fa.fa-bars.fa-fw(aria-hidden="true")
|
||||
|
||||
|
||||
|
||||
@@ -33,9 +33,7 @@ if theme.douban
|
||||
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")
|
||||
!=partial('includes/header/social', {}, {cache:theme.fragment_cache})
|
||||
#scroll_down
|
||||
i.fa.fa-angle-down.scroll-down-effects
|
||||
else if is_post()
|
||||
|
||||
@@ -7,17 +7,19 @@
|
||||
if (theme.post_meta.post.date_type)
|
||||
if (theme.post_meta.post.date_type === 'both')
|
||||
time.post-meta__date
|
||||
i.fa.fa-calendar(aria-hidden="true")
|
||||
=' '+_p('post.created')+' '+date(page.date, config.date_format)
|
||||
span.post-meta__date-created(title= _p('post.created')+' '+full_date(page.date))
|
||||
i.fa.fa-calendar(aria-hidden="true")
|
||||
=' '+_p('post.created')+' '+date(page.date, config.date_format)
|
||||
span.post-meta__separator |
|
||||
i.fa.fa-history(aria-hidden="true")
|
||||
=' '+_p('post.updated')+' '+date(page.updated, config.date_format)
|
||||
span.post-meta__date-updated(title= _p('post.updated')+' '+full_date(page.updated))
|
||||
i.fa.fa-history(aria-hidden="true")
|
||||
=' '+_p('post.updated')+' '+date(page.updated, config.date_format)
|
||||
else
|
||||
- var data_type_update = theme.post_meta.post.date_type === 'updated'
|
||||
- var date_type = data_type_update ? 'updated' : 'date'
|
||||
- var date_icon = data_type_update ? 'fa-history' :'fa-calendar'
|
||||
- var data_info = data_type_update ? _p('post.updated') : _p('post.created')
|
||||
time.post-meta__date
|
||||
time.post-meta__date(title=data_info + ' ' + full_date(page[date_type]))
|
||||
i.fa(class=date_icon aria-hidden="true")
|
||||
=' ' + data_info + ' ' + date(page[date_type], config.date_format)
|
||||
|
||||
@@ -33,7 +35,7 @@
|
||||
i.fa.fa-angle-right.post-meta__separator(aria-hidden="true")
|
||||
|
||||
.meta-secondline
|
||||
- let postWordcount = theme.wordcount.post_wordcount || theme.wordcount.min2read
|
||||
- let postWordcount = theme.wordcount.enable && (theme.wordcount.post_wordcount || theme.wordcount.min2read)
|
||||
if (postWordcount)
|
||||
span.post-meta-wordcount
|
||||
if theme.wordcount.post_wordcount
|
||||
|
||||
4
layout/includes/header/social.pug
Normal file
4
layout/includes/header/social.pug
Normal file
@@ -0,0 +1,4 @@
|
||||
each url, icon in theme.social
|
||||
a.social-icon(href=trim(url.split('||')[0]) target="_blank"
|
||||
title=url.split('||')[1] === undefined ? '' : trim(url.split('||')[1]))
|
||||
i(class=icon aria-hidden="true")
|
||||
@@ -1,5 +1,4 @@
|
||||
- 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)
|
||||
@@ -8,10 +7,11 @@ html(lang=config.language data-theme=theme.display_mode)
|
||||
body
|
||||
if theme.fireworks && theme.fireworks.enable
|
||||
canvas.fireworks
|
||||
|
||||
!=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
|
||||
|
||||
include ./sidebar.pug
|
||||
|
||||
#body-wrap
|
||||
if theme.background
|
||||
- var is_photo = theme.background.substring(3,0) === 'url' ? 'photo':'color'
|
||||
@@ -36,10 +36,14 @@ html(lang=config.language data-theme=theme.display_mode)
|
||||
- var is_bg = theme.footer_bg == false ? 'color' : 'photo'
|
||||
footer#footer(style=footer_bg data-type=is_bg)
|
||||
!=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
|
||||
|
||||
|
||||
|
||||
@@ -19,15 +19,19 @@ mixin UI_NEW(posts)
|
||||
if (theme.post_meta.page.date_type)
|
||||
if (theme.post_meta.page.date_type === 'both')
|
||||
time.post-meta__date
|
||||
i.fa.fa-calendar(aria-hidden="true")
|
||||
=date(article.date, config.date_format)
|
||||
span.post-meta__date-created(title=_p('post.created') + ' ' + full_date(article.date))
|
||||
i.fa.fa-calendar(aria-hidden="true")
|
||||
=date(article.date, config.date_format)
|
||||
span.article-meta__separator |
|
||||
i.fa.fa-history(aria-hidden="true")
|
||||
=date(article.updated, config.date_format)
|
||||
span.post-meta__date-updated(title=_p('post.updated') + ' ' + full_date(article.updated))
|
||||
i.fa.fa-history(aria-hidden="true")
|
||||
=date(article.updated, config.date_format)
|
||||
else
|
||||
- var date_type = theme.post_meta.page.date_type === 'updated' ? 'updated' : 'date'
|
||||
- var date_icon = theme.post_meta.page.date_type === 'updated' ? 'fa-history' :'fa-calendar'
|
||||
time.post-meta__date
|
||||
- var data_type_updated = theme.post_meta.page.date_type === 'updated'
|
||||
- var date_type = data_type_updated ? 'updated' : 'date'
|
||||
- var date_icon = data_type_updated ? 'fa-history' :'fa-calendar'
|
||||
- var date_title = data_type_updated ? _p('post.updated') : _p('post.created')
|
||||
time.post-meta__date(title=date_title + ' ' + full_date(article[date_type]))
|
||||
i.fa(class=date_icon aria-hidden="true")
|
||||
=date(article[date_type], config.date_format)
|
||||
if (theme.post_meta.page.categories && article.categories.data.length > 0)
|
||||
|
||||
@@ -15,6 +15,6 @@ mixin articleSort(posts)
|
||||
.article-sort-post
|
||||
a.article-sort-item__post(href=url_for(article.path))
|
||||
i.fa.fa-clock-o(aria-hidden="true")
|
||||
time.article-sort-item__time= date(article.date)
|
||||
time.article-sort-item__time(title=_p('post.created') + ' ' + full_date(article.date))= date(article.date, config.date_format)
|
||||
.article-sort-item__title= article.title || 'No Title'
|
||||
- })
|
||||
@@ -23,15 +23,19 @@ each article , index in page.posts.data
|
||||
if (theme.post_meta.page.date_type)
|
||||
if (theme.post_meta.page.date_type === 'both')
|
||||
time.post-meta__date
|
||||
i.fa.fa-calendar(aria-hidden="true")
|
||||
=date(article.date, config.date_format)
|
||||
span.post-meta__date-created(title=_p('post.created') + ' ' + full_date(article.date))
|
||||
i.fa.fa-calendar(aria-hidden="true")
|
||||
=date(article.date, config.date_format)
|
||||
span.article-meta__separator |
|
||||
i.fa.fa-history(aria-hidden="true")
|
||||
=date(article.updated, config.date_format)
|
||||
span.post-meta__date-updated(title=_p('post.updated') + ' ' + full_date(article.updated))
|
||||
i.fa.fa-history(aria-hidden="true")
|
||||
=date(article.updated, config.date_format)
|
||||
else
|
||||
- var date_type = theme.post_meta.page.date_type === 'updated' ? 'updated' : 'date'
|
||||
- var date_icon = theme.post_meta.page.date_type === 'updated' ? 'fa-history' :'fa-calendar'
|
||||
time.post-meta__date
|
||||
- var data_type_updated = theme.post_meta.page.date_type === 'updated'
|
||||
- var date_type = data_type_updated ? 'updated' : 'date'
|
||||
- var date_icon = data_type_updated ? 'fa-history' :'fa-calendar'
|
||||
- var date_title = data_type_updated ? _p('post.updated') : _p('post.created')
|
||||
time.post-meta__date(title=date_title + ' ' + full_date(article[date_type]))
|
||||
i.fa(class=date_icon aria-hidden="true")
|
||||
=date(article[date_type], config.date_format)
|
||||
if (theme.post_meta.page.categories && article.categories.data.length > 0)
|
||||
|
||||
@@ -18,6 +18,6 @@ section#rightside.rightside
|
||||
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
|
||||
if is_post() && page.toc !== false && theme.toc.enable && (toc(page.content) !== '' || page.encrypt == true )
|
||||
i#mobile-toc-button.fa.fa-list-ul.close(title=_p("rightside.toc") aria-hidden="true")
|
||||
i.fa.fa-arrow-up#go-up(title=_p("rightside.back_to_top") aria-hidden="true")
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
#sidebar
|
||||
- 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)
|
||||
- let showToc = is_post() && page.toc !== false && theme.toc.enable && (toc(page.content) !== '' || page.encrypt == true )
|
||||
- let autoOpenSidebar = theme.auto_open_sidebar.enable === true ? 'on' : ''
|
||||
|
||||
-
|
||||
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)
|
||||
i.fa.fa-arrow-right#toggle-sidebar(aria-hidden="true" class=autoOpenSidebar)
|
||||
#sidebar
|
||||
.sidebar-toc
|
||||
div.sidebar-toc__title= _p('sidebar.catalog')
|
||||
div.sidebar-toc__progress
|
||||
@@ -18,4 +22,4 @@
|
||||
div.sidebar-toc__content.toc-div-class(style="display:none")!=toc(page.origin, {list_number: tocNumber})
|
||||
else
|
||||
div.sidebar-toc__content!=toc(page.content, {list_number: tocNumber})
|
||||
|
||||
|
||||
@@ -31,6 +31,4 @@
|
||||
|
||||
if(theme.social)
|
||||
.card-info-social-icons.is-center
|
||||
each url, icon in theme.social
|
||||
a.social-icon(href=url target="_blank")
|
||||
i(class=icon aria-hidden="true")
|
||||
include ../header/social.pug
|
||||
|
||||
@@ -20,8 +20,6 @@
|
||||
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.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)]
|
||||
time.aside-post_meta.post-meta__date(title=_p('post.created') + ' ' + full_date(article.date)) #[=date(article.date, config.date_format)]
|
||||
|
||||
- })
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
.webinfo-item
|
||||
.webinfo-runtime-name= _p('aside.card_webinfo.runtime_name') + " :"
|
||||
#webinfo-runtime-count.webinfo-runtime-count(start_date=theme.runtimeshow.start_date)
|
||||
if theme.wordcount.total_wordcount
|
||||
if theme.wordcount.enable && theme.wordcount.total_wordcount
|
||||
.webinfo-item
|
||||
.webinfo-site-wordcount-name=_p('aside.card_webinfo.site_wordcount') + " :"
|
||||
.webinfo-site-wordcount=totalcount(site)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "hexo-theme-butterfly",
|
||||
"version": "2.2.0",
|
||||
"version": "2.2.5",
|
||||
"description": "A Hexo Theme: Butterfly"
|
||||
}
|
||||
@@ -1,11 +1,10 @@
|
||||
'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(/<img(\s*?)src="(.*?)"(.*?)>/gi, (str, p1, p2, p3) => {
|
||||
return htmlContent.replace(/<img(.*?)src="(.*?)"(.*?)>/gi, (str, p1, p2, p3) => {
|
||||
if (/data-src/gi.test(str)) {
|
||||
return str;
|
||||
}
|
||||
@@ -14,10 +13,10 @@ function lazyProcess(htmlContent) {
|
||||
return classStr.replace(p1, `${p1} lazyload`);
|
||||
})
|
||||
str = str.replace(p2, `${bg}`)
|
||||
return str.replace(p3, `${p3} data-src="${p2}"`);
|
||||
return str.replace('>', ` data-src="${p2}">`);
|
||||
}
|
||||
str = str.replace(p2, `${bg}`)
|
||||
return str.replace(p3, `${p3} class="lazyload" data-src="${p2}"`);
|
||||
return str.replace(p3, ` class="lazyload" data-src="${p2}" ${p3}`);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ hexo.extend.helper.register("list_archives", function(options = {}) {
|
||||
}
|
||||
|
||||
if (data.length > limit) {
|
||||
result += `<li class="archive-list-item">`;
|
||||
result += `<li class="archive-list-item is-center">`;
|
||||
result +=
|
||||
`<a class="archive-list-link-more" href="` +
|
||||
"/" +
|
||||
|
||||
@@ -62,7 +62,7 @@ h6
|
||||
left: $sidebar-icon-left
|
||||
z-index: 100
|
||||
font-size: $sidebar-icon-size
|
||||
opacity: 0
|
||||
// opacity: 0
|
||||
cursor: pointer
|
||||
transition: all .2s
|
||||
|
||||
@@ -143,6 +143,9 @@ table
|
||||
.is_visible
|
||||
display: block !important
|
||||
|
||||
.is-visible-inline
|
||||
display: inline-block !important
|
||||
|
||||
.is_invisible
|
||||
display: none !important
|
||||
|
||||
@@ -187,6 +190,9 @@ img[src=''],
|
||||
img:not([src])
|
||||
opacity: 0
|
||||
|
||||
.img-alt
|
||||
margin: -.5rem 0 .5rem
|
||||
|
||||
// hexo tag video
|
||||
.video-container
|
||||
position: relative
|
||||
@@ -240,8 +246,8 @@ img:not([src])
|
||||
margin: 2rem 0 !important
|
||||
|
||||
.ad_height
|
||||
height: auto !important
|
||||
display: block !important
|
||||
height: auto !important
|
||||
|
||||
#content-inner,
|
||||
#footer
|
||||
@@ -250,9 +256,8 @@ img:not([src])
|
||||
#nav
|
||||
animation: nav-effect 1s
|
||||
|
||||
#page-header
|
||||
animation: header-effect 1s
|
||||
|
||||
// #page-header
|
||||
// animation: header-effect 1s
|
||||
#site_title,
|
||||
#site_subtitle
|
||||
animation: titlescale 1s
|
||||
@@ -290,10 +295,10 @@ if hexo-config('avatar.effect') == true
|
||||
animation: tocsidebarRtoL .5s
|
||||
|
||||
.sidebar-toc__progress
|
||||
animation: tocsidebarRtoL .5s
|
||||
animation: tocsidebarRtoL .7s
|
||||
|
||||
.sidebar-toc__content
|
||||
animation: tocsidebarRtoL .7s
|
||||
animation: tocsidebarRtoL .9s
|
||||
|
||||
@keyframes scroll-down-effect
|
||||
0%
|
||||
@@ -321,9 +326,9 @@ if hexo-config('avatar.effect') == true
|
||||
0%
|
||||
opacity: 0
|
||||
|
||||
50%
|
||||
60%
|
||||
opacity: 0
|
||||
transform: translateY(-50px)
|
||||
transform: translateY(-30px)
|
||||
|
||||
100%
|
||||
opacity: 1
|
||||
|
||||
@@ -185,10 +185,6 @@
|
||||
&.child
|
||||
padding: 0 0 0 1.2rem
|
||||
|
||||
.card-archives
|
||||
.archive-list-link-more
|
||||
justify-content: center
|
||||
|
||||
.card-webinfo
|
||||
.webinfo
|
||||
padding: .2rem 1rem
|
||||
|
||||
@@ -52,6 +52,9 @@
|
||||
border-radius: 35px
|
||||
transition: all .3s
|
||||
|
||||
.img-alt
|
||||
display: none
|
||||
|
||||
.md-links-title
|
||||
overflow: hidden
|
||||
padding: 16px 10px 0 0
|
||||
|
||||
@@ -100,6 +100,9 @@ figure.gallery-group
|
||||
img
|
||||
opacity: 0
|
||||
|
||||
.img-alt
|
||||
display: none
|
||||
|
||||
.fancybox
|
||||
width: auto
|
||||
text-align: inherit
|
||||
|
||||
@@ -105,7 +105,7 @@
|
||||
|
||||
> .meta-secondline,
|
||||
> .meta-thirdline
|
||||
display inline
|
||||
display: inline
|
||||
|
||||
.word-count,
|
||||
#busuanzi_value_page_pv,
|
||||
@@ -118,7 +118,7 @@
|
||||
|
||||
&__icon
|
||||
margin-right: .2rem
|
||||
|
||||
|
||||
a
|
||||
color: $light-grey
|
||||
transition: all .3s ease-out
|
||||
@@ -136,16 +136,22 @@
|
||||
height: 58px
|
||||
border: none
|
||||
font-size: 18px
|
||||
opacity: 0
|
||||
transition: all .5s
|
||||
|
||||
&:not(.fixed)
|
||||
.menus
|
||||
padding-right: 0 !important
|
||||
|
||||
.toggle-menu
|
||||
display: none
|
||||
padding: .1rem 0 0 .3rem
|
||||
vertical-align: top
|
||||
|
||||
&:hover
|
||||
color: $white
|
||||
|
||||
&.is_visible
|
||||
&.is-visible-inline
|
||||
.site-page
|
||||
font-size: inherit
|
||||
|
||||
@@ -163,11 +169,6 @@
|
||||
box-shadow: 0 5px 6px -5px alpha($grey, .6)
|
||||
transition: transform .2s ease-in-out, opacity .2s ease-in-out
|
||||
|
||||
&.open-sidebar
|
||||
.menus,
|
||||
#search_button
|
||||
display: none
|
||||
|
||||
a,
|
||||
#site-name,
|
||||
.toggle-menu
|
||||
@@ -189,71 +190,75 @@
|
||||
font-weight: bold
|
||||
cursor: pointer
|
||||
|
||||
.menus_item
|
||||
position: relative
|
||||
display: inline-block
|
||||
padding: 0 0 0 .7rem
|
||||
.menus_items
|
||||
display: inline
|
||||
|
||||
&:hover
|
||||
.menus_item_child
|
||||
display: block
|
||||
|
||||
.menus-expand
|
||||
transform: rotate(180deg) !important
|
||||
|
||||
.menus-expand
|
||||
padding: 4px
|
||||
transition: all .3s
|
||||
transform: rotate(0)
|
||||
|
||||
& > a
|
||||
&:after
|
||||
position: absolute
|
||||
bottom: 0
|
||||
left: 0
|
||||
z-index: -1
|
||||
width: 0
|
||||
height: 3px
|
||||
background-color: lighten($theme-color, 30%)
|
||||
content: ''
|
||||
transition: all .3s ease-in-out
|
||||
.menus_item
|
||||
position: relative
|
||||
display: inline-block
|
||||
padding: 0 0 0 .7rem
|
||||
|
||||
&:hover
|
||||
.menus_item_child
|
||||
display: block
|
||||
|
||||
.menus-expand
|
||||
transform: rotate(180deg) !important
|
||||
|
||||
.menus-expand
|
||||
padding: 4px
|
||||
transition: all .3s
|
||||
transform: rotate(0)
|
||||
|
||||
& > a
|
||||
&:after
|
||||
width: 100%
|
||||
|
||||
.menus_item_child
|
||||
position: absolute
|
||||
right: 0
|
||||
display: none
|
||||
margin-top: 8px
|
||||
padding: 0
|
||||
width: max-content
|
||||
background-color: alpha($white, .8)
|
||||
box-shadow: 0 5px 20px -4px rgba($dark-black, .5)
|
||||
animation: sub_menus .3s .1s ease both
|
||||
|
||||
&:before
|
||||
position: absolute
|
||||
top: -8px
|
||||
left: 0
|
||||
width: 100%
|
||||
height: 20px
|
||||
content: ''
|
||||
|
||||
li
|
||||
padding: 1px 10px
|
||||
list-style: none
|
||||
text-align: center
|
||||
position: absolute
|
||||
bottom: 0
|
||||
left: 0
|
||||
z-index: -1
|
||||
width: 0
|
||||
height: 3px
|
||||
background-color: lighten($theme-color, 30%)
|
||||
content: ''
|
||||
transition: all .3s ease-in-out
|
||||
|
||||
&:hover
|
||||
background: $theme-color
|
||||
&:after
|
||||
width: 100%
|
||||
|
||||
a
|
||||
color: $font-black
|
||||
text-shadow: none
|
||||
.menus_item_child
|
||||
position: absolute
|
||||
right: 0
|
||||
display: none
|
||||
margin-top: 8px
|
||||
padding: 0
|
||||
width: max-content
|
||||
background-color: alpha($white, .8)
|
||||
box-shadow: 0 5px 20px -4px rgba($dark-black, .5)
|
||||
animation: sub_menus .3s .1s ease both
|
||||
|
||||
&:before
|
||||
position: absolute
|
||||
top: -8px
|
||||
left: 0
|
||||
width: 100%
|
||||
height: 20px
|
||||
content: ''
|
||||
|
||||
li
|
||||
padding: 1px 10px
|
||||
list-style: none
|
||||
text-align: center
|
||||
|
||||
&:hover
|
||||
background: $theme-color
|
||||
|
||||
a
|
||||
color: $font-black
|
||||
text-shadow: none
|
||||
|
||||
#search_button
|
||||
display: inline
|
||||
padding: 0 0 0 .7rem
|
||||
|
||||
.site-page
|
||||
@@ -300,7 +305,7 @@
|
||||
|
||||
.post-meta__categories
|
||||
display: none
|
||||
|
||||
|
||||
.meta-thirdline
|
||||
display: block
|
||||
|
||||
|
||||
@@ -100,6 +100,7 @@
|
||||
|
||||
& > time
|
||||
color: $theme-meta-color
|
||||
cursor: pointer
|
||||
|
||||
& > .article-meta
|
||||
color: $theme-meta-color
|
||||
|
||||
@@ -1,60 +1,55 @@
|
||||
$(function () {
|
||||
const isSnackbar = GLOBAL_CONFIG.Snackbar !== undefined
|
||||
const isTocContent = $('#sidebar .sidebar-toc__content').children().length > 0
|
||||
const $pageHead = $('#page-header')
|
||||
const $rightside = $('#rightside')
|
||||
const $body = $('body')
|
||||
|
||||
/**
|
||||
* 當menu過多時,自動適配,避免UI錯亂
|
||||
*/
|
||||
const searchWidth = $('#search_button').outerWidth() !== undefined ? $('#search_button').outerWidth() : 0
|
||||
const blogNameWidth = $('#blog_name').width()
|
||||
|
||||
var mw = 0
|
||||
var $menusItem = $pageHead.find('.menus_item')
|
||||
for (var i = 0; i < $menusItem.length; i++) {
|
||||
mw = mw + $menusItem.eq(i).outerWidth()
|
||||
}
|
||||
|
||||
/**
|
||||
* 傳入 1 sidebar打開時
|
||||
* 傳入 1 sidebar打開時
|
||||
* 傳入 2 正常狀態下
|
||||
* 傳入 3 resize時使用
|
||||
*/
|
||||
var blogNameWidth = $('#blog_name').width()
|
||||
var menusWidth = $('.menus').width()
|
||||
var sidebarWidth = $('#sidebar').width()
|
||||
|
||||
function isAdjust (n) {
|
||||
var t
|
||||
if (n === 1) {
|
||||
t = blogNameWidth + searchWidth + mw > $pageHead.width() - 300
|
||||
t = blogNameWidth + menusWidth > $pageHead.width() - sidebarWidth - 20
|
||||
} else if (n === 2) {
|
||||
t = blogNameWidth + searchWidth + mw > $pageHead.width()
|
||||
t = blogNameWidth + menusWidth > $pageHead.width() - 20
|
||||
}
|
||||
|
||||
if (t) headerAdjust()
|
||||
else headerAdjustBack()
|
||||
}
|
||||
|
||||
function headerAdjust () {
|
||||
$pageHead.find('.toggle-menu').addClass('is-visible-inline')
|
||||
$pageHead.find('.menus_items').addClass('is_invisible')
|
||||
$pageHead.find('#search_button span').addClass('is_invisible')
|
||||
}
|
||||
|
||||
function headerAdjustBack () {
|
||||
$pageHead.find('.toggle-menu').removeClass('is-visible-inline')
|
||||
$pageHead.find('.menus_items').removeClass('is_invisible')
|
||||
$pageHead.find('#search_button span').removeClass('is_invisible')
|
||||
}
|
||||
|
||||
// 初始化header
|
||||
function initAjust () {
|
||||
if (window.innerWidth < 768) headerAdjust()
|
||||
else isAdjust(2)
|
||||
}
|
||||
|
||||
initAjust()
|
||||
|
||||
function headerAdjust () {
|
||||
$pageHead.find('.toggle-menu').addClass('is_visible')
|
||||
$pageHead.find('.menus').addClass('is_invisible')
|
||||
$pageHead.find('#search_button span').addClass('is_invisible')
|
||||
}
|
||||
|
||||
function headerAdjustBack () {
|
||||
$pageHead.find('.toggle-menu').removeClass('is_visible')
|
||||
$pageHead.find('.menus').removeClass('is_invisible')
|
||||
$pageHead.find('#search_button span').removeClass('is_invisible')
|
||||
}
|
||||
$('#page-header').css({ opacity: '1', animation: 'headerNoOpacity 1s' })
|
||||
|
||||
$(window).on('resize', function () {
|
||||
if (!$pageHead.hasClass('open-sidebar')) {
|
||||
if ($('#sidebar').hasClass('tocOpenPc') && $pageHead.hasClass('fixed')) {
|
||||
isAdjust(1)
|
||||
} else {
|
||||
initAjust()
|
||||
}
|
||||
})
|
||||
@@ -72,21 +67,12 @@ $(function () {
|
||||
/**
|
||||
* 進入post頁sidebar處理
|
||||
*/
|
||||
|
||||
var isSidebarOpen = $('#toggle-sidebar').hasClass('on') && isTocContent
|
||||
var isPcSidebarOpen = false
|
||||
if (window.innerWidth > 1024 && isSidebarOpen) {
|
||||
setTimeout(function () {
|
||||
openSidebar()
|
||||
}, 400)
|
||||
}
|
||||
|
||||
// 當toc爲空時,隱藏toc按鈕
|
||||
if (isTocContent) {
|
||||
$('#toggle-sidebar').css('opacity', '1')
|
||||
} else {
|
||||
$('#toggle-sidebar').css('display', 'none')
|
||||
$('#mobile-toc-button').css('display', 'none')
|
||||
if (GLOBAL_CONFIG_SITE.isPost) {
|
||||
if (window.innerWidth > 1024 && $('#toggle-sidebar').hasClass('on')) {
|
||||
setTimeout(function () {
|
||||
openSidebar()
|
||||
}, 400)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -94,9 +80,10 @@ $(function () {
|
||||
*/
|
||||
|
||||
function closeSidebar () {
|
||||
isPcSidebarOpen = false
|
||||
$pageHead.removeClass('open-sidebar')
|
||||
$('#sidebar').removeClass('tocOpenPc')
|
||||
$('.menus').animate({
|
||||
paddingRight: 0
|
||||
}, 400)
|
||||
$('#body-wrap').animate({
|
||||
paddingLeft: 0
|
||||
}, 400)
|
||||
@@ -114,9 +101,10 @@ $(function () {
|
||||
}
|
||||
|
||||
function openSidebar () {
|
||||
isPcSidebarOpen = true
|
||||
$pageHead.addClass('open-sidebar')
|
||||
$('#sidebar').addClass('tocOpenPc')
|
||||
$('.menus').animate({
|
||||
paddingRight: 300
|
||||
}, 400)
|
||||
$('#body-wrap').animate({
|
||||
paddingLeft: 300
|
||||
}, 400)
|
||||
@@ -129,7 +117,8 @@ $(function () {
|
||||
opacity: '1'
|
||||
})
|
||||
var isAdjustTimeCount = window.setInterval(function () {
|
||||
isAdjust(1)
|
||||
if ($pageHead.hasClass('fixed')) isAdjust(1)
|
||||
else isAdjust(2)
|
||||
}, 100)
|
||||
setTimeout(function () {
|
||||
clearInterval(isAdjustTimeCount)
|
||||
@@ -165,7 +154,7 @@ $(function () {
|
||||
$toggleMenu.removeClass('close').addClass('open')
|
||||
$mobileSidevarMenus.css('transform', 'translate3d(-100%,0,0)')
|
||||
var $mobileSidevarMenusChild = $mobileSidevarMenus.children()
|
||||
for (i = 0; i <= $mobileSidevarMenusChild.length; i++) {
|
||||
for (let i = 0; i <= $mobileSidevarMenusChild.length; i++) {
|
||||
const duration = i / 5 + 0.2
|
||||
$mobileSidevarMenusChild.eq(i).css('animation', 'sidebarItem ' + duration + 's')
|
||||
}
|
||||
@@ -221,9 +210,9 @@ $(function () {
|
||||
const mql = window.matchMedia('(max-width: 1024px)')
|
||||
mql.addListener(function (ev) {
|
||||
if (ev.matches) {
|
||||
if (isPcSidebarOpen === true) closeSidebar()
|
||||
if ($('#sidebar').hasClass('tocOpenPc')) closeSidebar()
|
||||
} else {
|
||||
if ($('#toggle-sidebar').hasClass('on') && isTocContent) openSidebar()
|
||||
if ($('#toggle-sidebar').hasClass('on')) openSidebar()
|
||||
if ($mobileTocButton.hasClass('open')) closeMobileSidebar('toc')
|
||||
}
|
||||
})
|
||||
@@ -271,16 +260,16 @@ $(function () {
|
||||
* 代碼收縮
|
||||
*/
|
||||
const $highlightTools = $('.highlight-tools')
|
||||
if (isHighlightShrink === true) {
|
||||
if (isHighlightShrink === 'true') {
|
||||
$highlightTools.append('<i class="fa fa-angle-down code-expand code-closed" aria-hidden="true"></i>')
|
||||
} else if (isHighlightShrink === false) {
|
||||
} else if (isHighlightShrink === 'false') {
|
||||
$highlightTools.append('<i class="fa fa-angle-down code-expand" aria-hidden="true"></i>')
|
||||
}
|
||||
|
||||
$(document).on('click', '.highlight-tools >.code-expand', function () {
|
||||
var $table = $(this).parent().next()
|
||||
if ($(this).hasClass('code-closed')) {
|
||||
$table.css('display', '')
|
||||
$table.css('display', 'block')
|
||||
$(this).removeClass('code-closed')
|
||||
} else {
|
||||
$table.css('display', 'none')
|
||||
@@ -419,18 +408,16 @@ $(function () {
|
||||
} else if (isMediumZoom) {
|
||||
const zoom = mediumZoom(document.querySelectorAll('#article-container :not(a)>img'))
|
||||
zoom.on('open', function (event) {
|
||||
const photoBg = $(document.documentElement).attr('data-theme') === 'dark' ? '#121212' : '#fff'
|
||||
var photoBg = $(document.documentElement).attr('data-theme') === 'dark' ? '#121212' : '#fff'
|
||||
zoom.update({
|
||||
background: photoBg
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// 點擊toc,收起sidebar
|
||||
// $('.toc-link').on('click', function () {
|
||||
// closeMobileSidebar('toc')
|
||||
// })
|
||||
|
||||
/**
|
||||
* 滾動處理
|
||||
*/
|
||||
var initTop = 0
|
||||
$(window).scroll(function (event) {
|
||||
var currentTop = $(this).scrollTop()
|
||||
@@ -442,7 +429,6 @@ $(function () {
|
||||
if (!$pageHead.hasClass('visible')) $pageHead.addClass('visible')
|
||||
}
|
||||
$pageHead.addClass('fixed')
|
||||
|
||||
if ($rightside.css('opacity') === '0') {
|
||||
$rightside.css({ opacity: '1', transform: 'translateX(-38px)' })
|
||||
}
|
||||
@@ -450,7 +436,6 @@ $(function () {
|
||||
if (currentTop === 0) {
|
||||
$pageHead.removeClass('fixed').removeClass('visible')
|
||||
}
|
||||
|
||||
$rightside.css({ opacity: '', transform: '' })
|
||||
}
|
||||
})
|
||||
@@ -473,7 +458,7 @@ $(function () {
|
||||
* toc
|
||||
*/
|
||||
|
||||
if (GLOBAL_CONFIG_SITE.isPost && isTocContent) {
|
||||
if (GLOBAL_CONFIG_SITE.isPost && GLOBAL_CONFIG_SITE.isSidebar) {
|
||||
$('.toc-child').hide()
|
||||
|
||||
// main of scroll
|
||||
@@ -647,7 +632,7 @@ $(function () {
|
||||
if (copyFont.length > 45) {
|
||||
textFont = copyFont + '\n' + '\n' + '\n' +
|
||||
copyright.languages.author + '\n' +
|
||||
copyright.languages.link + '\n' +
|
||||
copyright.languages.link + window.location.href + '\n' +
|
||||
copyright.languages.source + '\n' +
|
||||
copyright.languages.info
|
||||
} else {
|
||||
@@ -668,8 +653,7 @@ $(function () {
|
||||
var isFontAwesomeV5 = GLOBAL_CONFIG.isFontAwesomeV5
|
||||
var $darkModeButtom = $('#darkmode')
|
||||
if (typeof autoChangeMode !== 'undefined') {
|
||||
if (Cookies.get('theme') === 'dark') changeLightIcon()
|
||||
else changeDarkIcon()
|
||||
document.documentElement.getAttribute('data-theme') === 'dark' ? changeLightIcon() : changeDarkIcon()
|
||||
}
|
||||
|
||||
function changeLightIcon () {
|
||||
@@ -752,4 +736,16 @@ $(function () {
|
||||
margins: 4
|
||||
})
|
||||
})
|
||||
|
||||
function addPhotoFigcaption () {
|
||||
var images = $('#article-container img')
|
||||
images.each(function (i, o) {
|
||||
var $this = $(o)
|
||||
if ($this.attr('alt')) {
|
||||
var t = $('<div class="img-alt is-center">' + $this.attr('alt') + '</div>')
|
||||
$this.after(t)
|
||||
}
|
||||
})
|
||||
}
|
||||
if (GLOBAL_CONFIG.isPhotoFigcaption) addPhotoFigcaption()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user