feat: 不再支持 butterfly.yml 寫法

improvement: 文章頁標題改為h1(seo)
improvement: 改用hexo 內置的 injector 插入 inject 的代碼
improvement: canonical 改為hexo提供的函數生成
improvement: 優化手機toc 的特效和按鈕出現的時機
remove: 刪除搜索不必要的配置
remove: 移除豆瓣配置,如需配置,請使用 hexo-butterfly-douban
fix: 修復上一個版本導致的搜索按鈕在pjax下無法點擊的bugs close #387
fix: 修復上一個版本更新的toc z-index 過低的bugs
pull/392/head
Jerry 4 years ago
parent 83b7232841
commit 8014ddb65e

@ -53,17 +53,9 @@ algolia_search:
hits:
per_page: 6
labels:
input_placeholder: Search for Posts
hits_empty: "We didn't find any results for the search: ${query}" # if there are no result
hits_stats: '${hits} results found in ${time} ms'
# Local search
local_search:
enable: false
labels:
input_placeholder: Search for Posts
hits_empty: "We didn't find any results for the search: ${query}" # if there are no result
# Math (數學)
# --------------------------------------
@ -108,7 +100,7 @@ archive_img:
tag_img:
# The banner image of tag page
# format:
# format:
# - tag name: xxxxx
tag_per_img:
@ -117,17 +109,10 @@ tag_per_img:
category_img:
# The banner image of category page
# format:
# format:
# - category name: xxxxx
category_per_img:
# If you are using hexo-douban, you can configure it (如果你有使用 hexo-douban,可配置這個)
# douban:
# meta: false
# movies_img:
# books_img:
# games_img:
cover:
# display the cover or not (是否顯示文章封面)
index_enable: true
@ -576,9 +561,9 @@ font:
# Font settings for the site title and site subtitle
# 左上角網站名字 主頁居中網站名字
# blog_title_font:
# font_link: https://fonts.googleapis.com/css?family=Titillium+Web&display=swap
# font-family: Titillium Web, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif
blog_title_font:
font_link:
font-family:
# The setting of divider icon (水平分隔線圖標設置)
hr_icon:
@ -919,4 +904,4 @@ CDN:
prismjs_lineNumber_js: https://cdn.jsdelivr.net/npm/prismjs/plugins/line-numbers/prism-line-numbers.min.js
prismjs_autoloader: https://cdn.jsdelivr.net/npm/prismjs/plugins/autoloader/prism-autoloader.min.js
artitalk: https://cdn.jsdelivr.net/npm/artitalk
artitalk: https://cdn.jsdelivr.net/npm/artitalk

@ -71,7 +71,7 @@ aside:
site_pv_name: PV
more_button: More
card_newest_comments:
heading: Newest Comments
headline: Newest Comments
loading_text: loading...
error: Unable to get the data, please make sure the settings are correct.
card_toc: Catalog

@ -71,7 +71,7 @@ aside:
site_pv_name: PV
more_button: More
card_newest_comments:
heading: Newest Comments
headline: Newest Comments
loading_text: loading...
error: Unable to get the data, please make sure the settings are correct.
card_toc: Catalog

@ -73,7 +73,7 @@ aside:
site_pv_name: 本站总访问量
more_button: 查看更多
card_newest_comments:
heading: 最新评论
headline: 最新评论
loading_text: 正在加载中...
error: 无法获取资料,请确认相关配置是否正确
card_toc: 目录

@ -73,7 +73,7 @@ aside:
site_pv_name: 本站總訪問量
more_button: 檢視更多
card_newest_comments:
heading: 最新評論
headline: 最新評論
loading_text: 正在加載中...
error: 無法獲取資料,請確認相關配置是否正確
card_toc: 目錄

@ -55,8 +55,6 @@ div
else if (!is_post() && page.aside !== false)
!=partial('includes/third-party/newest-comments/index', {}, {cache:theme.fragment_cache})
!=fragment_cache('injectBottom', function(){return injectHtml(theme.inject.bottom)})
!=partial('includes/third-party/effect', {}, {cache:theme.fragment_cache})
!=partial('includes/third-party/chat/index', {}, {cache:theme.fragment_cache})

@ -81,5 +81,3 @@ include ./head/noscript.pug
!=partial('includes/head/darkmode', {}, {cache:theme.fragment_cache})
!=fragment_cache('injectHead', function(){return injectHtml(theme.inject.head)})

