mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-10 21:17:07 +08:00
feat: 可配置 typed.js 的參數 closed #1154
fix: 修復 typeJSFn 重複賦值的 bug fix: 修復固定狀態欄後,標題有陰影的 bug fix: 修復 gallery 標籤將圖片鏈接截斷導致404無法加載圖片的 bug closed #1160 fix: 修復開啟導航欄固定後,點擊部分滾動向上的按鈕,滾動的目標部分被導航欄遮擋的 bug closed #1158 fix: 修復固定導航欄後,toc 被遮擋的 closed #1159 fix: 切換簡繁時,會改變 html 的 lang 屬性
This commit is contained in:
10
_config.yml
10
_config.yml
@@ -625,12 +625,9 @@ subtitle:
|
|||||||
enable: false
|
enable: false
|
||||||
# Typewriter Effect (打字效果)
|
# Typewriter Effect (打字效果)
|
||||||
effect: true
|
effect: true
|
||||||
# Effect Speed Options (打字效果速度參數)
|
# Customize typed.js (配置typed.js)
|
||||||
startDelay: 300 # time before typing starts in milliseconds
|
# https://github.com/mattboldt/typed.js/#customization
|
||||||
typeSpeed: 150 # type speed in milliseconds
|
typed_option:
|
||||||
backSpeed: 50 # backspacing speed in milliseconds
|
|
||||||
# loop (循環打字)
|
|
||||||
loop: true
|
|
||||||
# source 調用第三方服務
|
# source 調用第三方服務
|
||||||
# source: false 關閉調用
|
# source: false 關閉調用
|
||||||
# source: 1 調用一言網的一句話(簡體) https://hitokoto.cn/
|
# source: 1 調用一言網的一句話(簡體) https://hitokoto.cn/
|
||||||
@@ -958,3 +955,4 @@ CDN:
|
|||||||
# prismjs_autoloader:
|
# prismjs_autoloader:
|
||||||
# artalk_js:
|
# artalk_js:
|
||||||
# artalk_css:
|
# artalk_css:
|
||||||
|
# busuanzi:
|
||||||
|
|||||||
@@ -28,7 +28,9 @@ else
|
|||||||
- var top_img = false
|
- var top_img = false
|
||||||
- var isHomeClass = 'not-top-img'
|
- var isHomeClass = 'not-top-img'
|
||||||
|
|
||||||
header#page-header(class=isHomeClass style=bg_img)
|
- const isFixedClass = theme.nav.fixed ? ' fixed' : ''
|
||||||
|
|
||||||
|
header#page-header(class=`${isHomeClass+isFixedClass}` style=bg_img)
|
||||||
!=partial('includes/header/nav', {}, {cache: true})
|
!=partial('includes/header/nav', {}, {cache: true})
|
||||||
if top_img !== false
|
if top_img !== false
|
||||||
if is_post()
|
if is_post()
|
||||||
|
|||||||
104
layout/includes/third-party/subtitle.pug
vendored
104
layout/includes/third-party/subtitle.pug
vendored
@@ -1,6 +1,30 @@
|
|||||||
- const { effect,loop,source,sub,startDelay,typeSpeed,backSpeed } = theme.subtitle
|
- const { effect,source,sub,typed_option } = theme.subtitle
|
||||||
- let subContent = sub || new Array()
|
- let subContent = sub || new Array()
|
||||||
|
|
||||||
|
script.
|
||||||
|
window.typedJSFn = {
|
||||||
|
init: (str) => {
|
||||||
|
window.typed = new Typed('#subtitle', Object.assign({
|
||||||
|
strings: str,
|
||||||
|
startDelay: 300,
|
||||||
|
typeSpeed: 150,
|
||||||
|
loop: true,
|
||||||
|
backSpeed: 50,
|
||||||
|
}, !{JSON.stringify(typed_option)}))
|
||||||
|
},
|
||||||
|
run: (subtitleType) => {
|
||||||
|
if (!{effect}) {
|
||||||
|
if (typeof Typed === 'function') {
|
||||||
|
subtitleType()
|
||||||
|
} else {
|
||||||
|
getScript('!{url_for(theme.asset.typed)}').then(subtitleType)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
subtitleType()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case source
|
case source
|
||||||
when 1
|
when 1
|
||||||
script.
|
script.
|
||||||
@@ -12,28 +36,13 @@ case source
|
|||||||
const from = '出自 ' + data.from
|
const from = '出自 ' + data.from
|
||||||
const sub = !{JSON.stringify(subContent)}
|
const sub = !{JSON.stringify(subContent)}
|
||||||
sub.unshift(data.hitokoto, from)
|
sub.unshift(data.hitokoto, from)
|
||||||
window.typed = new Typed('#subtitle', {
|
typedJSFn.init(sub)
|
||||||
strings: sub,
|
|
||||||
startDelay: !{startDelay},
|
|
||||||
typeSpeed: !{typeSpeed},
|
|
||||||
loop: !{loop},
|
|
||||||
backSpeed: !{backSpeed},
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
document.getElementById('subtitle').innerHTML = data.hitokoto
|
document.getElementById('subtitle').innerHTML = data.hitokoto
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
typedJSFn.run(subtitleType)
|
||||||
if (!{effect}) {
|
|
||||||
if (typeof Typed === 'function') {
|
|
||||||
subtitleType()
|
|
||||||
} else {
|
|
||||||
getScript('!{url_for(theme.asset.typed)}').then(subtitleType)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
subtitleType()
|
|
||||||
}
|
|
||||||
|
|
||||||
when 2
|
when 2
|
||||||
script.
|
script.
|
||||||
@@ -44,28 +53,13 @@ case source
|
|||||||
const from = '出自 ' + str[1]
|
const from = '出自 ' + str[1]
|
||||||
const sub = !{JSON.stringify(subContent)}
|
const sub = !{JSON.stringify(subContent)}
|
||||||
sub.unshift(con, from)
|
sub.unshift(con, from)
|
||||||
window.typed = new Typed('#subtitle', {
|
typedJSFn.init(sub)
|
||||||
strings: sub,
|
|
||||||
startDelay: !{startDelay},
|
|
||||||
typeSpeed: !{typeSpeed},
|
|
||||||
loop: !{loop},
|
|
||||||
backSpeed: !{backSpeed},
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
document.getElementById('subtitle').innerHTML = con
|
document.getElementById('subtitle').innerHTML = con
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
typedJSFn.run(subtitleType)
|
||||||
if (!{effect}) {
|
|
||||||
if (typeof Typed === 'function') {
|
|
||||||
subtitleType()
|
|
||||||
} else {
|
|
||||||
getScript('!{url_for(theme.asset.typed)}').then(subtitleType)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
subtitleType()
|
|
||||||
}
|
|
||||||
|
|
||||||
when 3
|
when 3
|
||||||
script.
|
script.
|
||||||
@@ -76,53 +70,23 @@ case source
|
|||||||
const sub = !{JSON.stringify(subContent)}
|
const sub = !{JSON.stringify(subContent)}
|
||||||
const content = result.data.content
|
const content = result.data.content
|
||||||
sub.unshift(content)
|
sub.unshift(content)
|
||||||
window.typed = new Typed('#subtitle', {
|
typedJSFn.init(sub)
|
||||||
strings: sub,
|
|
||||||
startDelay: !{startDelay},
|
|
||||||
typeSpeed: !{typeSpeed},
|
|
||||||
loop: !{loop},
|
|
||||||
backSpeed: !{backSpeed},
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
document.getElementById('subtitle').innerHTML = result.data.content
|
document.getElementById('subtitle').innerHTML = result.data.content
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
typedJSFn.run(subtitleType)
|
||||||
if (!{effect}) {
|
|
||||||
if (typeof Typed === 'function') {
|
|
||||||
subtitleType()
|
|
||||||
} else {
|
|
||||||
getScript('!{url_for(theme.asset.typed)}').then(subtitleType)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
subtitleType()
|
|
||||||
}
|
|
||||||
|
|
||||||
default
|
default
|
||||||
- subContent = subContent.length ? subContent : new Array(config.subtitle)
|
- subContent = subContent.length ? subContent : new Array(config.subtitle)
|
||||||
script.
|
script.
|
||||||
function subtitleType () {
|
function subtitleType () {
|
||||||
if (!{effect}) {
|
if (!{effect}) {
|
||||||
window.typed = new Typed("#subtitle", {
|
typedJSFn.init(!{JSON.stringify(subContent)})
|
||||||
strings: !{JSON.stringify(subContent)},
|
|
||||||
startDelay: !{startDelay},
|
|
||||||
typeSpeed: !{typeSpeed},
|
|
||||||
loop: !{loop},
|
|
||||||
backSpeed: !{backSpeed}
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
document.getElementById("subtitle").innerHTML = '!{subContent[0]}'
|
document.getElementById("subtitle").innerHTML = '!{subContent[0]}'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
typedJSFn.run(subtitleType)
|
||||||
if (!{effect}) {
|
|
||||||
if (typeof Typed === 'function') {
|
|
||||||
subtitleType()
|
|
||||||
} else {
|
|
||||||
getScript('!{url_for(theme.asset.typed)}').then(subtitleType)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
subtitleType()
|
|
||||||
}
|
|
||||||
@@ -15,7 +15,7 @@ function gallery (args, content) {
|
|||||||
const rowHeight = args[1] || 220
|
const rowHeight = args[1] || 220
|
||||||
const limit = args[2] || 10
|
const limit = args[2] || 10
|
||||||
const lazyload = args[0] === 'true'
|
const lazyload = args[0] === 'true'
|
||||||
const regex = /!\[(.*?)\]\((.*?)\s*(?:["'](.*?)["']?)?\s*\)/g
|
const regex = /!\[(.*?)\]\(([^\s]*)\s*(?:["'](.*?)["']?)?\s*\)/g
|
||||||
const lazyloadClass = lazyload ? 'lazyload' : ''
|
const lazyloadClass = lazyload ? 'lazyload' : ''
|
||||||
let m
|
let m
|
||||||
const arr = []
|
const arr = []
|
||||||
|
|||||||
@@ -124,7 +124,8 @@
|
|||||||
background: rgba(255, 255, 255, .8)
|
background: rgba(255, 255, 255, .8)
|
||||||
box-shadow: 0 5px 6px -5px rgba(133, 133, 133, .6)
|
box-shadow: 0 5px 6px -5px rgba(133, 133, 133, .6)
|
||||||
|
|
||||||
a
|
a,
|
||||||
|
.site-name
|
||||||
color: var(--font-color)
|
color: var(--font-color)
|
||||||
text-shadow: none
|
text-shadow: none
|
||||||
|
|
||||||
@@ -137,10 +138,6 @@
|
|||||||
box-shadow: 0 5px 6px -5px alpha($grey, .6)
|
box-shadow: 0 5px 6px -5px alpha($grey, .6)
|
||||||
transition: transform .2s ease-in-out, opacity .2s ease-in-out
|
transition: transform .2s ease-in-out, opacity .2s ease-in-out
|
||||||
|
|
||||||
&.fixed
|
|
||||||
top: 0
|
|
||||||
transition: all .5s
|
|
||||||
|
|
||||||
#blog-info
|
#blog-info
|
||||||
color: var(--font-color)
|
color: var(--font-color)
|
||||||
|
|
||||||
@@ -158,8 +155,13 @@
|
|||||||
&:hover
|
&:hover
|
||||||
color: $light-blue
|
color: $light-blue
|
||||||
|
|
||||||
&.nav-visible
|
&.fixed
|
||||||
#nav:not(.fixed)
|
#nav
|
||||||
|
top: 0
|
||||||
|
transition: all .5s
|
||||||
|
|
||||||
|
&.nav-visible:not(.fixed)
|
||||||
|
#nav
|
||||||
transition: all .5s
|
transition: all .5s
|
||||||
transform: translate3d(0, 100%, 0)
|
transform: translate3d(0, 100%, 0)
|
||||||
|
|
||||||
@@ -168,6 +170,19 @@
|
|||||||
top: 70px
|
top: 70px
|
||||||
transition: top .5s
|
transition: top .5s
|
||||||
|
|
||||||
|
&.fixed
|
||||||
|
#nav
|
||||||
|
position: fixed
|
||||||
|
|
||||||
|
& + .layout
|
||||||
|
& > .aside-content > .sticky_layout
|
||||||
|
top: 70px
|
||||||
|
transition: top .5s
|
||||||
|
|
||||||
|
#card-toc
|
||||||
|
.toc-content
|
||||||
|
max-height: calc(100vh - 170px)
|
||||||
|
|
||||||
#page
|
#page
|
||||||
h1.page-title
|
h1.page-title
|
||||||
margin: 8px 0 20px
|
margin: 8px 0 20px
|
||||||
@@ -265,9 +280,6 @@
|
|||||||
&.show
|
&.show
|
||||||
opacity: 1
|
opacity: 1
|
||||||
|
|
||||||
&.fixed
|
|
||||||
position: fixed
|
|
||||||
|
|
||||||
#blog-info
|
#blog-info
|
||||||
flex: 1
|
flex: 1
|
||||||
color: var(--light-grey)
|
color: var(--light-grey)
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -122,7 +122,8 @@ const btf = {
|
|||||||
|
|
||||||
scrollToDest: (pos, time = 500) => {
|
scrollToDest: (pos, time = 500) => {
|
||||||
const currentPos = window.pageYOffset
|
const currentPos = window.pageYOffset
|
||||||
if (currentPos > pos) pos = pos - 70
|
const isNavFixed = document.getElementById('page-header').classList.contains('fixed')
|
||||||
|
if (currentPos > pos || isNavFixed) pos = pos - 70
|
||||||
|
|
||||||
if ('scrollBehavior' in document.documentElement.style) {
|
if ('scrollBehavior' in document.documentElement.style) {
|
||||||
window.scrollTo({
|
window.scrollTo({
|
||||||
|
|||||||
Reference in New Issue
Block a user