mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-10-04 06:22:00 +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:
1 parent
929a5608d3
commit
396fb102da
7 files changed
+108
-112
No files matched your search
+4
-6
@@ -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()
|
||||||
|
|||||||
+34
-70
@@ -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()
|
|
||||||
}
|
|
||||||
Loaded 3 of 7 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user