@ -16,18 +16,6 @@ if page.top_img !== false
else
- var top_img = page.top_img || theme.default_top_img
if theme.douban
- var doubanExist = false
if is_current('/movies/', [strict])
- var top_img = theme.douban.movies_img !== false ? theme.douban.movies_img || theme.default_top_img : false
- doubanExist = true
else if is_current('/books/', [strict])
- var top_img = theme.douban.books_img !== false ? theme.douban.books_img || theme.default_top_img : false
- doubanExist = true
else if is_current('/games/', [strict])
- var top_img = theme.douban.games_img !== false ? theme.douban.games_img || theme.default_top_img : false
- doubanExist = true
if top_img !== false
- var imgSource = top_img && top_img.indexOf('/') !== -1 ? `background-image: url(${url_for(top_img)})` : `background: ${top_img}`
- var bg_img = top_img ? imgSource : ''

@ -1,6 +1,5 @@
#post-info
#post-title
.posttitle= page.title || _p('no_title')
h1.post-title= page.title || _p('no_title')
#post-meta
.meta-firstline

@ -1,5 +1,3 @@
if theme.douban && theme.douban.meta && doubanExist
meta(name="referrer" content="no-referrer")
#article-container
if top_img === false
h1.page-title= page.title

@ -2,6 +2,6 @@
.card-content
.item-headline
i.fas.fa-bolt
span= _p('aside.card_newest_comments.heading')
span= _p('aside.card_newest_comments.headline')
.aside-list
span= _p('aside.card_newest_comments.loading_text')

