mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-16 17:50:54 +08:00
This commit is contained in:
@@ -92,7 +92,7 @@ hexo.extend.helper.register('aside_archives', function (options = {}) {
|
||||
if (len > Judge) {
|
||||
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>`
|
||||
<span>${moreButton}</span><i class="fas fa-angle-right" ></i></a></li>`
|
||||
}
|
||||
result += '</ul>'
|
||||
return result
|
||||
|
||||
@@ -6,9 +6,7 @@
|
||||
'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
|
||||
@@ -25,47 +23,48 @@ hexo.extend.helper.register('aside_categories', function (categories, options) {
|
||||
const order = options.order || 1
|
||||
const categoryDir = this.url_for(config.category_dir)
|
||||
const limit = options.limit === 0 ? categories.length : options.limit
|
||||
const isExpand = options.expand !== 'none'
|
||||
const expandClass = isExpand && options.expand === true ? 'card-category-list-icon expand' : 'card-category-list-icon'
|
||||
|
||||
const buttonLabel = this._p('aside.more_button')
|
||||
const prepareQuery = (parent) => {
|
||||
const query = {}
|
||||
if (parent) {
|
||||
query.parent = parent
|
||||
} else {
|
||||
query.parent = {
|
||||
$exists: false,
|
||||
}
|
||||
}
|
||||
return categories
|
||||
.find(query)
|
||||
.sort(orderby, order)
|
||||
.filter((cat) => cat.length)
|
||||
if (parent) { query.parent = parent } else { query.parent = { $exists: false } }
|
||||
return categories.find(query).sort(orderby, order).filter((cat) => cat.length)
|
||||
}
|
||||
|
||||
const hierarchicalList = (t, level, parent) => {
|
||||
const hierarchicalList = (t, level, parent, topparent = true) => {
|
||||
let result = ''
|
||||
var isTopParent = topparent
|
||||
if (t > 0) {
|
||||
prepareQuery(parent).forEach((cat, i) => {
|
||||
if (t > 0) {
|
||||
t = t - 1
|
||||
let child
|
||||
if (!depth || level + 1 < depth) {
|
||||
var childList = hierarchicalList(t, level + 1, cat._id)
|
||||
var childList = hierarchicalList(t, level + 1, cat._id, false)
|
||||
child = childList[0]
|
||||
t = childList[1]
|
||||
}
|
||||
|
||||
result += '<li class="card-category-list-item">'
|
||||
var parentClass = isExpand && isTopParent && child ? 'parent' : ''
|
||||
|
||||
result += `<li class="card-category-list-item ${parentClass}">`
|
||||
|
||||
result += `<a class="card-category-list-link" href="${this.url_for(cat.path)}">`
|
||||
|
||||
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="card-category-list-count">${cat.length}</span>`
|
||||
}
|
||||
|
||||
if (isExpand && isTopParent && child) {
|
||||
result += `<i class="fas fa-caret-left ${expandClass}"></i>`
|
||||
}
|
||||
|
||||
result += '</a>'
|
||||
|
||||
result += '</li>'
|
||||
|
||||
if (child) {
|
||||
@@ -85,7 +84,7 @@ hexo.extend.helper.register('aside_categories', function (categories, options) {
|
||||
if (categories.length <= limit) return ''
|
||||
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>`
|
||||
<span>${buttonLabel}</span><i class="fas fa-angle-right"></i></a></li>`
|
||||
|
||||
return moreHtml
|
||||
}
|
||||
|
||||
@@ -41,14 +41,14 @@ hexo.extend.helper.register('related_posts', function (currentPost, allPosts) {
|
||||
var limitNum = config.related_post.limit || 6
|
||||
var dateType = config.related_post.date_type || 'created'
|
||||
var headlineLang = this._p('post.recommend')
|
||||
var lazySrc = config.lazyload ? 'data-src' : 'src'
|
||||
var lazySrc = config.lazyload.enable ? 'data-src' : 'src'
|
||||
|
||||
relatedPosts = relatedPosts.sort(compare('weight'))
|
||||
|
||||
if (relatedPosts.length > 0) {
|
||||
result += '<div class="relatedPosts">'
|
||||
result +=
|
||||
'<div class="relatedPosts_headline"><i class="fa fa-fw fa-thumbs-up" aria-hidden="true"></i><span>' +
|
||||
'<div class="relatedPosts_headline"><i class="fas fa-thumbs-up fa-fw"></i><span>' +
|
||||
' ' +
|
||||
headlineLang +
|
||||
'</span></div>'
|
||||
@@ -74,13 +74,13 @@ hexo.extend.helper.register('related_posts', function (currentPost, allPosts) {
|
||||
'">'
|
||||
if (dateType === 'created') {
|
||||
result +=
|
||||
'<div class="relatedPosts_main is-center"><div class="relatedPosts_date"><i class="fa fa-calendar fa-fw" aria-hidden="true"></i>' +
|
||||
'<div class="relatedPosts_main is-center"><div class="relatedPosts_date"><i class="far fa-calendar-alt fa-fw"></i>' +
|
||||
' ' +
|
||||
this.date(relatedPosts[i].created, hexoConfig.date_format) +
|
||||
'</div>'
|
||||
} else {
|
||||
result +=
|
||||
'<div class="relatedPosts_main is-center"><div class="relatedPosts_date"><i class="fa fa-history fa-fw" aria-hidden="true"></i>' +
|
||||
'<div class="relatedPosts_main is-center"><div class="relatedPosts_date"><i class="fas fa-history fa-fw"></i>' +
|
||||
' ' +
|
||||
this.date(relatedPosts[i].updated, hexoConfig.date_format) +
|
||||
'</div>'
|
||||
@@ -90,7 +90,7 @@ hexo.extend.helper.register('related_posts', function (currentPost, allPosts) {
|
||||
result += '</div></a></div>'
|
||||
}
|
||||
|
||||
result += '</div><div class="clear_both"></div></div>'
|
||||
result += '</div></div>'
|
||||
return result
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user