hexo-theme-stellar 1.16.2 → 1.17.0

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.
Files changed (71) hide show
  1. package/_config.yml +10 -5
  2. package/_data/widgets.yml +4 -1
  3. package/languages/en.yml +5 -0
  4. package/languages/zh-CN.yml +5 -0
  5. package/languages/zh-TW.yml +5 -0
  6. package/layout/404.ejs +1 -1
  7. package/layout/_partial/cover/wiki_cover.ejs +1 -1
  8. package/layout/_partial/main/post_list/paginator.ejs +5 -9
  9. package/layout/_partial/main/post_list/post_card.ejs +1 -1
  10. package/layout/_partial/main/post_list/wiki_card.ejs +1 -1
  11. package/layout/_partial/plugins/comments/layout.ejs +1 -1
  12. package/layout/_partial/scripts/index.ejs +9 -0
  13. package/layout/_partial/sidebar/index.ejs +3 -3
  14. package/layout/_partial/{sidebar/widgets → widgets}/ghissues.ejs +2 -2
  15. package/layout/_partial/{sidebar/widgets → widgets}/ghrepo.ejs +2 -2
  16. package/layout/_partial/{sidebar/widgets → widgets}/ghuser.ejs +3 -3
  17. package/layout/_partial/{sidebar/widgets → widgets}/markdown.ejs +2 -2
  18. package/layout/_partial/{sidebar/widgets → widgets}/recent.ejs +5 -6
  19. package/layout/_partial/{sidebar/widgets → widgets}/related.ejs +2 -2
  20. package/layout/_partial/widgets/search.ejs +31 -0
  21. package/layout/_partial/{sidebar/widgets → widgets}/tagcloud.ejs +2 -2
  22. package/layout/_partial/{sidebar/widgets → widgets}/timeline.ejs +2 -2
  23. package/layout/_partial/{sidebar/widgets → widgets}/toc.ejs +2 -2
  24. package/layout/page.ejs +1 -1
  25. package/layout/post.ejs +1 -1
  26. package/layout/wiki.ejs +1 -1
  27. package/package.json +1 -1
  28. package/source/css/_common/base.styl +1 -1
  29. package/source/css/_common/highlight.styl +5 -5
  30. package/source/css/_common/span.styl +1 -0
  31. package/source/css/_layout/index.styl +1 -0
  32. package/source/css/_layout/list.styl +1 -1
  33. package/source/css/_layout/md.styl +12 -13
  34. package/source/css/_layout/pages/error.styl +2 -2
  35. package/source/css/_layout/partial/article-footer.styl +4 -4
  36. package/source/css/_layout/partial/paginator.styl +16 -5
  37. package/source/css/_layout/partial/related.styl +6 -14
  38. package/source/css/_layout/sidebar/footer.styl +1 -3
  39. package/source/css/_layout/sidebar/header.styl +112 -0
  40. package/source/css/_layout/sidebar/sidebar.styl +3 -115
  41. package/source/css/_layout/tag-plugins/checkbox.styl +1 -1
  42. package/source/css/_layout/tag-plugins/copy.styl +1 -1
  43. package/source/css/_layout/tag-plugins/emoji.styl +1 -1
  44. package/source/css/_layout/tag-plugins/frame.styl +5 -5
  45. package/source/css/_layout/tag-plugins/inline-labels.styl +1 -1
  46. package/source/css/_layout/tag-plugins/link.styl +6 -6
  47. package/source/css/_layout/tag-plugins/mark.styl +3 -4
  48. package/source/css/_layout/tag-plugins/navbar.styl +1 -1
  49. package/source/css/_layout/tag-plugins/note.styl +7 -7
  50. package/source/css/_layout/tag-plugins/poetry.styl +2 -2
  51. package/source/css/_layout/tag-plugins/quot.styl +7 -7
  52. package/source/css/_layout/tag-plugins/tabs.styl +1 -1
  53. package/source/css/_layout/tag-plugins/timeline.styl +3 -3
  54. package/source/css/_layout/widgets/ghrepo.styl +34 -0
  55. package/source/css/_layout/widgets/ghuser.styl +95 -0
  56. package/source/css/_layout/widgets/recent.styl +15 -0
  57. package/source/css/_layout/widgets/related.styl +8 -0
  58. package/source/css/_layout/widgets/search.styl +3 -0
  59. package/source/css/_layout/widgets/tagcloud.styl +8 -0
  60. package/source/css/_layout/widgets/timeline.styl +17 -0
  61. package/source/css/_layout/{sidebar → widgets}/toc_blog.styl +1 -1
  62. package/source/css/_layout/{sidebar → widgets}/toc_common.styl +7 -4
  63. package/source/css/_layout/{sidebar → widgets}/toc_wiki.styl +3 -7
  64. package/source/css/_layout/widgets/widgets.styl +60 -0
  65. package/source/css/_plugins/index.styl +4 -0
  66. package/source/css/_plugins/search/local-search.styl +89 -0
  67. package/source/js/main.js +41 -5
  68. package/source/js/search/local-search.js +161 -0
  69. package/source/css/_layout/sidebar/ghrepo.styl +0 -36
  70. package/source/css/_layout/sidebar/ghuser.styl +0 -98
  71. package/source/css/_layout/sidebar/widgets.styl +0 -106