@ -1,6 +1,6 @@
{
"name": "hexo-theme-butterfly",
"version": "3.3.0-b2",
"version": "3.3.0-b3",
"description": "A Simple and Card UI Design theme for Hexo",
"main": "package.json",
"scripts": {

@ -9,4 +9,13 @@ hexo.extend.filter.register('before_generate', () => {
logger.error('請把 Hexo 升級到 V5.0.0 或更高的版本!')
process.exit(-1)
}
if (hexo.locals.get) {
const data = hexo.locals.get('data')
if (data && data.butterfly) {
logger.error(" 'butterfly.yml' is deprecated. Please use '_config.butterfly.yml' ")
logger.error(" 'butterfly.yml' 已經棄用,請使用 '_config.butterfly.yml' ")
process.exit(-1)
}
}
})

@ -1,18 +0,0 @@
/**
* Note: configs in _data/butterfly.yml will merge configs with hexo.theme.config.
*/
'use strict'
const { deepMerge } = require('hexo-util')
hexo.on('generateBefore', function () {
const rootConfig = hexo.config
if (hexo.locals.get) {
const data = hexo.locals.get('data')
if (data && data.butterfly) {
hexo.theme.config = deepMerge(hexo.theme.config, data.butterfly)
}
}
hexo.theme.config.rootConfig = rootConfig
})

@ -6,7 +6,8 @@
'use strict'
hexo.extend.filter.register('before_post_render', function (data) {
if (hexo.theme.config.rootConfig.post_asset_folder) {
const { config } = this
if (config.post_asset_folder) {
const imgTestReg = /\.(png|jpe?g|gif|svg|webp)(\?.*)?$/
const topImg = data.top_img
const cover = data.cover

@ -2,13 +2,12 @@
* Butterfly
* @example
* page_description()
* injectHtml(data)
* cloudTags(source, minfontsize, maxfontsize, limit)
*/
'use strict'
const { stripHTML, escapeHTML } = require('hexo-util')
const { stripHTML, escapeHTML, prettyUrls } = require('hexo-util')
const crypto = require('crypto')
hexo.extend.helper.register('page_description', function () {
@ -23,15 +22,6 @@ hexo.extend.helper.register('page_description', function () {
}
})
hexo.extend.helper.register('injectHtml', function (data) {
let result = ''
if (!data) return ''
for (let i = 0; i < data.length; i++) {
result += data[i]
}
return result
})
hexo.extend.helper.register('cloudTags', function (options = {}) {
const env = this
let source = options.source
@ -65,12 +55,7 @@ hexo.extend.helper.register('cloudTags', function (options = {}) {
})
hexo.extend.helper.register('urlNoIndex', function () {
const { permalink } = hexo.config
let url = this.url.replace(/index\.html$/, '')
if (!permalink.endsWith('.html')) {
url = url.replace(/\.html$/, '')
}
return url
return prettyUrls(this.url, { trailing_index: false, trailing_html: false })
})
hexo.extend.helper.register('md5', function (path) {

@ -35,7 +35,7 @@ hexo.extend.helper.register('related_posts', function (currentPost, allPosts) {
return ''
}
let result = ''
const hexoConfig = hexo.theme.config.rootConfig
const hexoConfig = hexo.config
const config = hexo.theme.config
const limitNum = config.related_post.limit || 6

@ -0,0 +1,22 @@
// Injector
'use strict'
hexo.extend.injector.register('head_end', function () {
const data = hexo.config.theme_config && hexo.config.theme_config.inject.head
return genResult(data)
})
hexo.extend.injector.register('body_end', () => {
const data = hexo.config.theme_config && hexo.config.theme_config.inject.bottom
return genResult(data)
})
function genResult (data) {
let result = ''
if (!data) return ''
for (let i = 0; i < data.length; i++) {
result += data[i]
}
return result
}

@ -152,12 +152,13 @@ a
color: $light-blue
// font
#site-title,
#site-subtitle,
#site-name,
#aside_content .author-info__name,
#aside_content .author-info__description
font-family: $site-name-font
if $site-name-font
#site-title,
#site-subtitle,
#site-name,
#aside_content .author-info__name,
#aside_content .author-info__description
font-family: $site-name-font
.is-center
text-align: center

@ -126,6 +126,7 @@ blockquote
text-transform: uppercase
font-weight: bold
font-size: 1.15em
user-select: none
.copy-notice
position: absolute

@ -45,7 +45,8 @@ if hexo-config('error_404.enable')
padding: .5rem
text-align: center
font-size: 14px
font-family: $site-name-font
if $site-name-font
font-family: $site-name-font
+maxWidth768()
flex: 1.1

@ -269,15 +269,11 @@
position: fixed
right: 45px
bottom: 30px
z-index: 9999
z-index: 100
display: none
width: 300px
transform-origin: right bottom
animation: toc-close .3s
&.open
display: block
animation: toc-open .3s
animation: toc-open .3s
.toc-child
display: block !important
@ -327,7 +323,7 @@
@keyframes toc-close
0%
transform: scale(.7)
transform: scale(1)
100%
transform: scale(1)
transform: scale(.7)

@ -130,19 +130,18 @@
padding: 0 1.1rem
#post-info
#post-title
.post-title
@extend .limit-more-line
margin-bottom: .4rem
font-size: 2.5em
font-weight: normal
color: var(--white)
line-height: 1.5
-webkit-line-clamp: 3
+maxWidth768()
font-size: 1.72em
.posttitle
@extend .limit-more-line
color: var(--white)
line-height: 1.5
-webkit-line-clamp: 3
#post-meta
color: var(--light-grey)
font-size: 95%
@ -189,7 +188,7 @@
& > #post-info
margin-bottom: 1.5rem
.posttitle
.post-title
padding-bottom: .2rem
border-bottom: 1px solid var(--light-grey)
color: var(--text-highlight-color)

@ -36,5 +36,5 @@
#mobile-toc-button
display: none
+maxWidth1024()
+maxWidth900()
display: block

@ -17,7 +17,7 @@ $dafault-font-family = -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica
$dafault-code-font = consolas, Menlo, 'PingFang SC', 'Microsoft YaHei', sans-serif
$font-family = hexo-config('font.font-family') ? unquote(hexo-config('font.font-family')) : $dafault-font-family
$code-font-family = hexo-config('font.code-font-family') ? unquote(hexo-config('font.code-font-family')) : $dafault-code-font
$site-name-font = hexo-config('blog_title_font.font-family') ? unquote(hexo-config('blog_title_font.font-family')) : $font-family
$site-name-font = hexo-config('blog_title_font.font-family') && unquote(hexo-config('blog_title_font.font-family'))
// hr
$hrEnable = hexo-config('hr_icon') && hexo-config('hr_icon.enable')
$hr-icon = $hrEnable && hexo-config('hr_icon.icon') ? hexo-config('hr_icon.icon') : '\f0c4'

@ -351,11 +351,14 @@ $(function () {
const mobileToc = {
open: () => {
$cardTocLayout.addClass('open')
$cardTocLayout.css('display', 'block')
},
close: () => {
$cardTocLayout.removeClass('open')
$cardTocLayout.css('animation', 'toc-close .2s')
setTimeout(() => {
$cardTocLayout.css({ display: '', animation: '' })
}, 100)
}
}

@ -36,7 +36,7 @@ $(function () {
searchClickFn()
window.addEventListener('pjax:send', function () {
window.addEventListener('pjax:complete', function () {
closeSearch()
searchClickFn()
})

@ -47,7 +47,8 @@ $(function () {
}
searchClickFn()
window.addEventListener('pjax:send', function () {
window.addEventListener('pjax:complete', function () {
$('#local-search').is(':visible') && closeSearch()
searchClickFn()
})

Loading…
Cancel
Save