Skip to content

Commit

Permalink
🚀 升级主题版本至 4.2.0 - b2
Browse files Browse the repository at this point in the history
  • Loading branch information
CCKNBC committed Apr 17, 2022
1 parent 1313f98 commit 45dc51c
Show file tree
Hide file tree
Showing 11 changed files with 291 additions and 207 deletions.
234 changes: 130 additions & 104 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions themes/butterfly/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ algolia_search:
# Local search
local_search:
enable: false
preload: false
CDN:

# Math (數學)
# --------------------------------------
Expand Down
3 changes: 2 additions & 1 deletion themes/butterfly/layout/includes/head/config.pug
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
let localSearch = 'undefined';
if (theme.local_search && theme.local_search.enable) {
localSearch = JSON.stringify({
path: config.search.path,
path: theme.local_search.CDN ? theme.local_search.CDN : config.root + config.search.path,
preload: theme.local_search.preload,
languages: {
// search languages
hits_empty: _p("search.local_search.hits_empty"),
Expand Down
2 changes: 1 addition & 1 deletion themes/butterfly/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hexo-theme-butterfly",
"version": "4.2.0-b1",
"version": "4.2.0-b2",
"description": "A Simple and Card UI Design theme for Hexo",
"main": "package.json",
"scripts": {
Expand Down
5 changes: 3 additions & 2 deletions themes/butterfly/scripts/helpers/related_post.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,15 @@ hexo.extend.helper.register('related_posts', function (currentPost, allPosts) {
relatedPosts[i].cover === false
? relatedPosts[i].randomcover
: relatedPosts[i].cover
result += `<div><a href="${this.url_for(relatedPosts[i].path)}" title="${this.escape_html(relatedPosts[i].title)}">`
const title = this.escape_html(relatedPosts[i].title)
result += `<div><a href="${this.url_for(relatedPosts[i].path)}" title="${title}">`
result += `<img class="cover" src="${this.url_for(cover)}" alt="cover">`
if (dateType === 'created') {
result += `<div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> ${this.date(relatedPosts[i].created, hexoConfig.date_format)}</div>`
} else {
result += `<div class="content is-center"><div class="date"><i class="fa-solid fa-history fa-fw"></i> ${this.date(relatedPosts[i].updated, hexoConfig.date_format)}</div>`
}
result += `<div class="title">${this.escape_html(relatedPosts[i].title)}</div>`
result += `<div class="title">${title}</div>`
result += '</div></a></div>'
}

Expand Down
1 change: 1 addition & 0 deletions themes/butterfly/source/css/_layout/third-party.styl
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ mjx-container[display],
.has-jax
overflow-x: auto
overflow-y: hidden
line-height: normal !important

.aplayer
color: $font-black
Expand Down
34 changes: 31 additions & 3 deletions themes/butterfly/source/css/_search/algolia.styl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
color: var(--search-input-color)

.ais-Hits-list
padding-left: 24px
margin: 0
padding: 0
@extend .list-beauty

a
Expand All @@ -25,12 +26,17 @@
color: $search-keyword-highlight
font-weight: bold

.algolia-hit-item-content
margin: 0 0 8px
word-break: break-all

.ais-Pagination
margin: 16px 0 0
margin: 20px 0 0
padding: 0
text-align: center

.ais-Pagination-list
margin: 0
padding: 0
list-style: none

Expand All @@ -52,9 +58,31 @@
color: #eee
cursor: default

.ais-Pagination-item--disabled
visibility: hidden

.ais-Stats-text
display: inline
float: left

.ais-PoweredBy
padding-top: 5px
display: inline
float: right
float: right

#algolia-hits
> div
overflow-y: scroll

+minWidth768()
max-height: calc(80vh - 240px)

+maxWidth768()
height: calc(100vh - 260px)

.apple
#algolia-search
#algolia-hits
> div
+maxWidth768()
height: calc(90vh - 260px)
2 changes: 1 addition & 1 deletion themes/butterfly/source/css/_search/index.styl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.search-dialog
position: fixed
top: 100px
top: 10%
left: 50%
z-index: 1001
display: none
Expand Down
2 changes: 1 addition & 1 deletion themes/butterfly/source/css/_search/local-search.styl
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@

.search-result-list
overflow-y: auto
max-height: 210px
max-height: calc(80vh - 130px)

+maxWidth768()
padding-bottom: 40px
Expand Down
17 changes: 7 additions & 10 deletions themes/butterfly/source/js/search/algolia.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,13 @@ window.addEventListener('load', () => {
return console.error('Algolia setting is invalid!')
}

const searchClient = window.algoliasearch(algolia.appId, algolia.apiKey)
const search = instantsearch({
indexName: algolia.indexName,
searchClient,
searchFunction(helper) {
if (helper.state.query) {
helper.search();
}
}
})
const search = instantsearch({
indexName: algolia.indexName,
searchClient: algoliasearch(algolia.appId, algolia.apiKey),
searchFunction(helper) {
helper.state.query && helper.search()
},
})

search.addWidgets([
instantsearch.widgets.searchBox({
Expand Down
Loading

0 comments on commit 45dc51c

Please sign in to comment.