hexo-theme-solitude 1.2.1 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_config.yml +1 -0
- package/layout/includes/head/config.pug +1 -1
- package/layout/includes/inject/head.pug +2 -0
- package/layout/includes/page/equipment.pug +1 -1
- package/layout/includes/page/moments.pug +1 -1
- package/layout/includes/page/says.pug +1 -1
- package/layout/includes/page/tlink.pug +1 -1
- package/layout/includes/widgets/home/categoryBar.pug +1 -1
- package/layout/includes/widgets/third-party/search/algolia-search.pug +2 -4
- package/layout/includes/widgets/third-party/search/local-search.pug +2 -4
- package/package.json +1 -1
- package/source/css/_page/about.styl +0 -109
- package/source/css/_page/equipment.styl +0 -7
- package/source/css/_page/index.styl +110 -1
- package/source/css/_page/moment.styl +0 -7
- package/source/css/_page/says.styl +0 -6
- package/source/css/_search/algolia-search.styl +56 -108
- package/source/css/_search/local-search.styl +131 -112
- package/source/js/extend/search/algolia-search.js +146 -122
- package/source/js/extend/search/local-search.js +137 -162
- package/source/js/utils.js +30 -1
@@ -1,112 +1,131 @@
|
|
1
|
-
.search-dialog
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
#
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
.
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
.
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
1
|
+
.search-dialog
|
2
|
+
position fixed
|
3
|
+
top 5rem
|
4
|
+
left 50%
|
5
|
+
z-index 1001
|
6
|
+
display none
|
7
|
+
margin-left -15rem
|
8
|
+
padding 1rem
|
9
|
+
width 30rem
|
10
|
+
box-shadow var(--sco-shadow-lightblack)
|
11
|
+
background var(--sco-card-bg)
|
12
|
+
border var(--style-border)
|
13
|
+
transition 0.3s
|
14
|
+
border-radius 8px
|
15
|
+
|
16
|
+
&:hover
|
17
|
+
border var(--style-border-hover)
|
18
|
+
box-shadow var(--sco-shadow-theme)
|
19
|
+
|
20
|
+
+maxWidth768()
|
21
|
+
top 0
|
22
|
+
left 0
|
23
|
+
margin 0
|
24
|
+
width 100%
|
25
|
+
height 100%
|
26
|
+
|
27
|
+
.search-dialog-title
|
28
|
+
font-weight 700
|
29
|
+
color var(--sco-main)
|
30
|
+
padding 0 0 0.7rem
|
31
|
+
font-size 1.4em
|
32
|
+
line-height 1
|
33
|
+
|
34
|
+
.search-close-button
|
35
|
+
position absolute
|
36
|
+
top 0.8rem
|
37
|
+
right 1rem
|
38
|
+
color var(--sco-gray)
|
39
|
+
font-size 1.4em
|
40
|
+
line-height 1
|
41
|
+
cursor pointer
|
42
|
+
transition color .2s ease-in-out 0s
|
43
|
+
|
44
|
+
&:hover
|
45
|
+
color var(--sco-main)
|
46
|
+
|
47
|
+
#search-results
|
48
|
+
max-height calc(80vh - 130px)
|
49
|
+
overflow-y auto
|
50
|
+
margin-top 8px
|
51
|
+
|
52
|
+
.search-result-list
|
53
|
+
.search-result-title
|
54
|
+
padding-left 0
|
55
|
+
font-weight 700
|
56
|
+
position relative
|
57
|
+
transition color .2s ease-in-out 0s
|
58
|
+
|
59
|
+
&:hover
|
60
|
+
color var(--sco-main)
|
61
|
+
|
62
|
+
+maxWidth768()
|
63
|
+
max-height 80vh !important
|
64
|
+
|
65
|
+
#search-pagination
|
66
|
+
.pagination-list
|
67
|
+
margin 0.2rem 0 0
|
68
|
+
padding 0
|
69
|
+
text-align center
|
70
|
+
|
71
|
+
.pagination-item
|
72
|
+
color var(--sco-fontcolor)
|
73
|
+
display inline-block
|
74
|
+
min-width 1.2rem
|
75
|
+
height 1.2rem
|
76
|
+
text-align center
|
77
|
+
line-height 1.2rem
|
78
|
+
cursor pointer
|
79
|
+
|
80
|
+
&:hover
|
81
|
+
color var(--sco-main)
|
82
|
+
|
83
|
+
&.select
|
84
|
+
border-radius 4px
|
85
|
+
background var(--sco-main)
|
86
|
+
color var(--sco-white)
|
87
|
+
cursor default
|
88
|
+
|
89
|
+
&:hover
|
90
|
+
color var(--sco-white)
|
91
|
+
|
92
|
+
#search-tips
|
93
|
+
padding-top 12px
|
94
|
+
color var(--sco-secondtext)
|
95
|
+
right 0
|
96
|
+
margin auto
|
97
|
+
|
98
|
+
.search-result-count
|
99
|
+
color var(--sco-gray)
|
100
|
+
|
101
|
+
b
|
102
|
+
color var(--sco-main)
|
103
|
+
|
104
|
+
.search-box
|
105
|
+
position relative
|
106
|
+
margin 0 auto
|
107
|
+
max-width 100%
|
108
|
+
width 100%
|
109
|
+
padding-top 8px
|
110
|
+
margin-bottom 8px
|
111
|
+
|
112
|
+
input
|
113
|
+
height 100%
|
114
|
+
width 100%
|
115
|
+
border-radius 8px
|
116
|
+
border var(--style-border)
|
117
|
+
padding 0.25rem 0.7rem;
|
118
|
+
outline 0
|
119
|
+
background var(--sco-secondbg)
|
120
|
+
color var(--search-input-color)
|
121
|
+
|
122
|
+
#search-mask
|
123
|
+
position fixed
|
124
|
+
inset 0
|
125
|
+
z-index 1000
|
126
|
+
display none
|
127
|
+
background rgba(0, 0, 0, 0.6)
|
128
|
+
backdrop-filter blur(12px)
|
129
|
+
-webkit-backdrop-filter blur(12px)
|
130
|
+
transform translateZ(0)
|
131
|
+
background var(--sco-maskbgdeep)
|
@@ -1,140 +1,164 @@
|
|
1
|
-
window.addEventListener(
|
1
|
+
window.addEventListener("load", () => {
|
2
|
+
const $searchMask = document.getElementById("search-mask");
|
3
|
+
const $searchDialog = document.querySelector("#algolia-search .search-dialog");
|
4
|
+
|
2
5
|
const openSearch = () => {
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
document.addEventListener(
|
9
|
-
if (event.code ===
|
10
|
-
closeSearch()
|
11
|
-
document.removeEventListener(
|
6
|
+
utils.animateIn($searchMask, "to_show 0.5s");
|
7
|
+
$searchDialog.style.display = "block";
|
8
|
+
setTimeout(() => {
|
9
|
+
document.querySelector("#algolia-search .ais-SearchBox-input").focus();
|
10
|
+
}, 100);
|
11
|
+
document.addEventListener("keydown", function f(event) {
|
12
|
+
if (event.code === "Escape") {
|
13
|
+
closeSearch();
|
14
|
+
document.removeEventListener("keydown", f);
|
12
15
|
}
|
13
|
-
})
|
14
|
-
|
16
|
+
});
|
17
|
+
fixSafariHeight();
|
18
|
+
window.addEventListener("resize", fixSafariHeight);
|
19
|
+
};
|
15
20
|
|
16
21
|
const closeSearch = () => {
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
$searchDialog.style.cssText = "display: none; animation: ''"
|
22
|
-
}, 500)
|
23
|
-
utils.fadeOut(document.getElementById('search-mask'), 0.5)
|
24
|
-
}
|
22
|
+
utils.animateOut($searchDialog, "search_close .5s");
|
23
|
+
utils.animateOut($searchMask, "to_hide 0.5s");
|
24
|
+
window.removeEventListener("resize", fixSafariHeight);
|
25
|
+
};
|
25
26
|
|
26
|
-
const
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
rm.hideRightMenu();
|
32
|
-
openSearch();
|
33
|
-
let t = document.querySelector('.ais-search-box--input');
|
34
|
-
let evt = new Event('input', {bubbles: true, cancelable: true});
|
35
|
-
t.value = selectTextNow;
|
36
|
-
t.dispatchEvent(evt);
|
37
|
-
});
|
38
|
-
}
|
27
|
+
const fixSafariHeight = () => {
|
28
|
+
if (window.innerWidth < 768) {
|
29
|
+
$searchDialog.style.setProperty("--search-height", window.innerHeight + "px");
|
30
|
+
}
|
31
|
+
};
|
39
32
|
|
40
|
-
searchClickFn()
|
33
|
+
const searchClickFn = () => {
|
34
|
+
utils.addEventListenerPjax(document.querySelector("#search-button > .search"), "click", openSearch);
|
35
|
+
};
|
41
36
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
}
|
37
|
+
const searchFnOnce = () => {
|
38
|
+
$searchMask.addEventListener("click", closeSearch);
|
39
|
+
document.querySelector("#algolia-search .search-close-button").addEventListener("click", closeSearch);
|
40
|
+
};
|
46
41
|
|
47
|
-
const algolia = GLOBAL_CONFIG.algolia
|
48
|
-
const isAlgoliaValid = algolia.appId && algolia.apiKey && algolia.indexName
|
42
|
+
const algolia = GLOBAL_CONFIG.algolia;
|
43
|
+
const isAlgoliaValid = algolia.appId && algolia.apiKey && algolia.indexName;
|
49
44
|
if (!isAlgoliaValid) {
|
50
|
-
return console.error(
|
45
|
+
return console.error("Algolia setting is invalid!");
|
51
46
|
}
|
52
47
|
|
53
|
-
const searchClient = algoliasearch(
|
54
|
-
algolia.appId,
|
55
|
-
algolia.apiKey
|
56
|
-
);
|
57
|
-
|
58
48
|
const search = instantsearch({
|
59
49
|
indexName: algolia.indexName,
|
60
|
-
searchClient,
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
search.addWidget(
|
67
|
-
instantsearch.widgets.searchBox({
|
68
|
-
container: '#algolia-search-input',
|
69
|
-
showReset: false,
|
70
|
-
placeholder: GLOBAL_CONFIG.lang.search.placeholder,
|
71
|
-
showSubmit: false,
|
72
|
-
showLoadingIndicator: true,
|
73
|
-
templates: {
|
74
|
-
loadingIndicator: '<i class="scoicon sco-loading-line search-icon"></i>'
|
75
|
-
},
|
76
|
-
onStateChange({uiState, setUiState}) {
|
77
|
-
const searchInput = document.querySelector('#algolia-search-input input')
|
78
|
-
if (searchInput.value) {
|
79
|
-
setUiState(uiState);
|
80
|
-
}
|
50
|
+
searchClient: algoliasearch(algolia.appId, algolia.apiKey),
|
51
|
+
searchFunction(helper) {
|
52
|
+
if (helper.state.query) {
|
53
|
+
let innerLoading = '<i class="scoicon sco-loading-line sco-spin"></i>';
|
54
|
+
document.getElementById("algolia-hits").innerHTML = innerLoading;
|
55
|
+
helper.search();
|
81
56
|
}
|
82
|
-
}
|
83
|
-
)
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
57
|
+
},
|
58
|
+
});
|
59
|
+
|
60
|
+
const configure = instantsearch.widgets.configure({
|
61
|
+
hitsPerPage: algolia.hits.per_page ?? 5,
|
62
|
+
});
|
63
|
+
|
64
|
+
const searchBox = instantsearch.widgets.searchBox({
|
65
|
+
container: "#algolia-search-input",
|
66
|
+
showReset: false,
|
67
|
+
showSubmit: false,
|
68
|
+
placeholder: GLOBAL_CONFIG.lang.search.placeholder,
|
69
|
+
showLoadingIndicator: true,
|
70
|
+
searchOnEnterKeyPressOnly: true,
|
71
|
+
searchAsYouType: false,
|
72
|
+
});
|
73
|
+
|
74
|
+
const hits = instantsearch.widgets.hits({
|
75
|
+
container: "#algolia-hits",
|
76
|
+
templates: {
|
77
|
+
item(data) {
|
78
|
+
const link = data.permalink ? data.permalink : GLOBAL_CONFIG.root + data.path;
|
79
|
+
const result = data._highlightResult;
|
80
|
+
const loadingLogo = document.querySelector("#algolia-hits .sco-spin");
|
81
|
+
if (loadingLogo) {
|
82
|
+
loadingLogo.style.display = "none";
|
100
83
|
}
|
84
|
+
setTimeout(() => {
|
85
|
+
document.querySelector("#algolia-search .ais-SearchBox-input").focus();
|
86
|
+
}, 200);
|
87
|
+
return `
|
88
|
+
<a href="${link}" class="algolia-hit-item-link">
|
89
|
+
<span class="algolia-hits-item-title">${result.title.value || "no-title"}</span>
|
90
|
+
</a>`;
|
101
91
|
},
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
)
|
107
|
-
|
108
|
-
search.addWidget(
|
109
|
-
instantsearch.widgets.stats({
|
110
|
-
container: '#algolia-stats',
|
111
|
-
templates: {
|
112
|
-
text(data) {
|
113
|
-
const stats = GLOBAL_CONFIG.lang.search.hit.replace(/\$\{hits}/, data.nbHits).replace(/\$\{time}/, data.processingTimeMS);
|
114
|
-
return `${stats}`;
|
92
|
+
empty: function (data) {
|
93
|
+
const loadingLogo = document.querySelector("#algolia-hits .sco-spin");
|
94
|
+
if (loadingLogo) {
|
95
|
+
loadingLogo.style.display = "none";
|
115
96
|
}
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
97
|
+
setTimeout(() => {
|
98
|
+
document.querySelector("#algolia-search .ais-SearchBox-input").focus();
|
99
|
+
}, 200);
|
100
|
+
return (
|
101
|
+
'<div id="algolia-hits-empty">' +
|
102
|
+
GLOBAL_CONFIG.lang.search.empty.replace(/\$\{query}/, data.query) +
|
103
|
+
"</div>"
|
104
|
+
);
|
105
|
+
},
|
106
|
+
},
|
107
|
+
cssClasses: {
|
108
|
+
item: "algolia-hit-item",
|
109
|
+
},
|
110
|
+
});
|
111
|
+
|
112
|
+
const pagination = instantsearch.widgets.pagination({
|
113
|
+
container: "#algolia-pagination",
|
114
|
+
totalPages: algolia.hits.per_page ?? 5,
|
115
|
+
scrollTo: false,
|
116
|
+
showFirstLast: false,
|
117
|
+
templates: {
|
118
|
+
first: '<i class="scoicon sco-show-left-line"></i>',
|
119
|
+
last: '<i class="scoicon sco-show-right-line"></i>',
|
120
|
+
previous: '<i class="scoicon sco-arrow-left-bold"></i>',
|
121
|
+
next: '<i class="scoicon sco-arrow-right-bold"></i>',
|
122
|
+
},
|
123
|
+
cssClasses: {
|
124
|
+
root: "pagination",
|
125
|
+
item: "pagination-item",
|
126
|
+
link: "page-number",
|
127
|
+
active: "current",
|
128
|
+
disabled: "disabled-item",
|
129
|
+
},
|
130
|
+
});
|
131
|
+
|
132
|
+
const stats = instantsearch.widgets.stats({
|
133
|
+
container: "#algolia-tips > #algolia-stats",
|
134
|
+
templates: {
|
135
|
+
text: function (data) {
|
136
|
+
const stats = GLOBAL_CONFIG.lang.search.hit
|
137
|
+
.replace(/\$\{hits}/, data.nbHits)
|
138
|
+
.replace(/\$\{time}/, data.processingTimeMS);
|
139
|
+
return `<hr>${stats}`;
|
132
140
|
},
|
133
|
-
}
|
134
|
-
)
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
+
},
|
142
|
+
});
|
143
|
+
|
144
|
+
const powerBy = instantsearch.widgets.poweredBy({
|
145
|
+
container: "#algolia-tips > #algolia-poweredBy",
|
146
|
+
});
|
147
|
+
|
148
|
+
search.addWidgets([configure, searchBox,stats, hits,powerBy, pagination]); // add the widgets to the instantsearch instance
|
149
|
+
|
150
|
+
search.start();
|
151
|
+
|
152
|
+
searchClickFn();
|
153
|
+
searchFnOnce();
|
154
|
+
|
155
|
+
window.addEventListener("pjax:complete", () => {
|
156
|
+
!utils.isHidden($searchMask) && closeSearch();
|
157
|
+
searchClickFn();
|
158
|
+
});
|
159
|
+
|
160
|
+
window.pjax &&
|
161
|
+
search.on("render", () => {
|
162
|
+
window.pjax.refresh(document.getElementById("algolia-hits"));
|
163
|
+
});
|
164
|
+
});
|