hexo-theme-solitude 3.0.4 → 3.0.5

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 CHANGED
@@ -869,17 +869,27 @@ giscus:
869
869
  # Search
870
870
  search:
871
871
  enable: false
872
- # type: 使用的搜索引擎 / search engine
873
- type: local # local / algolia
872
+ type: # local / algolia / docsearch
874
873
  tags:
875
874
  # - Solitude
876
875
  # - Hexo
876
+ # Algolia
877
877
  algolia:
878
878
  # hits:
879
879
  # per_page: 6
880
+
881
+ # Local search
880
882
  local:
881
883
  preload: false
882
884
  CDN: # url: search.xml
885
+
886
+ # DocSearch
887
+ # https://docsearch.algolia.com/
888
+ docsearch:
889
+ appId:
890
+ apiKey:
891
+ indexName:
892
+ option:
883
893
  # --------------------------- end ---------------------------
884
894
 
885
895
  # --------------------------- start ---------------------------
@@ -0,0 +1,26 @@
1
+ - const { placeholder, docsearch: { appId, apiKey, indexName, option } } = theme.search
2
+
3
+ .docsearch-wrap
4
+ #docsearch(style="display:none")
5
+ script(src=url_for(theme.cdn.docsearch_js))
6
+ script.
7
+ (() => {
8
+ docsearch(Object.assign({
9
+ appId: '!{appId}',
10
+ apiKey: '!{apiKey}',
11
+ indexName: '!{indexName}',
12
+ container: '#docsearch',
13
+ placeholder: '!{ placeholder || _p("search.input_placeholder")}',
14
+ }, !{JSON.stringify(option)}))
15
+
16
+ const handleClick = () => {
17
+ document.querySelector('.DocSearch-Button').click()
18
+ }
19
+
20
+ const searchClickFn = () => {
21
+ utils.addEventListenerPjax(document.querySelector('#search-button > .search'), 'click', handleClick)
22
+ }
23
+
24
+ searchClickFn()
25
+ window.addEventListener('pjax:complete', searchClickFn)
26
+ })()
@@ -5,4 +5,7 @@ if theme.search.enable
5
5
  script(src=url_for(theme.cdn.algolia_js))
6
6
  when 'local'
7
7
  include local-search
8
- script(src=url_for(theme.cdn.local_search))
8
+ script(src=url_for(theme.cdn.local_search))
9
+ when 'docsearch'
10
+ include docsearch
11
+ link(rel="stylesheet" href=url_for(theme.cdn.docsearch_css))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hexo-theme-solitude",
3
- "version": "3.0.4",
3
+ "version": "3.0.5",
4
4
  "description": "A beautiful, powerful, and efficient Hexo theme developed by everfu.",
5
5
  "main": "package.json",
6
6
  "keywords": [
package/plugins.yml CHANGED
@@ -6,6 +6,16 @@ instantsearch:
6
6
  name: instantsearch.js
7
7
  file: dist/instantsearch.production.min.js
8
8
  version: 4.75.6
9
+ docsearch_css:
10
+ name: '@docsearch/css'
11
+ other_name: docsearch-css
12
+ file: dist/style.css
13
+ version: 3.8.2
14
+ docsearch_js:
15
+ name: '@docsearch/js'
16
+ other_name: docsearch-js
17
+ file: dist/umd/index.js
18
+ version: 3.8.2
9
19
  pjax:
10
20
  name: pjax
11
21
  file: pjax.min.js
@@ -246,6 +246,12 @@ hexo.extend.filter.register('before_generate', () => {
246
246
  local: {
247
247
  preload: false,
248
248
  CDN: null,
249
+ },
250
+ docsearch: {
251
+ appId: null,
252
+ apiKey: null,
253
+ indexName: null,
254
+ option: null
249
255
  }
250
256
  },
251
257
  rightside: {