mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-16 20:30:53 +08:00
🏷️ 2.3.0發佈
This commit is contained in:
@@ -67,7 +67,7 @@ hexo.extend.helper.register('aside_archives', function (options = {}) {
|
||||
return this.url_for(url)
|
||||
}
|
||||
|
||||
result += '<ul class="archive-list">'
|
||||
result += '<ul class="card-archive-list">'
|
||||
|
||||
const len = data.length
|
||||
const Judge = limit === 0 ? len : Math.min(len, limit)
|
||||
@@ -75,23 +75,24 @@ hexo.extend.helper.register('aside_archives', function (options = {}) {
|
||||
for (let i = 0; i < Judge; i++) {
|
||||
const item = data[i]
|
||||
|
||||
result += '<li class="archive-list-item">'
|
||||
result += '<li class="card-archive-list-item">'
|
||||
|
||||
result += `<a class="archive-list-link" href="${link(item)}">`
|
||||
result += '<span class="archive-list-date">'
|
||||
result += `<a class="card-archive-list-link" href="${link(item)}">`
|
||||
result += '<span class="card-archive-list-date">'
|
||||
result += transform ? transform(item.name) : item.name
|
||||
result += '</span>'
|
||||
|
||||
if (showCount) {
|
||||
result += `<span class="archive-list-count">${item.count}</span>`
|
||||
result += `<span class="card-archive-list-count">${item.count}</span>`
|
||||
}
|
||||
result += '</a>'
|
||||
result += '</li>'
|
||||
}
|
||||
|
||||
if (len > Judge) {
|
||||
result += '<li class="archive-list-item is-center">'
|
||||
result += `<a class="archive-list-link-more" href="${this.url_for(archiveDir)}">${moreButton}</a></li>`
|
||||
result += '<li class="card-archive-list-item more is-center">'
|
||||
result += `<a class="card-archive-list-link-more" href="${this.url_for(archiveDir)}">
|
||||
<span>${moreButton}</span><i class="fa fa-angle-right" aria-hidden="true"></i></a></li>`
|
||||
}
|
||||
result += '</ul>'
|
||||
return result
|
||||
|
||||
@@ -6,7 +6,10 @@
|
||||
'use strict'
|
||||
|
||||
hexo.extend.helper.register('aside_categories', function (categories, options) {
|
||||
if (!options && (!categories || !Object.prototype.hasOwnProperty.call(categories, 'length'))) {
|
||||
if (
|
||||
!options &&
|
||||
(!categories || !Object.prototype.hasOwnProperty.call(categories, 'length'))
|
||||
) {
|
||||
options = categories
|
||||
categories = this.site.categories
|
||||
}
|
||||
@@ -14,23 +17,28 @@ hexo.extend.helper.register('aside_categories', function (categories, options) {
|
||||
if (!categories || !categories.length) return ''
|
||||
options = options || {}
|
||||
const { config } = this
|
||||
const showCount = Object.prototype.hasOwnProperty.call(options, 'show_count') ? options.show_count : true
|
||||
const showCount = Object.prototype.hasOwnProperty.call(options, 'show_count')
|
||||
? options.show_count
|
||||
: true
|
||||
const depth = options.depth ? parseInt(options.depth, 10) : 0
|
||||
const orderby = options.orderby || 'name'
|
||||
const order = options.order || 1
|
||||
const categoryDir = this.url_for(config.category_dir)
|
||||
const limit = options.limit === 0 ? categories.length : options.limit
|
||||
const buttonLabel = this._p('aside.more_button')
|
||||
const prepareQuery = parent => {
|
||||
const prepareQuery = (parent) => {
|
||||
const query = {}
|
||||
if (parent) {
|
||||
query.parent = parent
|
||||
} else {
|
||||
query.parent = {
|
||||
$exists: false
|
||||
$exists: false,
|
||||
}
|
||||
}
|
||||
return categories.find(query).sort(orderby, order).filter(cat => cat.length)
|
||||
return categories
|
||||
.find(query)
|
||||
.sort(orderby, order)
|
||||
.filter((cat) => cat.length)
|
||||
}
|
||||
|
||||
const hierarchicalList = (t, level, parent) => {
|
||||
@@ -46,20 +54,22 @@ hexo.extend.helper.register('aside_categories', function (categories, options) {
|
||||
t = childList[1]
|
||||
}
|
||||
|
||||
result += '<li class="aside-category-list-item">'
|
||||
result += '<li class="card-category-list-item">'
|
||||
|
||||
result += `<a class="aside-category-list-link" href="${this.url_for(cat.path)}">`
|
||||
result += `<span class="aside-category-list-name">${cat.name}</span>`
|
||||
result += `<a class="card-category-list-link" href="${this.url_for(
|
||||
cat.path
|
||||
)}">`
|
||||
result += `<span class="card-category-list-name">${cat.name}</span>`
|
||||
|
||||
if (showCount) {
|
||||
result += `<span class="aside-category-list-count">${cat.length}</span>`
|
||||
result += `<span class="card-category-list-count">${cat.length}</span>`
|
||||
}
|
||||
|
||||
result += '</a>'
|
||||
result += '</li>'
|
||||
|
||||
if (child) {
|
||||
result += `<ul class="aside-category-list child">${child}</ul>`
|
||||
result += `<ul class="card-category-list child">${child}</ul>`
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -73,14 +83,14 @@ hexo.extend.helper.register('aside_categories', function (categories, options) {
|
||||
var moreButton = function () {
|
||||
var moreHtml = ''
|
||||
if (categories.length <= limit) return ''
|
||||
moreHtml += '<li class="aside-category-list-item is-center">'
|
||||
moreHtml += `<a class="aside-category-list-item-more" href="${categoryDir}" >`
|
||||
moreHtml += buttonLabel
|
||||
moreHtml += '</a></li>'
|
||||
moreHtml += '<li class="card-category-list-item more is-center">'
|
||||
moreHtml += `<a class="card-category-list-link-more" href="${categoryDir}">
|
||||
<span>${buttonLabel}</span><i class="fa fa-angle-right" aria-hidden="true"></i></a></li>`
|
||||
|
||||
return moreHtml
|
||||
}
|
||||
|
||||
return `<ul class="aside-category-list">
|
||||
return `<ul class="card-category-list">
|
||||
${list[0]}
|
||||
${moreButton()}
|
||||
</ul>`
|
||||
|
||||
@@ -31,8 +31,13 @@ hexo.extend.helper.register('injectHtml', function (data) {
|
||||
return result
|
||||
})
|
||||
|
||||
hexo.extend.helper.register('cloudTags', function (source, minfontsize, maxfontsize, limit) {
|
||||
hexo.extend.helper.register('cloudTags', function (options = {}) {
|
||||
const env = this
|
||||
const source = options.source
|
||||
const minfontsize = options.minfontsize
|
||||
const maxfontsize = options.maxfontsize
|
||||
const limit = options.limit || 8
|
||||
|
||||
let result = ''
|
||||
const tagLimit = limit === 0 ? source.length : limit
|
||||
source.sort('name').limit(tagLimit).forEach(function (tags) {
|
||||
|
||||
Reference in New Issue
Block a user