@@ -0,0 +1,95 @@
1
+ .widget-wrapper.ghuser
2
+ .widget-header+.widget-body
3
+ margin: 0.75rem 0
4
+ .widget-wrapper.ghuser .widget-body
5
+ text-align: center
6
+ background: var(--card)
7
+ border-radius: $border-card
8
+ padding: 1rem
9
+ box-shadow: $boxshadow-card
10
+
11
+ .widget-wrapper.ghuser
12
+ .avatar
13
+ display: block
14
+ border-radius: 100%
15
+ margin: 1rem auto 1.25rem auto
16
+ max-width: 75%
17
+ overflow: hidden
18
+ img
19
+ display: block
20
+ @media screen and (max-width: $device-tablet)
21
+ max-width: 50%
22
+
23
+ .username
24
+ font-weight: 900
25
+ font-size: $fs-h2
26
+ color: var(--text-p0)
27
+ margin: 0.5rem 0
28
+
29
+ .bio
30
+ font-size: $fs-13
31
+ margin: 0.5rem 0
32
+
33
+ .follow
34
+ font-weight: 500
35
+ border-radius: 64px
36
+ padding: 0.5rem 1rem
37
+ background: $color-theme
38
+ color: var(--card)
39
+ font-size: 1rem
40
+ align-self: stretch
41
+ text-align: center
42
+ line-height: 1.5
43
+ display: flex
44
+ align-items: center
45
+ justify-content: center
46
+ trans1: background
47
+ svg
48
+ margin-right: 6px
49
+ &:hover
50
+ background: $color-hover
51
+
52
+ .menu
53
+ margin-bottom: 0
54
+ background: none
55
+ a:hover
56
+ box-shadow: none
57
+ background: var(--block)
58
+ a.active
59
+ box-shadow: none
60
+ position: relative
61
+ &:after
62
+ content: ''
63
+ position: absolute
64
+ height: 3px
65
+ bottom: 0
66
+ width: 32px
67
+ left: 'calc(50% - 0.5 * %s)' % @width
68
+ border-radius: 4px
69
+ background: $color-theme
70
+
71
+ .buttons
72
+ margin: 1rem 0
73
+ align-self: stretch
74
+ display: grid
75
+ grid-gap: 2px
76
+ grid-template-columns: repeat(auto-fill, "calc((100% - 2 * %s) / 3)" % 2px)
77
+
78
+ .btn
79
+ display: flex
80
+ flex-direction: column
81
+ align-items: center
82
+ color: inherit
83
+ border: 1px solid transparent
84
+ border-radius: 4px
85
+ padding: 0.25rem 0
86
+ trans1: background
87
+ &:hover
88
+ background: var(--block)
89
+ .title
90
+ font-size: 1rem
91
+ font-weight: 700
92
+ .desc
93
+ font-size: $fs-12
94
+ color: var(--text-p3)
95
+ font-weight: 500
@@ -0,0 +1,15 @@
1
+ .widget-wrapper.recent .widget-body
2
+ display: flex
3
+ flex-direction: column
4
+ align-items: flex-start
5
+ margin-top: 0.25rem
6
+ a
7
+ line-height: 1.2
8
+ font-size: $fs-13
9
+ margin: 0.25rem 0
10
+ .title
11
+ font-size: $fs-13
12
+ color: var(--text-p2)
13
+ &:hover
14
+ color: $color-hover
15
+
@@ -0,0 +1,8 @@
1
+ .widget-wrapper.related .widget-body a
2
+ margin-top: 0.5rem
3
+ margin-bottom: 1rem
4
+ .title
5
+ font-weight: 700
6
+ font-size: $fs-14
7
+ .excerpt
8
+ -webkit-line-clamp: 3
@@ -0,0 +1,3 @@
1
+ .widgets .widget-wrapper.search
2
+ margin-top: 0
3
+ margin-bottom: 0
@@ -0,0 +1,8 @@
1
+ .widget-wrapper.tagcloud .widget-body
2
+ margin-top: 0.25rem
3
+ a
4
+ word-break: break-word
5
+ color: var(--text-p2)
6
+ line-height: 1.5
7
+ &:hover
8
+ color: $color-hover
@@ -0,0 +1,17 @@
1
+ .widget-wrapper.timeline
2
+ .widget-body
3
+ margin-top: 0.5rem
4
+ .tag-plugin.timeline .timenode
5
+ .header
6
+ margin-bottom: 0.5rem
7
+ txt-ellipsis()
8
+ .user-info
9
+ background: var(--block)
10
+ &:hover
11
+ background: $color-hover
12
+ color: var(--card)
13
+ &:before
14
+ display: none
15
+ &+.timenode
16
+ margin-top: 0.75rem
17
+
@@ -1,3 +1,3 @@
1
- .widget-wrap.single#toc .doc-tree
1
+ .widget-wrapper.toc.single .doc-tree
2
2
  &.active>.toc
