jekyll-text-theme 1.5.0 → 2.0.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.
- checksums.yaml +4 -4
- data/README.md +41 -153
- data/_data/authors.yml +0 -0
- data/_data/licenses.yml +16 -0
- data/_data/locale.yml +4 -10
- data/_data/navigation.yml +13 -0
- data/_data/variables.yml +22 -6
- data/_includes/analytics-providers/custom.html +0 -0
- data/_includes/analytics-providers/google.html +16 -0
- data/_includes/analytics.html +7 -0
- data/_includes/article-footer/custom.html +1 -0
- data/_includes/article-footer/license.html +24 -0
- data/_includes/article-info.html +90 -0
- data/_includes/aside/toc.html +1 -0
- data/_includes/author-profile.html +50 -0
- data/_includes/comments-providers/custom.html +0 -0
- data/_includes/comments-providers/disqus.html +22 -0
- data/_includes/comments-providers/gitalk.html +32 -0
- data/_includes/comments.html +9 -0
- data/_includes/follow-me.html +84 -0
- data/_includes/footer.html +39 -0
- data/_includes/head.html +54 -0
- data/_includes/header.html +33 -0
- data/_includes/markdown-enhancements.html +32 -0
- data/_includes/{utils → markdown-enhancements}/chart.html +1 -3
- data/_includes/{utils → markdown-enhancements}/mathjax.html +11 -4
- data/_includes/{utils → markdown-enhancements}/mermaid.html +1 -3
- data/_includes/pageview-providers/custom.html +0 -0
- data/_includes/pageview-providers/custom/home.html +0 -0
- data/_includes/pageview-providers/custom/post.html +0 -0
- data/_includes/pageview-providers/leancloud/home.html +35 -0
- data/_includes/pageview-providers/leancloud/leancloud.js +71 -0
- data/_includes/pageview-providers/leancloud/post.html +31 -0
- data/_includes/pageview.html +31 -0
- data/_includes/scripts/archieve.js +238 -0
- data/_includes/scripts/article-list.html +27 -0
- data/_includes/scripts/article.js +24 -0
- data/_includes/scripts/aside/affix.js +26 -0
- data/_includes/scripts/aside/toc.js +37 -0
- data/_includes/scripts/common.js +3 -0
- data/_includes/scripts/home.js +3 -0
- data/_includes/scripts/lib/affix.js +103 -0
- data/_includes/scripts/{utils.html → lib/lazyload.js} +55 -92
- data/_includes/scripts/lib/scroll.js +13 -0
- data/_includes/scripts/lib/throttle.js +28 -0
- data/_includes/scripts/lib/toc.js +106 -0
- data/_includes/scripts/page.js +3 -0
- data/_includes/scripts/sidebar.js +14 -0
- data/_includes/scripts/utils.js +38 -0
- data/_includes/scripts/variables.html +27 -0
- data/_includes/sidebar/toc.html +27 -0
- data/_includes/snippets/assign.html +5 -0
- data/_includes/snippets/get-nav-url.html +3 -2
- data/_includes/snippets/page-title.html +11 -6
- data/_includes/snippets/page-url.html +3 -1
- data/_includes/snippets/to-boolean.html +7 -0
- data/_includes/{icon → svg/icon}/social/behance.svg +0 -0
- data/_includes/{icon → svg/icon}/social/douban.svg +0 -0
- data/_includes/{icon → svg/icon}/social/facebook.svg +0 -0
- data/_includes/{icon → svg/icon}/social/flicker.svg +0 -0
- data/_includes/{icon → svg/icon}/social/github.svg +0 -0
- data/_includes/{icon → svg/icon}/social/googleplus.svg +0 -0
- data/_includes/{icon → svg/icon}/social/linkedin.svg +0 -0
- data/_includes/{icon → svg/icon}/social/mail.svg +0 -0
- data/_includes/{icon → svg/icon}/social/pinterest.svg +0 -0
- data/_includes/{icon → svg/icon}/social/qq.svg +0 -0
- data/_includes/{icon → svg/icon}/social/twitter.svg +0 -0
- data/_includes/{icon → svg/icon}/social/weibo.svg +0 -0
- data/_includes/{icon → svg/icon}/social/weixin.svg +0 -0
- data/_includes/{icon → svg/icon}/social/zhihu.svg +0 -0
- data/_includes/{logo → svg}/logo.svg +1 -1
- data/_includes/tags.html +52 -0
- data/_layouts/404.html +12 -0
- data/_layouts/archive.html +25 -0
- data/_layouts/article.html +78 -0
- data/_layouts/base.html +13 -33
- data/_layouts/home.html +135 -121
- data/_layouts/landing.html +164 -0
- data/_layouts/page.html +157 -9
- data/_sass/additional/_alert.scss +25 -0
- data/_sass/additional/_photo-frame.scss +17 -0
- data/_sass/animate/_fade-in-down.scss +1 -1
- data/_sass/animate/_fade-in.scss +1 -1
- data/_sass/common/_classes.scss +5 -2
- data/_sass/common/_reset.scss +32 -22
- data/_sass/common/_variables.scss +87 -31
- data/_sass/common/classes/_animation.scss +9 -0
- data/_sass/common/classes/_clearfix.scss +8 -0
- data/_sass/common/classes/_grid.scss +48 -0
- data/_sass/common/classes/_horizontal-rules.scss +14 -0
- data/_sass/common/classes/_link.scss +18 -145
- data/_sass/common/classes/_media.scss +1 -2
- data/_sass/common/classes/_overflow.scss +8 -0
- data/_sass/common/classes/_pseudo.scss +26 -0
- data/_sass/common/classes/_shadow.scss +13 -5
- data/_sass/common/classes/_spacing.scss +52 -0
- data/_sass/common/components/_button.scss +179 -47
- data/_sass/common/components/_card.scss +18 -0
- data/_sass/common/components/_menu.scss +43 -0
- data/_sass/common/components/_toc.scss +125 -0
- data/_sass/components/_article.content.scss +37 -45
- data/_sass/components/_article.info.scss +25 -0
- data/_sass/components/_author-profile.scss +43 -0
- data/_sass/components/_follow-me.scss +16 -19
- data/_sass/components/_footer.scss +16 -6
- data/_sass/components/_header.scss +26 -18
- data/_sass/components/_license.scss +1 -25
- data/_sass/components/_main.scss +13 -11
- data/_sass/components/_tags.scss +17 -36
- data/_sass/layout/{_error-404.scss → _404.scss} +2 -2
- data/_sass/layout/_all.scss +72 -63
- data/_sass/layout/_article.scss +44 -0
- data/_sass/layout/_home.scss +61 -52
- data/_sass/layout/_landing.scss +104 -0
- data/_sass/layout/_page.scss +155 -0
- data/_sass/{colors → skins}/_chocolate.scss +17 -6
- data/_sass/skins/_dark.scss +56 -0
- data/_sass/{colors → skins}/_default.scss +16 -5
- data/_sass/{colors → skins}/_forest.scss +16 -5
- data/_sass/{colors → skins}/_ocean.scss +16 -5
- data/_sass/{colors → skins}/_orange.scss +20 -9
- data/assets/android-chrome-192x192.png +0 -0
- data/assets/android-chrome-512x512.png +0 -0
- data/assets/apple-touch-icon.png +0 -0
- data/assets/browserconfig.xml +9 -0
- data/assets/css/main.scss +46 -0
- data/assets/favicon-16x16.png +0 -0
- data/assets/favicon-32x32.png +0 -0
- data/assets/favicon.ico +0 -0
- data/assets/images/logo/logo.svg +1 -1
- data/assets/mstile-144x144.png +0 -0
- data/assets/mstile-150x150.png +0 -0
- data/assets/mstile-310x150.png +0 -0
- data/assets/mstile-310x310.png +0 -0
- data/assets/mstile-70x70.png +0 -0
- data/assets/safari-pinned-tab.svg +38 -0
- data/assets/site.webmanifest +19 -0
- metadata +108 -76
- data/_includes/common-head.html +0 -10
- data/_includes/components/article-data.html +0 -55
- data/_includes/components/follow-me.html +0 -78
- data/_includes/components/footer.html +0 -10
- data/_includes/components/header.html +0 -42
- data/_includes/components/license.html +0 -26
- data/_includes/components/tags.html +0 -52
- data/_includes/head-icons-rel.html +0 -38
- data/_includes/icon/clear.svg +0 -3
- data/_includes/icon/link.svg +0 -1
- data/_includes/icon/menu.svg +0 -3
- data/_includes/icon/next.svg +0 -3
- data/_includes/icon/omit.svg +0 -1
- data/_includes/icon/previous.svg +0 -3
- data/_includes/icon/search.svg +0 -3
- data/_includes/scripts/all.html +0 -244
- data/_includes/scripts/common.html +0 -30
- data/_includes/scripts/data.html +0 -27
- data/_includes/scripts/home.html +0 -26
- data/_includes/scripts/page-post.html +0 -32
- data/_includes/scripts/post.html +0 -183
- data/_includes/utils/comment-disqus.html +0 -19
- data/_includes/utils/comment-gitalk.html +0 -25
- data/_includes/utils/google-analytics.html +0 -11
- data/_layouts/all.html +0 -20
- data/_layouts/error-404.html +0 -9
- data/_layouts/post.html +0 -60
- data/_sass/colors/_dark.scss +0 -45
- data/_sass/common/classes/_shape.scss +0 -19
- data/_sass/common/classes/_space.scss +0 -40
- data/_sass/components/_article.content.extra.scss +0 -41
- data/_sass/components/_article.data.scss +0 -36
- data/_sass/components/_pagination.scss +0 -19
- data/_sass/components/_toc.scss +0 -72
- data/_sass/layout/_default.scss +0 -19
- data/_sass/layout/_post.scss +0 -80
- data/assets/css/blog.scss +0 -41
- data/assets/images/logo/icon-120x120.png +0 -0
- data/assets/images/logo/icon-128x128.png +0 -0
- data/assets/images/logo/icon-150x150.png +0 -0
- data/assets/images/logo/icon-152x152.png +0 -0
- data/assets/images/logo/icon-167x167.png +0 -0
- data/assets/images/logo/icon-16x16.png +0 -0
- data/assets/images/logo/icon-180x180.png +0 -0
- data/assets/images/logo/icon-192x192.png +0 -0
- data/assets/images/logo/icon-310x150.png +0 -0
- data/assets/images/logo/icon-310x310.png +0 -0
- data/assets/images/logo/icon-48x48.png +0 -0
- data/assets/images/logo/icon-70x70.png +0 -0
@@ -0,0 +1,71 @@
|
|
1
|
+
(function() {
|
2
|
+
function errorHandler(error, callback) {
|
3
|
+
if (error) {
|
4
|
+
callback && callback(error);
|
5
|
+
throw error;
|
6
|
+
}
|
7
|
+
}
|
8
|
+
|
9
|
+
function pageview(_AV ,options) {
|
10
|
+
var AV = _AV;
|
11
|
+
var appId, appKey, appClass;
|
12
|
+
appId = options.appId;
|
13
|
+
appKey = options.appKey;
|
14
|
+
appClass = options.appClass;
|
15
|
+
AV.init({
|
16
|
+
appId: appId,
|
17
|
+
appKey: appKey
|
18
|
+
});
|
19
|
+
return {
|
20
|
+
get: get,
|
21
|
+
increase: increase
|
22
|
+
};
|
23
|
+
|
24
|
+
function searchKey(key) {
|
25
|
+
var query = new AV.Query(appClass);
|
26
|
+
query.equalTo('key', key);
|
27
|
+
return query.first();
|
28
|
+
}
|
29
|
+
|
30
|
+
function insert(key, title) {
|
31
|
+
var Blog = AV.Object.extend(appClass);
|
32
|
+
var blog = new Blog();
|
33
|
+
blog.set('title', title);
|
34
|
+
blog.set('key', key);
|
35
|
+
blog.set('views', 0);
|
36
|
+
return blog.save();
|
37
|
+
}
|
38
|
+
|
39
|
+
function increment(result) {
|
40
|
+
result.increment('views', 1);
|
41
|
+
return result.save(null, {
|
42
|
+
fetchWhenSave: true
|
43
|
+
});
|
44
|
+
}
|
45
|
+
|
46
|
+
function get(key, callback) {
|
47
|
+
searchKey(key).then(function(result) {
|
48
|
+
if (result) {
|
49
|
+
callback && callback(result.attributes.views);
|
50
|
+
}
|
51
|
+
}, errorHandler);
|
52
|
+
}
|
53
|
+
|
54
|
+
function increase(key, title, callback) {
|
55
|
+
searchKey(key).then(function(result) {
|
56
|
+
if (result) {
|
57
|
+
increment(result).then(function(result) {
|
58
|
+
callback && callback(result.attributes.views);
|
59
|
+
});
|
60
|
+
} else {
|
61
|
+
insert(key, title).then(function(result) {
|
62
|
+
increment(result).then(function(result) {
|
63
|
+
callback && callback(result.attributes.views);
|
64
|
+
});
|
65
|
+
}, errorHandler);
|
66
|
+
}
|
67
|
+
}, errorHandler);
|
68
|
+
}
|
69
|
+
}
|
70
|
+
window.pageview = pageview;
|
71
|
+
})();
|
@@ -0,0 +1,31 @@
|
|
1
|
+
{%- include snippets/get-sources.html -%}
|
2
|
+
{%- assign _sources = __return -%}
|
3
|
+
|
4
|
+
{%- assign _LEANCLOUD_APP_ID = site.pageview.leancloud.app_id -%}
|
5
|
+
{%- assign _LEANCLOUD_APP_KEY = site.pageview.leancloud.app_key -%}
|
6
|
+
{%- assign _LEANCLOUD_APP_CLASS = site.pageview.leancloud.app_class -%}
|
7
|
+
|
8
|
+
{%- if page.key and
|
9
|
+
_LEANCLOUD_APP_ID and
|
10
|
+
_LEANCLOUD_APP_KEY and
|
11
|
+
_LEANCLOUD_APP_CLASS -%}
|
12
|
+
|
13
|
+
<script>
|
14
|
+
{%- include pageview-providers/leancloud/leancloud.js -%}
|
15
|
+
</script>
|
16
|
+
<script>
|
17
|
+
window.Lazyload.js(['{{ _sources.jquery }}', '{{ _sources.leancloud_js_sdk}}'], function() {
|
18
|
+
var pageview = window.pageview(AV, {
|
19
|
+
appId: '{{ _LEANCLOUD_APP_ID }}',
|
20
|
+
appKey: '{{ _LEANCLOUD_APP_KEY }}',
|
21
|
+
appClass: '{{ _LEANCLOUD_APP_CLASS }}'
|
22
|
+
});
|
23
|
+
var key = '{{ page.key }}';
|
24
|
+
var title = window.decodeUrl('{{ page.title | url_encode }}');
|
25
|
+
pageview.increase(key, title, function(view) {
|
26
|
+
$("[data-page-key='{{ page.key }}']").text(view);
|
27
|
+
});
|
28
|
+
});
|
29
|
+
</script>
|
30
|
+
|
31
|
+
{%- endif -%}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
{%- assign __source = page.pageview -%}
|
2
|
+
{%- assign __target = site.data.variables.default.pageview -%}
|
3
|
+
{%- include snippets/assign.html -%}
|
4
|
+
{%- assign _pageview = __return -%}
|
5
|
+
|
6
|
+
|
7
|
+
{%- if page.layout == "home" -%}
|
8
|
+
|
9
|
+
{%- if jekyll.environment != "development" -%}
|
10
|
+
{%- if site.pageview.provider == 'leancloud' -%}
|
11
|
+
{%- include pageview-providers/leancloud/home.html -%}
|
12
|
+
{%- elsif site.pageview.provider == 'custom' -%}
|
13
|
+
{%- include pageview-providers/custom/home.html -%}
|
14
|
+
{%- endif -%}
|
15
|
+
{%- endif -%}
|
16
|
+
|
17
|
+
|
18
|
+
{%- elsif page.layout == "article" -%}
|
19
|
+
{%- if _pageview -%}
|
20
|
+
|
21
|
+
{%- if jekyll.environment != "development" and
|
22
|
+
jekyll.environment != "beta" -%}
|
23
|
+
{%- if site.pageview.provider == 'leancloud' -%}
|
24
|
+
{%- include pageview-providers/leancloud/post.html -%}
|
25
|
+
{%- elsif site.pageview.provider == 'custom' -%}
|
26
|
+
{%- include pageview-providers/custom/post.html -%}
|
27
|
+
{%- endif -%}
|
28
|
+
{%- endif -%}
|
29
|
+
|
30
|
+
{%- endif -%}
|
31
|
+
{%- endif -%}
|
@@ -0,0 +1,238 @@
|
|
1
|
+
(function() {
|
2
|
+
var SOURCES = window.TEXT_VARIABLES.sources;
|
3
|
+
function queryString() {
|
4
|
+
// This function is anonymous, is executed immediately and
|
5
|
+
// the return value is assigned to QueryString!
|
6
|
+
var i = 0, queryObj = {}, pair;
|
7
|
+
var queryStr = window.location.search.substring(1);
|
8
|
+
var queryArr = queryStr.split('&');
|
9
|
+
for (i = 0; i < queryArr.length; i++) {
|
10
|
+
pair = queryArr[i].split('=');
|
11
|
+
// If first entry with this name
|
12
|
+
if (typeof queryObj[pair[0]] === 'undefined') {
|
13
|
+
queryObj[pair[0]] = pair[1];
|
14
|
+
// If second entry with this name
|
15
|
+
} else if (typeof queryObj[pair[0]] === 'string') {
|
16
|
+
queryObj[pair[0]] = [queryObj[pair[0]], pair[1]];
|
17
|
+
// If third or later entry with this name
|
18
|
+
} else {
|
19
|
+
queryObj[pair[0]].push(pair[1]);
|
20
|
+
}
|
21
|
+
}
|
22
|
+
return queryObj;
|
23
|
+
}
|
24
|
+
|
25
|
+
function memorize(f) {
|
26
|
+
var cache = {};
|
27
|
+
return function () {
|
28
|
+
var key = Array.prototype.join.call(arguments, ',');
|
29
|
+
if (key in cache) return cache[key];
|
30
|
+
else return cache[key] = f.apply(this, arguments);
|
31
|
+
};
|
32
|
+
}
|
33
|
+
|
34
|
+
function initData(json) {
|
35
|
+
var _data = JSON.parse(json), i, j, cur, _tags;
|
36
|
+
Object.keys(_data).forEach(function(year) {
|
37
|
+
for (i = 0; i < _data[year].length; i++) {
|
38
|
+
cur = _data[year][i], _tags = cur.tags;
|
39
|
+
cur.title = window.decodeUrl(cur.title);
|
40
|
+
cur.url = window.decodeUrl(cur.url);
|
41
|
+
if (_tags && _tags.length > 0) {
|
42
|
+
for (j = 0; j < _tags.length; j++) {
|
43
|
+
_tags[j] = window.decodeUrl(_tags[j]);
|
44
|
+
}
|
45
|
+
}
|
46
|
+
}
|
47
|
+
});
|
48
|
+
return _data;
|
49
|
+
}
|
50
|
+
|
51
|
+
var setUrlQuery = (function() {
|
52
|
+
var baseUrl = window.location.href.split('?')[0];
|
53
|
+
return function(query) {
|
54
|
+
if (typeof query === 'string') {
|
55
|
+
window.history.replaceState(null, '', baseUrl + query);
|
56
|
+
} else {
|
57
|
+
window.history.replaceState(null, '', baseUrl);
|
58
|
+
}
|
59
|
+
};
|
60
|
+
})();
|
61
|
+
|
62
|
+
var data = initData('{%- include scripts/article-list.html -%}');
|
63
|
+
|
64
|
+
var searchByTag = memorize(function(tag) {
|
65
|
+
var i, j, cur, _tags, _tag, _data = {};
|
66
|
+
Object.keys(data).forEach(function(year) {
|
67
|
+
for (i = 0; i < data[year].length; i++) {
|
68
|
+
cur = data[year][i], _tags = cur.tags;
|
69
|
+
if (_tags && _tags.length > 0) {
|
70
|
+
for (j = 0; j < _tags.length; j++) {
|
71
|
+
_tag = _tags[j];
|
72
|
+
if (_tag === tag) {
|
73
|
+
if (!_data[year]) {
|
74
|
+
_data[year] = [];
|
75
|
+
}
|
76
|
+
_data[year].push(cur);
|
77
|
+
break;
|
78
|
+
}
|
79
|
+
}
|
80
|
+
}
|
81
|
+
}
|
82
|
+
});
|
83
|
+
return _data;
|
84
|
+
});
|
85
|
+
|
86
|
+
var searchByQuery = function(query) {
|
87
|
+
var i, cur, _title, _data = { _: [] };
|
88
|
+
Object.keys(data).forEach(function(year) {
|
89
|
+
for (i = 0; i < data[year].length; i++) {
|
90
|
+
cur = data[year][i], _title = cur.title;
|
91
|
+
if (_title.toLowerCase().indexOf(query.toLowerCase()) >= 0) {
|
92
|
+
_data._.push(cur);
|
93
|
+
}
|
94
|
+
}
|
95
|
+
});
|
96
|
+
return _data;
|
97
|
+
};
|
98
|
+
|
99
|
+
window.Lazyload.js(SOURCES.jquery, function() {
|
100
|
+
var $root = $('.js-all');
|
101
|
+
var $searchBox = $('.js-search-box');
|
102
|
+
var $searchInput = $searchBox.children('input');
|
103
|
+
var $searchClear = $searchBox.children('.icon-clear');
|
104
|
+
var $tags = $('.js-tags');
|
105
|
+
var $articleTags = $('.js-article-tag');
|
106
|
+
var $tagShowAll = $('.js-tag-show-all');
|
107
|
+
var $result = $('.js-result');
|
108
|
+
var $lastFocusButton = null;
|
109
|
+
|
110
|
+
function addClass(dom, className) {
|
111
|
+
dom.hasClass(className) || dom.addClass(className);
|
112
|
+
}
|
113
|
+
function removeClass(dom, className) {
|
114
|
+
dom.hasClass(className) && dom.removeClass(className);
|
115
|
+
}
|
116
|
+
|
117
|
+
var renderHeading = memorize(function (year) {
|
118
|
+
return $('<h2 class="year">' + year + '</h2>');
|
119
|
+
});
|
120
|
+
var renderItem = memorize(function (key, title, date, url) {
|
121
|
+
return $('<li><span class="date">' + date + '</span><a class="link" href="' + url + '">' + title + '</a></li>');
|
122
|
+
});
|
123
|
+
function render(data) {
|
124
|
+
var $dom = $('<div></div>'), $section, $ul, i, cur;
|
125
|
+
Object.keys(data).sort(function(a, b) {
|
126
|
+
return b.localeCompare(a);
|
127
|
+
}).forEach(function(year) {
|
128
|
+
$section = $('<section></section>'), $ul = $('<ul></ul>');
|
129
|
+
(year === '_') || $section.append(renderHeading(year));
|
130
|
+
for (i = 0; i < data[year].length; i++) {
|
131
|
+
cur = data[year][i];
|
132
|
+
$ul.append(renderItem(cur.key, cur.title, cur.date, cur.url, cur.tags));
|
133
|
+
}
|
134
|
+
$dom.append($section.append($ul));
|
135
|
+
});
|
136
|
+
return $dom;
|
137
|
+
}
|
138
|
+
|
139
|
+
function searchButtonsByTag(_tag/*raw tag*/) {
|
140
|
+
if (!_tag) {
|
141
|
+
return $tagShowAll;
|
142
|
+
}
|
143
|
+
var _buttons = $articleTags.filter('[data-encode="' + _tag + '"]');
|
144
|
+
if (_buttons.length === 0) {
|
145
|
+
return $tagShowAll;
|
146
|
+
}
|
147
|
+
return _buttons;
|
148
|
+
}
|
149
|
+
function buttonFoucs(target) {
|
150
|
+
if (target) {
|
151
|
+
addClass(target, 'focus');
|
152
|
+
$lastFocusButton && !$lastFocusButton.is(target) && removeClass($lastFocusButton, 'focus');
|
153
|
+
$lastFocusButton = target;
|
154
|
+
}
|
155
|
+
}
|
156
|
+
|
157
|
+
function setIsSearch() {
|
158
|
+
addClass($root, 'search');
|
159
|
+
}
|
160
|
+
function setNotSearch() {
|
161
|
+
removeClass($root, 'search');
|
162
|
+
}
|
163
|
+
function setIsEmpty() {
|
164
|
+
removeClass($searchBox, 'not-empty');
|
165
|
+
}
|
166
|
+
function setNotEmpty() {
|
167
|
+
addClass($searchBox, 'not-empty');
|
168
|
+
}
|
169
|
+
function setSearchBoxVal(val) {
|
170
|
+
($searchInput.val() === val) || $searchInput.val(val);
|
171
|
+
}
|
172
|
+
function clearSearchBox() {
|
173
|
+
setSearchBoxVal(''); queryInput('');
|
174
|
+
}
|
175
|
+
|
176
|
+
function showAll() {
|
177
|
+
setNotSearch(); setIsEmpty(); buttonFoucs($tagShowAll); setUrlQuery();
|
178
|
+
$result.html(render(data));
|
179
|
+
}
|
180
|
+
function tagSelect(tag/*decode tag*/, target) {
|
181
|
+
var _tag;
|
182
|
+
if (tag === '' || tag === undefined) {
|
183
|
+
showAll();
|
184
|
+
} else {
|
185
|
+
$result.html(render(searchByTag(tag)));
|
186
|
+
}
|
187
|
+
if (target) {
|
188
|
+
buttonFoucs(target);
|
189
|
+
_tag = target.attr('data-encode');
|
190
|
+
if (_tag === '' || typeof _tag !== 'string') {
|
191
|
+
setUrlQuery();
|
192
|
+
} else {
|
193
|
+
setUrlQuery('?tag=' + _tag);
|
194
|
+
}
|
195
|
+
}
|
196
|
+
}
|
197
|
+
function queryInput(query) {
|
198
|
+
if (query === '' || typeof query !== 'string') {
|
199
|
+
showAll();
|
200
|
+
} else {
|
201
|
+
$result.html(render(searchByQuery(query))); setIsSearch(); setNotEmpty(); setUrlQuery('?q=' + query);
|
202
|
+
|
203
|
+
}
|
204
|
+
}
|
205
|
+
|
206
|
+
(function() {
|
207
|
+
$articleTags.removeClass('inactive');
|
208
|
+
var query = queryString(), _tag = query.tag, _q = query.q;
|
209
|
+
if (_tag !== undefined) {
|
210
|
+
query.tag === undefined || (_tag = query.tag);
|
211
|
+
tagSelect(window.decodeUrl(_tag));
|
212
|
+
buttonFoucs(searchButtonsByTag(_tag));
|
213
|
+
} else if (_q !== undefined) {
|
214
|
+
_q = window.decodeUrl(_q);
|
215
|
+
queryInput(_q); setSearchBoxVal(_q);
|
216
|
+
} else {
|
217
|
+
showAll();
|
218
|
+
}
|
219
|
+
})();
|
220
|
+
|
221
|
+
$tags.on('click', 'button', function() {
|
222
|
+
tagSelect($(this).children('span').text(), $(this));
|
223
|
+
});
|
224
|
+
|
225
|
+
$searchInput.on('input', window.throttle(function() {
|
226
|
+
queryInput($(this).val());
|
227
|
+
}, 400));
|
228
|
+
$searchInput.on('focus', function() {
|
229
|
+
addClass($(this), 'focus');
|
230
|
+
});
|
231
|
+
$searchInput.on('blur', function() {
|
232
|
+
removeClass($(this), 'focus');
|
233
|
+
});
|
234
|
+
$searchClear.on('click', function() {
|
235
|
+
clearSearchBox();
|
236
|
+
});
|
237
|
+
});
|
238
|
+
})();
|
@@ -0,0 +1,27 @@
|
|
1
|
+
{%- assign __locale = site.data.locale.ARTICLE_LIST_DATE_FORMAT -%}
|
2
|
+
{%- include snippets/locale-to-string.html -%}
|
3
|
+
{%- assign _format = __return -%}
|
4
|
+
{%- assign _post_count = site.posts | size -%}
|
5
|
+
{%- if _post_count < 1 -%}
|
6
|
+
{}
|
7
|
+
{%- else -%}
|
8
|
+
{
|
9
|
+
{%- for _post in site.posts -%}
|
10
|
+
{%- assign _currentdate = _post.date | date: '%Y' -%}
|
11
|
+
{%- if _currentdate != _date -%}
|
12
|
+
{%- unless forloop.first -%}],{%- endunless -%}
|
13
|
+
"{{ _currentdate }}":[{
|
14
|
+
{%- assign _date = _currentdate -%}
|
15
|
+
{%- else -%},{
|
16
|
+
{%- endif -%}
|
17
|
+
"key":"{{ forloop.index }}","title":"{{ _post.title | url_encode }}","tags":[
|
18
|
+
{%- for _tag in _post.tags -%}
|
19
|
+
"{{ _tag | url_encode }}" {%- unless forloop.last -%},{%- endunless -%}
|
20
|
+
{%- endfor -%}
|
21
|
+
{%- assign __path = _post.url -%}
|
22
|
+
{%- include snippets/prepend-baseurl.html -%}
|
23
|
+
{%- assign _url = __return -%}
|
24
|
+
],"url":"{{ _url | url_encode }}","date":"{{ _post.date | date: _format }}"}
|
25
|
+
{%- endfor -%}
|
26
|
+
]}
|
27
|
+
{%- endif -%}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
(function() {
|
2
|
+
var SOURCES = window.TEXT_VARIABLES.sources;
|
3
|
+
window.Lazyload.js(SOURCES.jquery, function() {
|
4
|
+
$(function() {
|
5
|
+
var $this ,$scroll;
|
6
|
+
var $articleContent = $('.js-article-content');
|
7
|
+
var hasSidebar = $('.js-page-root').hasClass('layout--page--sidebar');
|
8
|
+
var scroll = hasSidebar ? '.js-page-main' : 'html, body';
|
9
|
+
$scroll = $(scroll);
|
10
|
+
|
11
|
+
$articleContent.find('.highlight').each(function() {
|
12
|
+
$this = $(this);
|
13
|
+
$this.attr('data-lang', $this.find('code').attr('data-lang'));
|
14
|
+
});
|
15
|
+
$articleContent.find('h1, h2, h3, h4, h5, h6').each(function() {
|
16
|
+
$this = $(this);
|
17
|
+
$this.append($('<a class="anchor" aria-hidden="true"></a>').html('<i class="fas fa-anchor"></i>'));
|
18
|
+
});
|
19
|
+
$articleContent.on('click', '.anchor', function() {
|
20
|
+
$scroll.scrollToAnchor('#' + $(this).parent().attr('id'), 400);
|
21
|
+
});
|
22
|
+
});
|
23
|
+
});
|
24
|
+
})();
|
@@ -0,0 +1,26 @@
|
|
1
|
+
(function() {
|
2
|
+
var SOURCES = window.TEXT_VARIABLES.sources;
|
3
|
+
window.Lazyload.js(SOURCES.jquery, function() {
|
4
|
+
var $window = $(window), $pageFooter = $('.js-page-footer');
|
5
|
+
var $pageAside = $('.js-page-aside');
|
6
|
+
var affix;
|
7
|
+
var tocDisabled = false;
|
8
|
+
var hasSidebar = $('.js-page-root').hasClass('layout--page--sidebar');
|
9
|
+
|
10
|
+
setTimeout(function() {
|
11
|
+
affix = $pageAside.affix({
|
12
|
+
offsetBottom: $pageFooter.outerHeight(),
|
13
|
+
scrollTarget: hasSidebar ? '.js-page-main' : null,
|
14
|
+
scroller: hasSidebar ? '.js-page-main' : null,
|
15
|
+
scroll: hasSidebar ? $('.js-page-main').children() : null,
|
16
|
+
disabled: tocDisabled
|
17
|
+
});
|
18
|
+
}, 1000);
|
19
|
+
|
20
|
+
$window.on('resize', window.throttle(function() {
|
21
|
+
affix && affix.setOptions({
|
22
|
+
disabled: tocDisabled
|
23
|
+
});
|
24
|
+
}, 100));
|
25
|
+
});
|
26
|
+
})();
|