hexo-theme-solitude 1.1.3 → 1.2.1
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/LICENSE +674 -19
- package/_config.yml +243 -193
- package/languages/en-US.yml +1 -0
- package/languages/zh-CN.yml +8 -8
- package/layout/404.pug +24 -0
- package/layout/archive.pug +11 -0
- package/layout/category.pug +16 -0
- package/layout/includes/console.pug +42 -0
- package/layout/includes/footer.pug +71 -0
- package/layout/includes/head/config.pug +79 -0
- package/layout/includes/head/pwa.pug +59 -0
- package/layout/includes/head.pug +29 -0
- package/layout/includes/header.pug +4 -0
- package/layout/includes/inject/body.pug +68 -0
- package/layout/{partial/compoment/inject/head.ejs → includes/inject/head.pug} +59 -35
- package/layout/includes/layout.pug +35 -0
- package/layout/{partial/loading.ejs → includes/loading.pug} +19 -17
- package/layout/includes/mixins/articleSort.pug +14 -0
- package/layout/includes/mixins/pagination.pug +8 -0
- package/layout/includes/nav.pug +22 -0
- package/layout/includes/page/about.pug +10 -0
- package/layout/includes/page/categories.pug +8 -0
- package/layout/includes/page/default.pug +2 -0
- package/layout/includes/page/echarts.pug +7 -0
- package/layout/includes/page/equipment.pug +3 -0
- package/layout/includes/page/links.pug +35 -0
- package/layout/includes/page/moments.pug +5 -0
- package/layout/includes/page/rss.pug +22 -0
- package/layout/includes/page/says.pug +20 -0
- package/layout/includes/page/tags.pug +8 -0
- package/layout/includes/page/tlink.pug +9 -0
- package/layout/includes/recent-posts.pug +9 -0
- package/layout/includes/sidebar.pug +17 -0
- package/layout/includes/widgets/aside/aside.pug +18 -0
- package/layout/includes/widgets/aside/asideAllInfo.pug +8 -0
- package/layout/includes/widgets/aside/asideArchive.pug +9 -0
- package/layout/includes/widgets/aside/asideFlipCard.pug +5 -0
- package/layout/includes/widgets/aside/asideHistory.pug +8 -0
- package/layout/includes/widgets/aside/asideInfoCard.pug +22 -0
- package/layout/includes/widgets/aside/asideNewestPost.pug +16 -0
- package/layout/includes/widgets/aside/asidePower.pug +19 -0
- package/layout/includes/widgets/aside/asideSwitch.pug +26 -0
- package/layout/includes/widgets/aside/asideTag.pug +11 -0
- package/layout/includes/widgets/aside/asideToc.pug +5 -0
- package/layout/includes/widgets/aside/asideWebInfo.pug +40 -0
- package/layout/includes/widgets/aside/asideWelcome.pug +12 -0
- package/layout/includes/widgets/home/banner.pug +16 -0
- package/layout/includes/widgets/home/bbTimeList.pug +8 -0
- package/layout/includes/widgets/home/categoryBar.pug +10 -0
- package/layout/includes/widgets/home/categoryGroup.pug +9 -0
- package/layout/includes/widgets/home/hometop.pug +9 -0
- package/layout/includes/widgets/home/postList.pug +26 -0
- package/layout/includes/widgets/home/rencentPost.pug +26 -0
- package/layout/includes/widgets/home/topGroup.pug +27 -0
- package/layout/includes/widgets/nav/left.pug +10 -0
- package/layout/includes/widgets/nav/menu.pug +16 -0
- package/layout/includes/widgets/nav/right.pug +23 -0
- package/layout/includes/widgets/page/about/authorinfo.pug +12 -0
- package/layout/includes/widgets/page/about/award.pug +34 -0
- package/layout/includes/widgets/page/about/contentinfo.pug +38 -0
- package/layout/includes/widgets/page/about/hobbies.pug +33 -0
- package/layout/includes/widgets/page/about/motto.pug +19 -0
- package/layout/includes/widgets/page/about/other.pug +61 -0
- package/layout/includes/widgets/page/about/personalities.pug +16 -0
- package/layout/includes/widgets/page/about/skillsinfo.pug +41 -0
- package/layout/includes/widgets/page/banner.pug +14 -0
- package/layout/includes/widgets/page/equipment/content.pug +23 -0
- package/layout/includes/widgets/page/links/banner.pug +30 -0
- package/layout/includes/widgets/page/links/linksCard.pug +18 -0
- package/layout/includes/widgets/page/links/linksItem.pug +14 -0
- package/layout/includes/widgets/page/moments/angle.pug +24 -0
- package/layout/includes/widgets/page/moments/index.pug +18 -0
- package/layout/includes/widgets/page/says/saysBottom.pug +11 -0
- package/layout/includes/widgets/page/says/saysContent.pug +6 -0
- package/layout/includes/widgets/page/says/saysFunction.pug +10 -0
- package/layout/includes/widgets/page/says/saysMeta.pug +7 -0
- package/layout/includes/widgets/post/award.pug +48 -0
- package/layout/includes/widgets/post/copyright.pug +27 -0
- package/layout/includes/widgets/post/postMeta.pug +55 -0
- package/layout/includes/widgets/post/postNav.pug +25 -0
- package/layout/includes/widgets/post/wave.pug +9 -0
- package/layout/includes/widgets/randomlink.pug +32 -0
- package/layout/includes/widgets/rightside/index.pug +74 -0
- package/layout/includes/widgets/third-party/comments/comment.pug +14 -0
- package/layout/includes/widgets/third-party/comments/gitalk.pug +0 -0
- package/layout/{partial/compoment/third-party/comments/twikoo.ejs → includes/widgets/third-party/comments/twikoo.pug} +8 -9
- package/layout/includes/widgets/third-party/comments/valine.pug +0 -0
- package/layout/includes/widgets/third-party/music.pug +3 -0
- package/layout/includes/widgets/third-party/pjax.pug +30 -0
- package/layout/includes/widgets/third-party/search/algolia-search.pug +16 -0
- package/layout/includes/widgets/third-party/search/index.pug +7 -0
- package/layout/includes/widgets/third-party/search/local-search.pug +15 -0
- package/layout/index.pug +20 -0
- package/layout/page.pug +32 -0
- package/layout/post.pug +43 -0
- package/layout/tag.pug +19 -0
- package/package.json +4 -4
- package/scripts/event/page.js +20 -2
- package/scripts/filter/checkThemeConfig.js +0 -1
- package/scripts/filter/randomPosts.js +0 -1
- package/scripts/helper/{charts.js → echarts.js} +27 -28
- package/scripts/helper/stylus.js +23 -0
- package/scripts/tags/bvideo.js +1 -36
- package/source/css/_comment/index.styl +121 -0
- package/source/css/_comment/twikoo.styl +515 -0
- package/source/css/_extra/console.styl +354 -0
- package/source/css/_extra/rightmenu.styl +83 -0
- package/source/css/_global/animation.css +756 -0
- package/source/css/_global/function.styl +83 -0
- package/source/css/_global/index.styl +120 -0
- package/source/css/_global/var.styl +1 -0
- package/source/css/_layout/articleSort.styl +199 -0
- package/source/css/_layout/base.styl +392 -0
- package/source/css/_layout/footer.styl +359 -0
- package/source/css/_layout/header.styl +1331 -0
- package/source/css/_layout/index.styl +293 -0
- package/source/css/_layout/sidebar.styl +226 -0
- package/source/css/_mode/index.styl +52 -0
- package/source/css/_page/about.styl +944 -0
- package/source/css/_page/category.styl +141 -0
- package/source/css/_page/equipment.styl +108 -0
- package/source/css/_page/error.styl +161 -0
- package/source/css/_page/home.styl +58 -0
- package/source/css/_page/homeTop.styl +1035 -0
- package/source/css/_page/index.styl +22 -0
- package/source/css/_page/link.styl +433 -0
- package/source/css/_page/moment.styl +186 -0
- package/source/css/_page/rss.styl +87 -0
- package/source/css/_page/says.styl +353 -0
- package/source/css/_page/tag.styl +56 -0
- package/source/css/_post/commentBarrage.styl +149 -0
- package/source/css/_post/externalTags.styl +694 -0
- package/source/css/_post/highlight.styl +96 -0
- package/source/css/_post/index.styl +935 -0
- package/source/css/_post/pagination.styl +467 -0
- package/source/css/_post/postContent.styl +957 -0
- package/source/css/_post/relatedPost.styl +160 -0
- package/source/css/_post/reward.styl +217 -0
- package/source/css/_search/algolia-search.styl +206 -0
- package/source/css/_search/local-search.styl +112 -0
- package/source/css/_widgets/aside/allinfo.styl +134 -0
- package/source/css/_widgets/aside/flip.styl +68 -0
- package/source/css/_widgets/aside/history.styl +35 -0
- package/source/css/_widgets/aside/index.styl +156 -0
- package/source/css/_widgets/aside/info.styl +263 -0
- package/source/css/_widgets/aside/newPost.styl +55 -0
- package/source/css/_widgets/aside/power.styl +90 -0
- package/source/css/_widgets/aside/toc.styl +85 -0
- package/source/css/_widgets/aside/welcome.styl +14 -0
- package/source/css/_widgets/index.styl +3 -0
- package/source/css/index.styl +40 -0
- package/source/js/commentBarrage.js +8 -5
- package/source/js/extend/console/comment.js +60 -63
- package/source/js/extend/covercolor/local.js +1 -1
- package/source/js/extend/search/algolia-search.js +104 -111
- package/source/js/extend/search/local-search.js +7 -7
- package/source/js/main.js +655 -505
- package/source/js/utils.js +131 -137
- package/layout/404.ejs +0 -34
- package/layout/archive.ejs +0 -10
- package/layout/category.ejs +0 -18
- package/layout/index.ejs +0 -20
- package/layout/layout.ejs +0 -30
- package/layout/page/about.ejs +0 -15
- package/layout/page/categories.ejs +0 -12
- package/layout/page/circle.ejs +0 -5
- package/layout/page/echarts.ejs +0 -1
- package/layout/page/equipment.ejs +0 -2
- package/layout/page/links.ejs +0 -46
- package/layout/page/page.ejs +0 -3
- package/layout/page/rss.ejs +0 -39
- package/layout/page/says.ejs +0 -17
- package/layout/page/tags.ejs +0 -12
- package/layout/page/tlink.ejs +0 -11
- package/layout/page.ejs +0 -45
- package/layout/partial/body.ejs +0 -7
- package/layout/partial/compoment/about/authorinfo.ejs +0 -18
- package/layout/partial/compoment/about/award.ejs +0 -59
- package/layout/partial/compoment/about/contentinfo.ejs +0 -33
- package/layout/partial/compoment/about/hobbies.ejs +0 -53
- package/layout/partial/compoment/about/motto.ejs +0 -17
- package/layout/partial/compoment/about/other.ejs +0 -76
- package/layout/partial/compoment/about/personalities.ejs +0 -11
- package/layout/partial/compoment/about/skillsinfo.ejs +0 -62
- package/layout/partial/compoment/aside/aside.ejs +0 -28
- package/layout/partial/compoment/aside/asideAllInfo.ejs +0 -6
- package/layout/partial/compoment/aside/asideArchive.ejs +0 -11
- package/layout/partial/compoment/aside/asideFlipCard.ejs +0 -72
- package/layout/partial/compoment/aside/asideHistory.ejs +0 -49
- package/layout/partial/compoment/aside/asideInfoCard.ejs +0 -39
- package/layout/partial/compoment/aside/asideNewestPost.ejs +0 -31
- package/layout/partial/compoment/aside/asidePower.ejs +0 -31
- package/layout/partial/compoment/aside/asideSwitch.ejs +0 -41
- package/layout/partial/compoment/aside/asideTag.ejs +0 -5
- package/layout/partial/compoment/aside/asideToc.ejs +0 -11
- package/layout/partial/compoment/aside/asideWebInfo.ejs +0 -60
- package/layout/partial/compoment/aside/asideWelcome.ejs +0 -33
- package/layout/partial/compoment/circle/angle.ejs +0 -26
- package/layout/partial/compoment/circle/banner.ejs +0 -11
- package/layout/partial/compoment/circle/content.ejs +0 -19
- package/layout/partial/compoment/dorakika/rightmenu.ejs +0 -100
- package/layout/partial/compoment/equipment/list.ejs +0 -37
- package/layout/partial/compoment/home/homeCategoryBar.ejs +0 -11
- package/layout/partial/compoment/home/postList.ejs +0 -37
- package/layout/partial/compoment/hometop/bbTimeList.ejs +0 -15
- package/layout/partial/compoment/hometop/categoryGroup.ejs +0 -19
- package/layout/partial/compoment/hometop/groupTag.ejs +0 -30
- package/layout/partial/compoment/hometop/topGroup.ejs +0 -41
- package/layout/partial/compoment/inject/body.ejs +0 -70
- package/layout/partial/compoment/links/angle.ejs +0 -26
- package/layout/partial/compoment/links/banner.ejs +0 -42
- package/layout/partial/compoment/links/linksCard.ejs +0 -27
- package/layout/partial/compoment/links/linksItem.ejs +0 -21
- package/layout/partial/compoment/mixins/articleSort.ejs +0 -26
- package/layout/partial/compoment/mixins/pagination.ejs +0 -11
- package/layout/partial/compoment/nav/left.ejs +0 -22
- package/layout/partial/compoment/nav/menu.ejs +0 -25
- package/layout/partial/compoment/nav/right.ejs +0 -42
- package/layout/partial/compoment/post/award.ejs +0 -60
- package/layout/partial/compoment/post/copyright.ejs +0 -39
- package/layout/partial/compoment/post/postMeta.ejs +0 -85
- package/layout/partial/compoment/post/postNav.ejs +0 -41
- package/layout/partial/compoment/post/wave.ejs +0 -14
- package/layout/partial/compoment/says/banner.ejs +0 -10
- package/layout/partial/compoment/says/saysBottom.ejs +0 -18
- package/layout/partial/compoment/says/saysContent.ejs +0 -10
- package/layout/partial/compoment/says/saysFunction.ejs +0 -15
- package/layout/partial/compoment/third-party/comments/comment.ejs +0 -12
- package/layout/partial/compoment/third-party/comments/twikoo_k.ejs +0 -29
- package/layout/partial/compoment/third-party/music.ejs +0 -5
- package/layout/partial/compoment/third-party/pjax.ejs +0 -31
- package/layout/partial/compoment/third-party/search/algolia-search.ejs +0 -20
- package/layout/partial/compoment/third-party/search/index.ejs +0 -10
- package/layout/partial/compoment/third-party/search/local-search.ejs +0 -22
- package/layout/partial/compoment/tlink/banner.ejs +0 -10
- package/layout/partial/console.ejs +0 -68
- package/layout/partial/footer.ejs +0 -109
- package/layout/partial/head.ejs +0 -37
- package/layout/partial/header.ejs +0 -6
- package/layout/partial/hometop.ejs +0 -15
- package/layout/partial/nav.ejs +0 -34
- package/layout/partial/pwa.ejs +0 -40
- package/layout/partial/sidebar.ejs +0 -31
- package/layout/post.ejs +0 -52
- package/layout/tag.ejs +0 -19
- package/scripts/helper/randomLinks.js +0 -16
- package/scripts/helper/themeJsExport.js +0 -79
- package/source/css/commentBarrage.css +0 -174
- package/source/css/custom.css +0 -901
- package/source/css/main.css +0 -16285
- package/source/css/search/algolia-search.css +0 -141
- package/source/css/search/local-search.css +0 -138
- package/source/css/var.css +0 -189
- /package/source/js/{rightmenu.js → rightside.js} +0 -0
@@ -1,10 +1,10 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
utils.fadeIn(
|
7
|
-
|
1
|
+
window.addEventListener('load', () => {
|
2
|
+
const openSearch = () => {
|
3
|
+
document.body.style.cssText = 'width: 100%;overflow: hidden'
|
4
|
+
document.querySelector('#algolia-search .search-dialog').style.display = 'block'
|
5
|
+
document.querySelector('#algolia-search .ais-SearchBox-input').focus()
|
6
|
+
utils.fadeIn(document.getElementById('search-mask'), 0.5)
|
7
|
+
// shortcut: ESC
|
8
8
|
document.addEventListener('keydown', function f(event) {
|
9
9
|
if (event.code === 'Escape') {
|
10
10
|
closeSearch()
|
@@ -13,135 +13,128 @@ class search {
|
|
13
13
|
})
|
14
14
|
}
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
const closeSearch = () => {
|
17
|
+
document.body.style.cssText = "width: '';overflow: ''"
|
18
|
+
const $searchDialog = document.querySelector('#algolia-search .search-dialog')
|
19
|
+
$searchDialog.style.animation = 'search_close .5s'
|
20
|
+
setTimeout(() => {
|
21
|
+
$searchDialog.style.cssText = "display: none; animation: ''"
|
22
|
+
}, 500)
|
23
|
+
utils.fadeOut(document.getElementById('search-mask'), 0.5)
|
19
24
|
}
|
20
25
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
26
|
+
const searchClickFn = () => {
|
27
|
+
document.querySelector('#search-button > .search').addEventListener('click', openSearch)
|
28
|
+
document.getElementById('search-mask').addEventListener('click', closeSearch)
|
29
|
+
document.querySelector('#algolia-search .search-close-button').addEventListener('click', closeSearch)
|
30
|
+
document.getElementById('menu-search').addEventListener('click', function () {
|
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
|
+
}
|
25
39
|
|
26
|
-
|
27
|
-
let end = firstOccur + 120
|
28
|
-
let pre = ''
|
29
|
-
let post = ''
|
40
|
+
searchClickFn()
|
30
41
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
pre = '...'
|
36
|
-
}
|
42
|
+
window.addEventListener('pjax:complete', function () {
|
43
|
+
getComputedStyle(document.querySelector('#algolia-search .search-dialog')).display === 'block' && closeSearch()
|
44
|
+
searchClickFn()
|
45
|
+
})
|
37
46
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
}
|
43
|
-
|
44
|
-
const matchContent = pre + content.substring(start, end) + post
|
45
|
-
return matchContent
|
47
|
+
const algolia = GLOBAL_CONFIG.algolia
|
48
|
+
const isAlgoliaValid = algolia.appId && algolia.apiKey && algolia.indexName
|
49
|
+
if (!isAlgoliaValid) {
|
50
|
+
return console.error('Algolia setting is invalid!')
|
46
51
|
}
|
47
52
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
return console.error('Algolia setting is invalid!')
|
53
|
-
}
|
53
|
+
const searchClient = algoliasearch(
|
54
|
+
algolia.appId,
|
55
|
+
algolia.apiKey
|
56
|
+
);
|
54
57
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
58
|
+
const search = instantsearch({
|
59
|
+
indexName: algolia.indexName,
|
60
|
+
searchClient,
|
61
|
+
searchParameters: {
|
62
|
+
hitsPerPage: algolia.hits.per_page || 10
|
63
|
+
}
|
64
|
+
})
|
62
65
|
|
63
|
-
|
64
|
-
|
66
|
+
search.addWidget(
|
67
|
+
instantsearch.widgets.searchBox({
|
68
|
+
container: '#algolia-search-input',
|
65
69
|
showReset: false,
|
70
|
+
placeholder: GLOBAL_CONFIG.lang.search.placeholder,
|
66
71
|
showSubmit: false,
|
67
|
-
|
68
|
-
|
69
|
-
|
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
|
+
}
|
81
|
+
}
|
70
82
|
})
|
71
|
-
|
72
|
-
|
83
|
+
)
|
84
|
+
search.addWidget(
|
85
|
+
instantsearch.widgets.hits({
|
73
86
|
container: '#algolia-hits',
|
74
87
|
templates: {
|
75
|
-
item(
|
76
|
-
const link =
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
: result.contentStrip
|
81
|
-
? that.cutContent(result.contentStrip.value)
|
82
|
-
: result.content
|
83
|
-
? that.cutContent(result.content.value)
|
84
|
-
: ''
|
85
|
-
return `
|
86
|
-
<a href="${link}" class="algolia-hit-item-link">
|
87
|
-
${result.title.value}
|
88
|
-
</a>
|
89
|
-
<p class="algolia-hit-item-content">${content}</p>`
|
88
|
+
item(hit) {
|
89
|
+
const link = hit.permalink ? hit.permalink : (GLOBAL_CONFIG.root + hit.path)
|
90
|
+
return (
|
91
|
+
`<a href="${link}" class="algolia-hit-item-link">${hit._highlightResult.title.value}</a>`
|
92
|
+
)
|
90
93
|
},
|
91
|
-
empty
|
94
|
+
empty(data) {
|
92
95
|
return (
|
93
|
-
|
96
|
+
'<div id="algolia-hits-empty">' +
|
97
|
+
GLOBAL_CONFIG.lang.search.empty.replace(/\$\{query}/, data.query) +
|
98
|
+
'</div>'
|
94
99
|
)
|
95
100
|
}
|
101
|
+
},
|
102
|
+
cssClasses: {
|
103
|
+
item: 'algolia-hit-item'
|
96
104
|
}
|
97
105
|
})
|
106
|
+
)
|
98
107
|
|
99
|
-
|
100
|
-
|
108
|
+
search.addWidget(
|
109
|
+
instantsearch.widgets.stats({
|
110
|
+
container: '#algolia-stats',
|
101
111
|
templates: {
|
102
|
-
text
|
103
|
-
const stats =
|
104
|
-
return
|
105
|
-
stats
|
106
|
-
)
|
112
|
+
text(data) {
|
113
|
+
const stats = GLOBAL_CONFIG.lang.search.hit.replace(/\$\{hits}/, data.nbHits).replace(/\$\{time}/, data.processingTimeMS);
|
114
|
+
return `${stats}`;
|
107
115
|
}
|
108
116
|
}
|
109
117
|
})
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
118
|
+
)
|
119
|
+
|
120
|
+
search.addWidget(
|
121
|
+
instantsearch.widgets.pagination({
|
122
|
+
container: '#algolia-pagination',
|
123
|
+
scrollTo: false,
|
124
|
+
showFirst: false,
|
125
|
+
showPrevious: false,
|
126
|
+
showNext: false,
|
127
|
+
showLast: false,
|
128
|
+
cssClasses: {
|
129
|
+
list: 'pagination',
|
130
|
+
pageItem: 'pagination-item',
|
131
|
+
link: 'page-number',
|
132
|
+
},
|
115
133
|
})
|
116
|
-
|
117
|
-
|
134
|
+
)
|
135
|
+
search.start()
|
118
136
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
rm.hideRightMenu();
|
123
|
-
search.openSearch();
|
124
|
-
let t = document.getElementsByClassName('ais-search-box--input')[0];
|
125
|
-
let evt = new Event('input', {
|
126
|
-
bubbles: true,
|
127
|
-
cancelable: true
|
128
|
-
});
|
129
|
-
t.value = selectTextNow;
|
130
|
-
t.dispatchEvent(evt);
|
131
|
-
});
|
132
|
-
}
|
133
|
-
|
134
|
-
const searchClickFnOnce = () => {
|
135
|
-
document.querySelector('#algolia-search .search-close-button').addEventListener('click', search.closeSearch)
|
136
|
-
$searchMask.addEventListener('click', search.closeSearch)
|
137
|
-
}
|
138
|
-
|
139
|
-
window.addEventListener('load', () => {
|
140
|
-
searchClickFn()
|
141
|
-
searchClickFnOnce()
|
142
|
-
search.search()
|
137
|
+
window.pjax && search.on('render', () => {
|
138
|
+
window.pjax.refresh(document.getElementById('algolia-hits'))
|
139
|
+
})
|
143
140
|
})
|
144
|
-
|
145
|
-
window.addEventListener('pjax:complete', () => {
|
146
|
-
searchClickFn()
|
147
|
-
})
|
@@ -44,7 +44,7 @@ class search{
|
|
44
44
|
}
|
45
45
|
|
46
46
|
static search(){
|
47
|
-
if (!
|
47
|
+
if (!GLOBAL_CONFIG.localsearch.preload && dataObj === null) dataObj = this.fetchData(GLOBAL_CONFIG.localsearch.path)
|
48
48
|
$input.addEventListener('input', function type() {
|
49
49
|
const keywords = this.value.trim().toLowerCase().split(/[\s]+/)
|
50
50
|
if (keywords[0] !== '') $loadingStatus.innerHTML = '<i class="scoicon sco-loading-line"></i><span>加载中</span>'
|
@@ -61,7 +61,7 @@ class search{
|
|
61
61
|
let isMatch = true
|
62
62
|
let dataTitle = data.title ? data.title.trim().toLowerCase() : ''
|
63
63
|
const dataContent = data.content ? data.content.trim().replace(/<[^>]+>/g, '').toLowerCase() : ''
|
64
|
-
const dataUrl = data.url.startsWith('/') ? data.url :
|
64
|
+
const dataUrl = data.url.startsWith('/') ? data.url : GLOBAL_CONFIG.root + data.url
|
65
65
|
let indexTitle = -1
|
66
66
|
let indexContent = -1
|
67
67
|
let firstOccur = -1
|
@@ -128,9 +128,9 @@ class search{
|
|
128
128
|
}
|
129
129
|
})
|
130
130
|
if (count === 0) {
|
131
|
-
str += `<div id="search__hits-empty">${
|
131
|
+
str += `<div id="search__hits-empty">${GLOBAL_CONFIG.lang.search.empty}</div>`
|
132
132
|
}else{
|
133
|
-
str += `<div class="search__hits-count">${
|
133
|
+
str += `<div class="search__hits-count">${GLOBAL_CONFIG.lang.search.hit.replace('${query}', '<span class="search-keyword">' + count + '</span>')}</div>`
|
134
134
|
}
|
135
135
|
str += '</div>'
|
136
136
|
$resultContent.innerHTML = str
|
@@ -141,8 +141,8 @@ class search{
|
|
141
141
|
}
|
142
142
|
|
143
143
|
const searchClickFn = () => {
|
144
|
-
document.querySelector('#search-button > .search').addEventListener('click', search.openSearch)
|
145
|
-
document.getElementById('menu-search').addEventListener('click', function() {
|
144
|
+
if (PAGE_CONFIG.page !== "404") document.querySelector('#search-button > .search').addEventListener('click', search.openSearch)
|
145
|
+
GLOBAL_CONFIG.rightmenu.enable && document.getElementById('menu-search').addEventListener('click', function() {
|
146
146
|
rm.hideRightMenu();
|
147
147
|
search.openSearch();
|
148
148
|
let t = document.getElementsByClassName('search-box-input')[0];
|
@@ -158,7 +158,7 @@ const searchClickFn = () => {
|
|
158
158
|
const searchClickFnOnce = () => {
|
159
159
|
document.querySelector('#local-search .search-close-button').addEventListener('click', search.closeSearch)
|
160
160
|
$searchMask.addEventListener('click', search.closeSearch)
|
161
|
-
if (
|
161
|
+
if (GLOBAL_CONFIG.localsearch.preload) dataObj = search.fetchData(GLOBAL_CONFIG.localsearch.path)
|
162
162
|
}
|
163
163
|
|
164
164
|
window.addEventListener('load', () => {
|