hexo-theme-stellar 1.17.0 → 1.17.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/_config.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  ######## Stellar info ########
2
2
  stellar:
3
- version: '1.17.0'
3
+ version: '1.17.1'
4
4
  homepage: 'https://xaoxuu.com/wiki/stellar/'
5
5
  repo: 'https://github.com/xaoxuu/hexo-theme-stellar'
6
6
  cdn_css: # Use cdn links instead of /css/main.css
@@ -62,8 +62,11 @@ article:
62
62
 
63
63
 
64
64
  search:
65
- service: local_search # hexo, todo...
66
- local_search: # npm i hexo-generator-search
65
+ service: local_search # local_search, todo...
66
+ local_search:
67
+ field: all # post, page, all
68
+ path: /search.json
69
+ content: true
67
70
 
68
71
 
69
72
  ######## Comments ########
@@ -70,9 +70,9 @@ function layoutDiv() {
70
70
  } else if (item == 'weibo') {
71
71
  el += ' href="https://service.weibo.com/share/share.php?url=' + page.permalink;
72
72
  el += '&title=' + (page.seo_title || (page.title + ' - ' + config.title));
73
- if (page.latyout == 'post' && page.cover) {
73
+ if (page.layout == 'post' && page.cover) {
74
74
  el += '&pics=' + page.cover;
75
- } else if (page.latyout == 'wiki' && page.logo && page.logo.src) {
75
+ } else if (page.layout == 'wiki' && page.logo && page.logo.src) {
76
76
  el += '&pics=' + page.logo.src;
77
77
  }
78
78
  el += '&summary=' + truncate(page.description || strip_html(page.excerpt || page.content), {length: 120});
@@ -111,7 +111,7 @@
111
111
  stellar.search = {};
112
112
  stellar.search.service = '<%- theme.search.service %>';
113
113
  if (stellar.search.service == 'local_search') {
114
- let service_obj = Object.assign({}, <%- JSON.stringify(config.search) %>);
114
+ let service_obj = Object.assign({}, <%- JSON.stringify(theme.search.local_search) %>);
115
115
  stellar.search[stellar.search.service] = service_obj;
116
116
  }
117
117
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hexo-theme-stellar",
3
- "version": "1.17.0",
3
+ "version": "1.17.1",
4
4
  "description": "Elegant and powerful theme for Hexo.",
5
5
  "main": "package.json",
6
6
  "scripts": {
@@ -0,0 +1,103 @@
1
+ /**
2
+ * https://github.com/wzpan/hexo-generator-search
3
+ */
4
+
5
+ hexo.extend.generator.register('search_json_generator', function (locals) {
6
+ if (this.theme.config.search.service != 'local_search') {
7
+ return {}
8
+ }
9
+ var config = this.config
10
+ const { local_search } = this.theme.config.search
11
+
12
+ var searchfield = local_search.field
13
+ var content = local_search.content
14
+
15
+ var posts, pages
16
+
17
+ if (searchfield.trim() != '') {
18
+ searchfield = searchfield.trim()
19
+ if (searchfield == 'post'){
20
+ posts = locals.posts.sort('-date')
21
+ } else if (searchfield == 'page') {
22
+ pages = locals.pages
23
+ } else {
24
+ posts = locals.posts.sort('-date')
25
+ pages = locals.pages
26
+ }
27
+ } else {
28
+ posts = locals.posts.sort('-date')
29
+ }
30
+
31
+ var res = new Array()
32
+ var index = 0
33
+
34
+ if (posts) {
35
+ posts.each(function(post) {
36
+ if (post.indexing != undefined && !post.indexing) return
37
+ var temp_post = new Object()
38
+ if (post.title) {
39
+ temp_post.title = post.title
40
+ }
41
+ if (post.path) {
42
+ temp_post.url = config.root + post.path
43
+ }
44
+ if (content != false && post._content) {
45
+ temp_post.content = post._content
46
+ }
47
+ if (post.tags && post.tags.length > 0) {
48
+ var tags = []
49
+ post.tags.forEach(function (tag) {
50
+ tags.push(tag.name)
51
+ })
52
+ temp_post.tags = tags
53
+ }
54
+ if (post.categories && post.categories.length > 0) {
55
+ var categories = []
56
+ post.categories.forEach(function (cate) {
57
+ categories.push(cate.name)
58
+ })
59
+ temp_post.categories = categories
60
+ }
61
+ res[index] = temp_post
62
+ index += 1
63
+ })
64
+ }
65
+ if (pages) {
66
+ pages.each(function(page) {
67
+ if (page.indexing != undefined && !page.indexing) return
68
+ var temp_page = new Object()
69
+ if (page.title) {
70
+ temp_page.title = page.title
71
+ }
72
+ if (page.path) {
73
+ temp_page.url = config.root + page.path
74
+ }
75
+ if (content != false && page._content) {
76
+ temp_page.content = page._content
77
+ }
78
+ if (page.tags && page.tags.length > 0) {
79
+ var tags = new Array()
80
+ var tag_index = 0
81
+ page.tags.each(function (tag) {
82
+ tags[tag_index] = tag.name
83
+ })
84
+ temp_page.tags = tags
85
+ }
86
+ if (page.categories && page.categories.length > 0) {
87
+ temp_page.categories = []
88
+ (page.categories.each || page.categories.forEach)(function (item) {
89
+ temp_page.categories.push(item)
90
+ })
91
+ }
92
+ res[index] = temp_page
93
+ index += 1
94
+ })
95
+ }
96
+
97
+ var json = JSON.stringify(res)
98
+
99
+ return {
100
+ path: local_search.path,
101
+ data: json
102
+ }
103
+ })
@@ -9,7 +9,7 @@
9
9
  border-radius: $border-card
10
10
  overflow: hidden
11
11
  box-shadow: 0 2px 8px 0px rgba(0, 0, 0, 0.03)
12
- a.page-number
12
+ .page-number
13
13
  padding: 4px 8px
14
14
  border-radius: 8px
15
15
  background: var(--block)
@@ -17,7 +17,7 @@
17
17
  width: 1rem
18
18
  height: 1rem
19
19
  .about-header
20
- display flex
20
+ display: flex
21
21
  justify-content: center
22
22
  flex-wrap: wrap
23
23
  margin: 1.5rem 0
package/source/js/main.js CHANGED
@@ -209,7 +209,7 @@ if (stellar.plugins.lazyload) {
209
209
  false
210
210
  );
211
211
  document.addEventListener('DOMContentLoaded', function () {
212
- lazyLoadInstance.update();
212
+ window.lazyLoadInstance?.update();
213
213
  });
214
214
  }
215
215
 
@@ -309,7 +309,7 @@ if (stellar.search.service) {
309
309
  var $inputArea = $("input#search-input");
310
310
  var $resultArea = document.querySelector("div#search-result");
311
311
  $inputArea.focus(function() {
312
- var path = stellar.search[stellar.search.service]?.path || '/search.xml';
312
+ var path = stellar.search[stellar.search.service]?.path || '/search.json';
313
313
  if (!path.startsWith('/')) {
314
314
  path = '/' + path;
315
315
  }
@@ -51,17 +51,9 @@ var searchFunc = function(path, filter, searchId, contentId) {
51
51
 
52
52
  $.ajax({
53
53
  url: path,
54
- dataType: "xml",
55
- success: function(xmlResponse) {
56
- // get the contents from search data
57
- var datas = $("entry", xmlResponse).map(function() {
58
- return {
59
- title: $("title", this).text(),
60
- content: $("content", this).text(),
61
- url: $("link", this).attr("href")
62
- };
63
- }).get();
64
-
54
+ dataType: "json",
55
+ success: function(jsonResponse) {
56
+ var datas = jsonResponse;
65
57
  var $input = document.getElementById(searchId);
66
58
  if (!$input) { return; }
67
59
  var $resultContent = document.getElementById(contentId);