3
3
  border-left: 2px solid var(--block-hover)
@@ -1,10 +1,13 @@
1
- .widget-wrap.single#toc .widget-header
1
+ .widget-wrapper.toc .widget-header
2
+ margin-top: 1rem
3
+
4
+ .widget-wrapper.toc.single .widget-header
2
5
  font-weight: 500
3
6
  font-size: $fs-12
4
7
  >span
5
8
  margin: 0.5rem 0
6
9
 
7
- #toc .widget-body
10
+ .widget-wrapper.toc .widget-body
8
11
  margin-top: 0
9
12
  ul ul, ul ol
10
13
  padding-left: 0
@@ -34,7 +37,7 @@
34
37
  padding-left: 2.9rem
35
38
 
36
39
 
37
- #toc .toc-item
40
+ .widget-wrapper.toc .toc-item
38
41
  color: var(--text-p2)
39
42
  font-size: $fs-12
40
43
  padding: 0
@@ -44,7 +47,7 @@
44
47
  border-left-color: @color
45
48
  .toc-child .toc-item
46
49
  padding: 0
47
- #toc a.toc-link
50
+ .widget-wrapper.toc a.toc-link
48
51
  color: inherit
49
52
  display: block
50
53
  line-height: 1.2
@@ -1,14 +1,10 @@
1
- .widget-wrap#toc
2
- .widget-header
3
- margin-top: 1rem
4
-
5
- .widget-wrap.multi#toc .widget-header
1
+ .widget-wrapper.toc.multi .widget-header
6
2
  color: var(--text-p1)
7
3
  font-size: $fs-14
8
4
 
9
5
 
10
6
  // 其它分页链接
11
- .widget-wrap.multi#toc .doc-tree
7
+ .widget-wrapper.toc.multi .doc-tree
12
8
  border-radius: $border-block
13
9
  background: var(--block)
14
10
  overflow: hidden
@@ -34,7 +30,7 @@
34
30
 
35
31
 
36
32
  // 当前分页链接
37
- .widget-wrap.multi#toc .doc-tree.active
33
+ .widget-wrapper.toc.multi .doc-tree.active
38
34
  a.doc-tree-link
39
35
  background: var(--block)
40
36
  font-weight: 700
@@ -0,0 +1,60 @@
1
+ .widgets
2
+ .loading-wrap
3
+ margin: 0.5rem 0
4
+
5
+ .widgets
6
+ overflow: scroll
7
+ flex-grow: 1
8
+ scrollbar-width: none
9
+ scrollbar(0, 0)
10
+ z-index: 1
11
+ line-height: 1.2
12
+ .widget-wrapper
13
+ .widget-header
14
+ padding-left: var(--gap-l)
15
+ padding-right: var(--gap-l)
16
+ display: flex
17
+ justify-content: space-between
18
+ align-items: center
19
+ font-weight: 500
20
+ position: sticky
21
+ top: -2px
22
+ background: var(--site-bg)
23
+ padding-top: 2px
24
+ z-index 1
25
+ .item
26
+ display: block
27
+ >span
28
+ margin: 0.25rem 0
29
+ text-align: left
30
+ &:empty
31
+ display: none
32
+ .cap-action
33
+ hover-block 4px 4px
34
+ line-height: 0
35
+ color: var(--text-meta)
36
+ trans2: color background
37
+ .icon
38
+ fill: var(--text-meta)
39
+ &:hover
40
+ color: $color-hover
41
+ .icon
42
+ fill: $color-hover
43
+
44
+ .widget-body
45
+ margin: 0.5rem var(--gap-l)
46
+ color: var(--text-p1)
47
+ p
48
+ margin-top: .5em
49
+ margin-bottom: .5em
50
+ line-height: 1.5
51
+ .widget-header+.widget-body
52
+ margin-top: 0
53
+ .widget-wrapper+.widget-wrapper .widget-header
54
+ margin-top: 3rem
55
+ .widget-wrapper+.widget-wrapper.toc .widget-header
56
+ margin-top: 1rem
57
+
58
+ .widget-wrapper
59
+ display: block
60
+ margin: 2rem 0
@@ -8,6 +8,10 @@ if hexo-config('plugins.scrollreveal.enable')
8
8
  if hexo-config('plugins.fancybox.enable')
9
9
  @import 'fancybox'
10
10
 
11
+ // 搜索
12
+ if hexo-config('search.service') == 'local_search'
13
+ @import 'search/local-search'
14
+
11
15
  // 评论
12
16
  if hexo-config('comments.service') == 'beaudar'
13
17
  @import 'comments/beaudar'
@@ -0,0 +1,89 @@
1
+ .search-wrapper
2
+ width: 100%
3
+ >.search-form
4
+ position: sticky
5
+ top: 1rem
6
+ .search-input
7
+ width: 100%
8
+ padding: 0.75rem 1rem
9
+ line-height: 1
10
+ box-sizing: border-box
11
+ border-radius: $border-block
12
+ background-color: var(--card)
13
+ color: var(--text-p0)
14
+ box-shadow: $boxshadow-button
15
+ trans1 box-shadow
16
+ &:hover
17
+ box-shadow: 0 0 2px 0px rgba(0, 0, 0, 0.16), 0 0 8px 0px rgba(0, 0, 0, 0.08)
18
+
19
+ &.noresult
20
+ .search-input
21
+ &:hover
22
+ box-shadow: 0 0 2px 0px alpha($c-red, 0.2), 0 0 8px 0px alpha($c-red, 0.2)
23
+ &:focus
24
+ box-shadow: 0 0 2px 0px alpha($c-red, 0.5), 0 0 8px 0px alpha($c-red, 0.4)
25
+
26
+ .search-no-result
27
+ display: none
28
+ margin: 1em auto
29
+ color: var(--text-p1)
30
+ text-align: center
31
+ font-size: $fs-14
32
+ padding: 2rem
33
+ background: var(--block)
34
+ border-radius: $border-block
35
+
36
+ #search-result
37
+ ul.search-result-list
38
+ padding: 0
39
+ margin: 0
40
+ list-style-type: none
41
+ li
42
+ margin: 1em auto
43
+ &:hover
44
+ .search-result-title
45
+ color: $color-hover
46
+ .search-result-title
47
+ background-image: none
48
+ color: var(--text-p1)
49
+ text-transform: capitalize
50
+ font-weight: bold
51
+ line-height: 1.2
52
+
53
+ .search-result-content
54
+ overflow: hidden
55
+ color: var(--text-p3)
56
+ margin: .4em auto
57
+ max-height: 13em
58
+ text-align: justify
59
+ font-size: $fs-12
60
+ line-height: 1.2
61
+ display: -webkit-box
62
+ -webkit-box-orient: vertical
63
+ overflow: hidden
64
+ -webkit-line-clamp: 3
65
+
66
+ .search-keyword
67
+ border-bottom: 1px dashed $color-hover
68
+ color: $color-hover
69
+ font-weight: bold
70
+
71
+
72
+
73
+ .search-wrapper.noresult
74
+ .search-no-result
75
+ display: block
76
+
77
+ .widget-wrapper
78
+ .search-form
79
+ top: 0
80
+ background: var(--site-bg)
81
+ .search-input
82
+ margin-top: 1rem
83
+ margin-bottom: -1rem
84
+ #search-result,.search-no-result
85
+ margin-top: 2rem
86
+
87
+ .widget-wrapper:not(:first-child)
88
+ .search-wrapper
89
+ margin-top: -1rem
package/source/js/main.js CHANGED
@@ -92,7 +92,7 @@ const init = {
92
92
  stellar.jQuery(() => {
93
93
  const scrollOffset = 32;
94
94
  var segs = [];
95
- $("article.md :header").each(function (idx, node) {
95
+ $("article.md-text :header").each(function (idx, node) {
96
96
  segs.push(node)
97
97
  });
98
98
  // 滚动
@@ -111,12 +111,12 @@ const init = {
111
111
  }
112
112
  }
113
113
  if (topSeg) {
114
- $("#toc a.toc-link").removeClass("active")
114
+ $(".toc#toc a.toc-link").removeClass("active")
115
115
  var link = "#" + topSeg.attr("id")
116
116
  if (link != '#undefined') {
117
- $('#toc a.toc-link[href="' + encodeURI(link) + '"]').addClass("active")
117
+ $('.toc#toc a.toc-link[href="' + encodeURI(link) + '"]').addClass("active")
118
118
  } else {
119
- $('#toc a.toc-link:first').addClass("active")
119
+ $('.toc#toc a.toc-link:first').addClass("active")
120
120
  }
121
121
  }
122
122
  })
@@ -124,7 +124,7 @@ const init = {
124
124
  },
125
125
  sidebar: () => {
126
126
  stellar.jQuery(() => {
127
- $("#toc a.toc-link").click(function (e) {
127
+ $(".toc#toc a.toc-link").click(function (e) {
128
128
  l_body.classList.remove("sidebar");
129
129
  });
130
130
  })
@@ -301,6 +301,42 @@ if (stellar.plugins.fancybox) {
301
301
  }
302
302
  }
303
303
 
304
+
305
+ if (stellar.search.service) {
306
+ if (stellar.search.service == 'local_search') {
307
+ stellar.jQuery(() => {
308
+ stellar.loadScript('/js/search/local-search.js', { defer: true }).then(function () {
309
+ var $inputArea = $("input#search-input");
310
+ var $resultArea = document.querySelector("div#search-result");
311
+ $inputArea.focus(function() {
312
+ var path = stellar.search[stellar.search.service]?.path || '/search.xml';
313
+ if (!path.startsWith('/')) {
314
+ path = '/' + path;
315
+ }
316
+ const filter = $inputArea.attr('data-filter') || '';
317
+ searchFunc(path, filter, 'search-input', 'search-result');
318
+ });
319
+ $inputArea.keydown(function(e) {
320
+ if (e.which == 13) {
321
+ e.preventDefault();
322
+ }
323
+ });
324
+ var observer = new MutationObserver(function(mutationsList, observer) {
325
+ if (mutationsList.length == 1) {
326
+ if (mutationsList[0].addedNodes.length) {
327
+ $('.search-wrapper').removeClass('noresult');
328
+ } else if (mutationsList[0].removedNodes.length) {
329
+ $('.search-wrapper').addClass('noresult');
330
+ }
331
+ }
332
+ });
333
+ observer.observe($resultArea, { childList: true });
334
+ });
335
+ })
336
+ }
337
+ }
338
+
339
+
304
340
  // heti
305
341
  if (stellar.plugins.heti) {
306
342
  stellar.loadCSS(stellar.plugins.heti.css);
@@ -0,0 +1,161 @@
1
+ // A local search script with the help of
2
+ // [hexo-generator-search](https://github.com/PaicHyperionDev/hexo-generator-search)
3
+ // Copyright (C) 2015
4
+ // Joseph Pan <http://github.com/wzpan>
5
+ // Shuhao Mao <http://github.com/maoshuhao>
6
+ // This library is free software; you can redistribute it and/or modify
7
+ // it under the terms of the GNU Lesser General Public License as
8
+ // published by the Free Software Foundation; either version 2.1 of the
9
+ // License, or (at your option) any later version.
10
+ //
11
+ // This library is distributed in the hope that it will be useful, but
12
+ // WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ // Lesser General Public License for more details.
15
+ //
16
+ // You should have received a copy of the GNU Lesser General Public
17
+ // License along with this library; if not, write to the Free Software
18
+ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19
+ // 02110-1301 USA
20
+ //
21
+ // Modified by:
22
+ // Pieter Robberechts <http://github.com/probberechts>
23
+
24
+ /*exported searchFunc*/
25
+ var searchFunc = function(path, filter, searchId, contentId) {
26
+
27
+ function stripHtml(html) {
28
+ html = html.replace(/<style([\s\S]*?)<\/style>/gi, "");
29
+ html = html.replace(/<script([\s\S]*?)<\/script>/gi, "");
30
+ html = html.replace(/<figure([\s\S]*?)<\/figure>/gi, "");
31
+ html = html.replace(/<\/div>/ig, "\n");
32
+ html = html.replace(/<\/li>/ig, "\n");
33
+ html = html.replace(/<li>/ig, " * ");
34
+ html = html.replace(/<\/ul>/ig, "\n");
35
+ html = html.replace(/<\/p>/ig, "\n");
36
+ html = html.replace(/<br\s*[\/]?>/gi, "\n");
37
+ html = html.replace(/<[^>]+>/ig, "");
38
+ return html;
39
+ }
40
+
41
+ function getAllCombinations(keywords) {
42
+ var i, j, result = [];
43
+
44
+ for (i = 0; i < keywords.length; i++) {
45
+ for (j = i + 1; j < keywords.length + 1; j++) {
46
+ result.push(keywords.slice(i, j).join(" "));
47
+ }
48
+ }
49
+ return result;
50
+ }
51
+
52
+ $.ajax({
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
+
65
+ var $input = document.getElementById(searchId);
66
+ if (!$input) { return; }
67
+ var $resultContent = document.getElementById(contentId);
68
+
69
+ $input.addEventListener("input", function(){
70
+ var resultList = [];
71
+ var keywords = getAllCombinations(this.value.trim().toLowerCase().split(" "))
72
+ .sort(function(a,b) { return b.split(" ").length - a.split(" ").length; });
73
+ $resultContent.innerHTML = "";
74
+ if (this.value.trim().length <= 0) {
75
+ return;
76
+ }
77
+ // perform local searching
78
+ datas.forEach(function(data) {
79
+ var matches = 0;
80
+ if (!data.title || data.title.trim() === "") {
81
+ return;
82
+ }
83
+ if (filter && !data.url.includes(filter)) {
84
+ return;
85
+ }
86
+ var dataTitle = data.title.trim().toLowerCase();
87
+ var dataTitleLowerCase = dataTitle.toLowerCase();
88
+ var dataContent = stripHtml(data.content.trim());
89
+ var dataContentLowerCase = dataContent.toLowerCase();
90
+ var dataUrl = data.url;
91
+ var indexTitle = -1;
92
+ var indexContent = -1;
93
+ var firstOccur = -1;
94
+ // only match artiles with not empty contents
95
+ if (dataContent !== "") {
96
+ keywords.forEach(function(keyword) {
97
+ indexTitle = dataTitleLowerCase.indexOf(keyword);
98
+ indexContent = dataContentLowerCase.indexOf(keyword);
99
+
100
+ if( indexTitle >= 0 || indexContent >= 0 ){
101
+ matches += 1;
102
+ if (indexContent < 0) {
103
+ indexContent = 0;
104
+ }
105
+ if (firstOccur < 0) {
106
+ firstOccur = indexContent;
107
+ }
108
+ }
109
+ });
110
+ }
111
+ // show search results
112
+ if (matches > 0) {
113
+ var searchResult = {};
114
+ searchResult.rank = matches;
115
+ searchResult.str = "<li><a href='"+ dataUrl +"'><span class='search-result-title'>"+ dataTitle +"</span>";
116
+ if (firstOccur >= 0) {
117
+ // cut out 100 characters
118
+ var start = firstOccur - 20;
119
+ var end = firstOccur + 80;
120
+
121
+ if(start < 0){
122
+ start = 0;
123
+ }
124
+
125
+ if(start == 0){
126
+ end = 100;
127
+ }
128
+
129
+ if(end > dataContent.length){
130
+ end = dataContent.length;
131
+ }
132
+
133
+ var matchContent = dataContent.substring(start, end);
134
+
135
+ // highlight all keywords
136
+ var regS = new RegExp(keywords.join("|"), "gi");
137
+ matchContent = matchContent.replace(regS, function(keyword) {
138
+ return "<span class=\"search-keyword\">"+keyword+"</span>";
139
+ });
140
+
141
+ searchResult.str += "<p class=\"search-result-content\">" + matchContent +"...</p>";
142
+ }
143
+ searchResult.str += "</a></li>";
144
+ resultList.push(searchResult);
145
+ }
146
+ });
147
+ if (resultList.length) {
148
+ resultList.sort(function(a, b) {
149
+ return b.rank - a.rank;
150
+ });
151
+ var result ="<ul class=\"search-result-list\">";
152
+ for (var i = 0; i < resultList.length; i++) {
153
+ result += resultList[i].str;
154
+ }
155
+ result += "</ul>";
156
+ $resultContent.innerHTML = result;
157
+ }
158
+ });
159
+ }
160
+ });
161
+ };
@@ -1,36 +0,0 @@
1
- .widget-wrap#repo-info
2
- .widget-body
3
- a.repo
4
- display: block
5
- padding: 0.75rem 0.5rem
6
- color: var(--text-p2)
7
- background: var(--card)
8
- border-radius: $border-block
9
- box-shadow: $boxshadow-card
10
- trans2 box-shadow transform
11
- >div+div
12
- margin-top: 0.5rem
13
- span
14
- color: var(--text-p2)
15
- &:hover
16
- box-shadow: $boxshadow-card-float
17
- transform: translateY(-1px)
18
- a.repo
19
- svg
20
- margin-right: 4px
21
- .flex-row
22
- display: flex
23
- align-items: center
24
- .repo-name
25
- font-size: $fs-14
26
- font-weight: 700
27
- color: var(--text-p1)
28
- .repo-desc
29
- font-size: $fs-13
30
- margin-left: 2px
31
- margin-right: 2px
32
- .grid
33
- font-size: $fs-13
34
- display: grid
35
- grid-gap: 2px
36
- grid-template-columns: repeat(auto-fill, "calc((100% - 2 * %s) / 3)" % 2px)