hexo-theme-shokax 0.4.5 → 0.4.6-beta2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (183) hide show
  1. package/CODE_OF_CONDUCT.md +128 -128
  2. package/CONTRIBUTING.md +58 -58
  3. package/LICENSE +660 -660
  4. package/LICENSE-shoka +21 -21
  5. package/README.md +99 -98
  6. package/README_en.MD +91 -90
  7. package/UsageRestrictions.md +25 -25
  8. package/_config.yml +381 -388
  9. package/_images.yml +9 -9
  10. package/eslint.config.mjs +55 -55
  11. package/index.html +231 -0
  12. package/languages/README.md +19 -19
  13. package/languages/default.yml +1 -1
  14. package/languages/en.yml +153 -153
  15. package/languages/ja.yml +153 -153
  16. package/languages/zh-CN.yml +153 -153
  17. package/languages/zh-HK.yml +153 -153
  18. package/languages/zh-TW.yml +153 -153
  19. package/layout/_alternate/atom.ejs +30 -30
  20. package/layout/_alternate/json.ejs +16 -16
  21. package/layout/_alternate/rss.ejs +34 -34
  22. package/layout/_mixin/breadcrumb.pug +33 -33
  23. package/layout/_mixin/card.pug +38 -38
  24. package/layout/_mixin/comment.pug +6 -6
  25. package/layout/_mixin/postmeta.pug +29 -29
  26. package/layout/_mixin/segment.pug +35 -35
  27. package/layout/_mixin/sidebar.pug +40 -40
  28. package/layout/_mixin/widgets.pug +28 -28
  29. package/layout/_partials/footer.pug +43 -43
  30. package/layout/_partials/head/head.pug +55 -56
  31. package/layout/_partials/head/head_com.pug +24 -24
  32. package/layout/_partials/head/pwa.pug +18 -18
  33. package/layout/_partials/header.pug +18 -18
  34. package/layout/_partials/layout.pug +140 -140
  35. package/layout/_partials/loading.pug +13 -13
  36. package/layout/_partials/pagination.pug +4 -4
  37. package/layout/_partials/post/copyright.pug +20 -20
  38. package/layout/_partials/post/footer.pug +17 -17
  39. package/layout/_partials/post/nav.pug +13 -13
  40. package/layout/_partials/post/post.pug +41 -41
  41. package/layout/_partials/post/reward.pug +18 -18
  42. package/layout/_partials/sidebar/menu.pug +37 -37
  43. package/layout/_partials/sidebar/overview.pug +42 -42
  44. package/layout/_partials/third-party/baidu-analytics.pug +11 -11
  45. package/layout/_partials/third-party/clarity.pug +8 -8
  46. package/layout/_partials/third-party/google-analytics.pug +9 -9
  47. package/layout/archive.pug +118 -118
  48. package/layout/category.pug +59 -59
  49. package/layout/index.pug +33 -33
  50. package/layout/page.pug +55 -55
  51. package/layout/post.pug +36 -36
  52. package/layout/tag.pug +43 -43
  53. package/meta.json +6431 -0
  54. package/package.json +72 -70
  55. package/scripts/helpers/engine.js +10 -0
  56. package/scripts/plugin/check.js +2 -2
  57. package/scripts/tags/links.js +4 -4
  58. package/source/assets/algolia_logo.svg +9 -9
  59. package/source/assets/logo.svg +16 -16
  60. package/source/css/_colors.styl +207 -207
  61. package/source/css/_common/components/components.styl +6 -6
  62. package/source/css/_common/components/highlight/highlight.styl +357 -357
  63. package/source/css/_common/components/highlight/operation.styl +21 -21
  64. package/source/css/_common/components/pages/collapse.styl +119 -119
  65. package/source/css/_common/components/pages/home.styl +391 -391
  66. package/source/css/_common/components/pages/pages.styl +56 -56
  67. package/source/css/_common/components/pages/tag-cloud.styl +12 -12
  68. package/source/css/_common/components/post/breadcrumb.styl +39 -39
  69. package/source/css/_common/components/post/copyright.styl +41 -41
  70. package/source/css/_common/components/post/expand.styl +263 -263
  71. package/source/css/_common/components/post/footer.styl +11 -11
  72. package/source/css/_common/components/post/header.styl +79 -79
  73. package/source/css/_common/components/post/nav.styl +64 -64
  74. package/source/css/_common/components/post/post.styl +29 -29
  75. package/source/css/_common/components/post/reward.styl +50 -50
  76. package/source/css/_common/components/post/rtl.styl +12 -12
  77. package/source/css/_common/components/post/tags.styl +39 -39
  78. package/source/css/_common/components/tags/collapse.styl +72 -72
  79. package/source/css/_common/components/tags/container.styl +49 -49
  80. package/source/css/_common/components/tags/label.styl +12 -12
  81. package/source/css/_common/components/tags/links.styl +77 -77
  82. package/source/css/_common/components/tags/list.styl +131 -131
  83. package/source/css/_common/components/tags/note.styl +70 -70
  84. package/source/css/_common/components/tags/player.styl +361 -361
  85. package/source/css/_common/components/tags/quiz.styl +200 -200
  86. package/source/css/_common/components/tags/tabs.styl +89 -89
  87. package/source/css/_common/components/tags/tags.styl +9 -9
  88. package/source/css/_common/components/third-party/loading.styl +222 -222
  89. package/source/css/_common/components/third-party/mermaid/class.styl +90 -90
  90. package/source/css/_common/components/third-party/mermaid/flowchart.styl +72 -72
  91. package/source/css/_common/components/third-party/mermaid/gantt.styl +251 -251
  92. package/source/css/_common/components/third-party/mermaid/git.styl +7 -7
  93. package/source/css/_common/components/third-party/mermaid/mermaid.styl +37 -37
  94. package/source/css/_common/components/third-party/mermaid/pie.styl +9 -9
  95. package/source/css/_common/components/third-party/mermaid/sequence.styl +95 -95
  96. package/source/css/_common/components/third-party/mermaid/state.styl +130 -130
  97. package/source/css/_common/components/third-party/pace.styl +18 -18
  98. package/source/css/_common/components/third-party/search.styl +167 -167
  99. package/source/css/_common/components/third-party/theme.styl +151 -151
  100. package/source/css/_common/components/third-party/third-party.styl +22 -22
  101. package/source/css/_common/components/third-party/widgets.styl +57 -57
  102. package/source/css/_common/outline/footer/footer.styl +67 -67
  103. package/source/css/_common/outline/header/brand.styl +77 -77
  104. package/source/css/_common/outline/header/header.styl +20 -20
  105. package/source/css/_common/outline/header/image.styl +85 -85
  106. package/source/css/_common/outline/header/menu.styl +117 -117
  107. package/source/css/_common/outline/header/nav.styl +81 -81
  108. package/source/css/_common/outline/header/right.styl +15 -15
  109. package/source/css/_common/outline/header/tool.styl +207 -207
  110. package/source/css/_common/outline/header/waves.styl +57 -57
  111. package/source/css/_common/outline/mobile.styl +46 -46
  112. package/source/css/_common/outline/outline.styl +78 -78
  113. package/source/css/_common/outline/sidebar/author.styl +59 -59
  114. package/source/css/_common/outline/sidebar/dimmer.styl +23 -23
  115. package/source/css/_common/outline/sidebar/menu.styl +63 -63
  116. package/source/css/_common/outline/sidebar/quick.styl +43 -43
  117. package/source/css/_common/outline/sidebar/related.styl +56 -56
  118. package/source/css/_common/outline/sidebar/sidebar.styl +80 -80
  119. package/source/css/_common/outline/sidebar/social.styl +69 -69
  120. package/source/css/_common/outline/sidebar/state.styl +37 -37
  121. package/source/css/_common/outline/sidebar/tab.styl +71 -71
  122. package/source/css/_common/outline/sidebar/toc.styl +47 -47
  123. package/source/css/_common/scaffolding/animate.styl +322 -322
  124. package/source/css/_common/scaffolding/base.styl +190 -190
  125. package/source/css/_common/scaffolding/buttons.styl +48 -48
  126. package/source/css/_common/scaffolding/divider.styl +36 -36
  127. package/source/css/_common/scaffolding/iconfont.styl +443 -443
  128. package/source/css/_common/scaffolding/normalize.styl +273 -273
  129. package/source/css/_common/scaffolding/pagination.styl +81 -81
  130. package/source/css/_common/scaffolding/ribbon.styl +38 -38
  131. package/source/css/_common/scaffolding/scaffolding.styl +14 -14
  132. package/source/css/_common/scaffolding/scrollbar.styl +37 -37
  133. package/source/css/_common/scaffolding/tables.styl +50 -50
  134. package/source/css/_common/scaffolding/tip.styl +19 -19
  135. package/source/css/_common/scaffolding/toggles.styl +59 -59
  136. package/source/css/_iconfont.styl +455 -455
  137. package/source/css/_mixins.styl +148 -148
  138. package/source/css/_variables.styl +89 -89
  139. package/source/css/app.styl +41 -41
  140. package/source/css/mermaid.styl +5 -5
  141. package/source/css/optimize.styl +5 -5
  142. package/source/js/_app/components/comments.js +59 -0
  143. package/source/js/_app/components/comments.ts +88 -89
  144. package/source/js/_app/components/sidebar.js +244 -0
  145. package/source/js/_app/components/sidebar.ts +239 -239
  146. package/source/js/_app/components/tcomments.js +47 -0
  147. package/source/js/_app/components/tcomments.ts +54 -54
  148. package/source/js/_app/globals/globalVars.ts +99 -99
  149. package/source/js/_app/globals/handles.js +105 -0
  150. package/source/js/_app/globals/handles.ts +124 -124
  151. package/source/js/_app/globals/themeColor.ts +63 -63
  152. package/source/js/_app/globals/thirdparty.ts +63 -63
  153. package/source/js/_app/globals/tools.ts +75 -75
  154. package/source/js/_app/library/anime.ts +110 -110
  155. package/source/js/_app/library/declare.d.ts +128 -130
  156. package/source/js/_app/library/dom.ts +28 -28
  157. package/source/js/_app/library/loadFile.js +43 -0
  158. package/source/js/_app/library/loadFile.ts +47 -50
  159. package/source/js/_app/library/proto.ts +137 -137
  160. package/source/js/_app/library/scriptPjax.ts +72 -72
  161. package/source/js/_app/library/storage.ts +12 -12
  162. package/source/js/_app/library/vue.js +52 -0
  163. package/source/js/_app/library/vue.ts +49 -49
  164. package/source/js/_app/page/common.js +45 -0
  165. package/source/js/_app/page/common.ts +43 -43
  166. package/source/js/_app/page/fancybox.js +70 -0
  167. package/source/js/_app/page/fancybox.ts +72 -72
  168. package/source/js/_app/page/post.js +253 -0
  169. package/source/js/_app/page/post.ts +266 -266
  170. package/source/js/_app/page/search.js +111 -0
  171. package/source/js/_app/page/search.ts +115 -115
  172. package/source/js/_app/page/tab.ts +60 -60
  173. package/source/js/_app/pjax/domInit.js +80 -0
  174. package/source/js/_app/pjax/domInit.ts +97 -97
  175. package/source/js/_app/pjax/refresh.js +137 -0
  176. package/source/js/_app/pjax/refresh.ts +140 -138
  177. package/source/js/_app/pjax/siteInit.js +115 -0
  178. package/source/js/_app/pjax/siteInit.ts +106 -104
  179. package/source/js/_app/player.js +777 -0
  180. package/source/js/_app/player.ts +798 -798
  181. package/toolbox/compiler.mjs +73 -0
  182. package/toolbox/hoistdep.mjs +6 -0
  183. package/toolbox/lib.mjs +43 -0
@@ -1,89 +1,88 @@
1
- import { CONFIG } from '../globals/globalVars'
2
- import { init, RecentComments } from '@waline/client'
3
- import { pageviewCount } from '@waline/client/pageview'
4
-
5
- import { $dom } from '../library/dom'
6
-
7
- export const walineComment = function () {
8
- init({
9
- el: '#comments',
10
- serverURL: CONFIG.waline.serverURL,
11
- lang: CONFIG.waline.lang,
12
- locale: CONFIG.waline.locale,
13
- emoji: CONFIG.waline.emoji,
14
- meta: CONFIG.waline.meta,
15
- requiredMeta: CONFIG.waline.requiredMeta,
16
- wordLimit: CONFIG.waline.wordLimit,
17
- pageSize: CONFIG.waline.pageSize,
18
- pageview: CONFIG.waline.pageview,
19
- path: window.location.pathname,
20
- dark: 'html[data-theme="dark"]'
21
- })
22
- }
23
-
24
- export const walinePageview = function () {
25
- // TODO waline 上游此模块存在问题
26
- pageviewCount({
27
- serverURL: CONFIG.waline.serverURL,
28
- path: window.location.pathname
29
- })
30
- }
31
-
32
- export const walineRecentComments = async function () {
33
- const root = shokax_siteURL.replace(/^(https?:\/\/)?[^/]*/, '')
34
- let items = []
35
- const { comments } = await RecentComments({
36
- serverURL: CONFIG.waline.serverURL.replace(/\/+$/, ''),
37
- count: 10
38
- })
39
- // TODO 疑似 waline API 返回格式与文档不一致,需要确认是否为上游问题
40
- // @ts-ignore
41
- comments.data.forEach(function (item) {
42
- let cText = (item.orig.length > 50) ? item.orig.substring(0, 50) + '...' : item.orig
43
- item.url = item.url.startsWith('/') ? item.url : '/' + item.url
44
- const siteLink = item.url + '#' + item.objectId
45
-
46
- const time = new Date(item.time)
47
- const now = new Date()
48
- const diff = now.valueOf() - time.valueOf()
49
- let dateStr:string
50
- if (diff < 3600000) {
51
- dateStr = `${Math.floor(diff / 60000)} 分钟前`
52
- } else if (diff < 86400000) {
53
- dateStr = `${Math.floor(diff / 3600000)} 小时前`
54
- } else if (diff < 2592000000) {
55
- dateStr = `${Math.floor(diff / 86400000)} 天前`
56
- } else {
57
- dateStr = `${time.getFullYear()}-${time.getMonth() + 1}-${time.getDate()}`
58
- }
59
-
60
- items.push({
61
- href: siteLink,
62
- nick: item.nick,
63
- time: dateStr,
64
- text: cText
65
- })
66
- })
67
- const newComments = new DocumentFragment()
68
- items.forEach(function (item) {
69
- const commentEl = document.createElement('li')
70
- const commentLink = document.createElement('a')
71
- const commentTime = document.createElement('span')
72
- const commentText = document.createElement('span')
73
-
74
- commentText.innerText = item.text
75
- commentTime.className = 'breadcrumb'
76
- commentTime.innerText = `${item.nick} @ ${item.time}`
77
- commentLink.href = root + item.href
78
- commentLink['data-pjax-state'] = 'data-pjax-state'
79
- commentEl.className = 'item'
80
-
81
- commentText.appendChild(document.createElement('br'))
82
- commentLink.appendChild(commentTime)
83
- commentLink.appendChild(commentText)
84
- commentEl.appendChild(commentLink)
85
- newComments.appendChild(commentEl)
86
- })
87
-
88
- document.getElementById("new-comment").appendChild(newComments)
89
- }
1
+ import { CONFIG } from '../globals/globalVars'
2
+ import { init, RecentComments } from '@waline/client'
3
+ import { pageviewCount } from '@waline/client/pageview'
4
+ await import('@waline/client/style')
5
+
6
+ export const walineComment = function () {
7
+ init({
8
+ el: '#comments',
9
+ serverURL: CONFIG.waline.serverURL,
10
+ lang: CONFIG.waline.lang,
11
+ locale: CONFIG.waline.locale,
12
+ emoji: CONFIG.waline.emoji,
13
+ meta: CONFIG.waline.meta,
14
+ requiredMeta: CONFIG.waline.requiredMeta,
15
+ wordLimit: CONFIG.waline.wordLimit,
16
+ pageSize: CONFIG.waline.pageSize,
17
+ pageview: CONFIG.waline.pageview,
18
+ path: window.location.pathname,
19
+ dark: 'html[data-theme="dark"]'
20
+ })
21
+ }
22
+
23
+ export const walinePageview = function () {
24
+ // TODO waline 上游此模块存在问题
25
+ pageviewCount({
26
+ serverURL: CONFIG.waline.serverURL,
27
+ path: window.location.pathname
28
+ })
29
+ }
30
+
31
+ export const walineRecentComments = async function () {
32
+ const root = shokax_siteURL.replace(/^(https?:\/\/)?[^/]*/, '')
33
+ let items = []
34
+ const { comments } = await RecentComments({
35
+ serverURL: CONFIG.waline.serverURL.replace(/\/+$/, ''),
36
+ count: 10
37
+ })
38
+ // TODO 疑似 waline API 返回格式与文档不一致,需要确认是否为上游问题
39
+ // @ts-ignore
40
+ comments.data.forEach(function (item) {
41
+ let cText = (item.orig.length > 50) ? item.orig.substring(0, 50) + '...' : item.orig
42
+ item.url = item.url.startsWith('/') ? item.url : '/' + item.url
43
+ const siteLink = item.url + '#' + item.objectId
44
+
45
+ const time = new Date(item.time)
46
+ const now = new Date()
47
+ const diff = now.valueOf() - time.valueOf()
48
+ let dateStr:string
49
+ if (diff < 3600000) {
50
+ dateStr = `${Math.floor(diff / 60000)} 分钟前`
51
+ } else if (diff < 86400000) {
52
+ dateStr = `${Math.floor(diff / 3600000)} 小时前`
53
+ } else if (diff < 2592000000) {
54
+ dateStr = `${Math.floor(diff / 86400000)} 天前`
55
+ } else {
56
+ dateStr = `${time.getFullYear()}-${time.getMonth() + 1}-${time.getDate()}`
57
+ }
58
+
59
+ items.push({
60
+ href: siteLink,
61
+ nick: item.nick,
62
+ time: dateStr,
63
+ text: cText
64
+ })
65
+ })
66
+ const newComments = new DocumentFragment()
67
+ items.forEach(function (item) {
68
+ const commentEl = document.createElement('li')
69
+ const commentLink = document.createElement('a')
70
+ const commentTime = document.createElement('span')
71
+ const commentText = document.createElement('span')
72
+
73
+ commentText.innerText = item.text
74
+ commentTime.className = 'breadcrumb'
75
+ commentTime.innerText = `${item.nick} @ ${item.time}`
76
+ commentLink.href = root + item.href
77
+ commentLink['data-pjax-state'] = 'data-pjax-state'
78
+ commentEl.className = 'item'
79
+
80
+ commentText.appendChild(document.createElement('br'))
81
+ commentLink.appendChild(commentTime)
82
+ commentLink.appendChild(commentText)
83
+ commentEl.appendChild(commentLink)
84
+ newComments.appendChild(commentEl)
85
+ })
86
+
87
+ document.getElementById("new-comment").appendChild(newComments)
88
+ }
@@ -0,0 +1,244 @@
1
+ "use strict";
2
+ /* 边栏分区 */
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || function (mod) {
20
+ if (mod && mod.__esModule) return mod;
21
+ var result = {};
22
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
23
+ __setModuleDefault(result, mod);
24
+ return result;
25
+ };
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.menuActive = exports.goToCommentHandle = exports.goToBottomHandle = exports.backToTopHandle = exports.sidebarTOC = exports.sideBarTab = exports.sideBarToggleHandle = void 0;
28
+ const globalVars_1 = require("../globals/globalVars");
29
+ const tools_1 = require("../globals/tools");
30
+ const anime_1 = require("../library/anime");
31
+ const dom_1 = require("../library/dom");
32
+ const proto_1 = __importStar(require("../library/proto"));
33
+ (0, proto_1.default)();
34
+ const sideBarToggleHandle = (event, force) => {
35
+ if (globalVars_1.sideBar.hasClass('on')) {
36
+ globalVars_1.sideBar.removeClass('on');
37
+ globalVars_1.menuToggle.removeClass('close');
38
+ if (force) {
39
+ // @ts-ignore
40
+ // noinspection JSConstantReassignment
41
+ globalVars_1.sideBar.style = '';
42
+ }
43
+ else {
44
+ (0, anime_1.transition)(globalVars_1.sideBar, 'slideRightOut');
45
+ }
46
+ }
47
+ else {
48
+ if (force) {
49
+ // @ts-ignore
50
+ // noinspection JSConstantReassignment
51
+ globalVars_1.sideBar.style = '';
52
+ }
53
+ else {
54
+ (0, anime_1.transition)(globalVars_1.sideBar, 'slideRightIn', () => {
55
+ globalVars_1.sideBar.addClass('on');
56
+ globalVars_1.menuToggle.addClass('close');
57
+ });
58
+ }
59
+ }
60
+ };
61
+ exports.sideBarToggleHandle = sideBarToggleHandle;
62
+ const sideBarTab = () => {
63
+ const sideBarInner = (0, proto_1.child)(globalVars_1.sideBar, '.inner');
64
+ if (globalVars_1.sideBar.child('.tab')) {
65
+ sideBarInner.removeChild(globalVars_1.sideBar.child('.tab'));
66
+ }
67
+ const list = document.createElement('ul');
68
+ let active = 'active';
69
+ list.className = 'tab';
70
+ ['contents', 'related', 'overview'].forEach((item) => {
71
+ const element = globalVars_1.sideBar.child('.panel.' + item);
72
+ if (element.innerHTML.trim().length < 1) {
73
+ if (item === 'contents') {
74
+ (0, proto_1.setDisplay)(globalVars_1.showContents, 'none');
75
+ }
76
+ return;
77
+ }
78
+ if (item === 'contents') {
79
+ (0, proto_1.setDisplay)(globalVars_1.showContents, '');
80
+ }
81
+ const tab = document.createElement('li');
82
+ const span = document.createElement('span');
83
+ const text = document.createTextNode(element.getAttribute('data-title'));
84
+ span.appendChild(text);
85
+ tab.appendChild(span);
86
+ tab.addClass(item + ' item');
87
+ if (active) {
88
+ element.addClass(active);
89
+ tab.addClass(active);
90
+ }
91
+ else {
92
+ element.removeClass('active');
93
+ }
94
+ tab.addEventListener('click', (event) => {
95
+ const target = event.currentTarget;
96
+ if (target.hasClass('active'))
97
+ return;
98
+ globalVars_1.sideBar.find('.tab .item').forEach((element) => {
99
+ element.removeClass('active');
100
+ });
101
+ globalVars_1.sideBar.find('.panel').forEach((element) => {
102
+ element.removeClass('active');
103
+ });
104
+ globalVars_1.sideBar.child('.panel.' + target.className.replace(' item', '')).addClass('active');
105
+ target.addClass('active');
106
+ });
107
+ list.appendChild(tab);
108
+ active = '';
109
+ });
110
+ if (list.childNodes.length > 1) {
111
+ sideBarInner.insertBefore(list, sideBarInner.childNodes[0]);
112
+ globalVars_1.sideBar.child('.panels').style.paddingTop = '';
113
+ }
114
+ else {
115
+ globalVars_1.sideBar.child('.panels').style.paddingTop = '.625rem';
116
+ }
117
+ };
118
+ exports.sideBarTab = sideBarTab;
119
+ const sidebarTOC = () => {
120
+ const activateNavByIndex = (index) => {
121
+ const target = navItems[index];
122
+ if (!target)
123
+ return;
124
+ if (target.hasClass('current')) {
125
+ return;
126
+ }
127
+ dom_1.$dom.each('.toc .active', (element) => {
128
+ element && element.removeClass('active current');
129
+ });
130
+ sections.forEach((element) => {
131
+ element && element.removeClass('active');
132
+ });
133
+ target.addClass('active current');
134
+ sections[index] && sections[index].addClass('active');
135
+ let parent = target.parentNode;
136
+ while (!parent.matches('.contents')) {
137
+ if (parent.matches('li')) {
138
+ parent.addClass('active');
139
+ const t = (0, dom_1.$dom)(parent.child('a.toc-link').getAttribute('href'));
140
+ if (t) {
141
+ t.addClass('active');
142
+ }
143
+ }
144
+ parent = parent.parentNode;
145
+ }
146
+ // Scrolling to center active TOC element if TOC content is taller than viewport.
147
+ if (getComputedStyle(globalVars_1.sideBar).display !== 'none' && tocElement.hasClass('active')) {
148
+ (0, anime_1.pageScroll)(tocElement, target.offsetTop - (tocElement.offsetHeight / 4));
149
+ }
150
+ };
151
+ const navItems = dom_1.$dom.all('.contents li');
152
+ if (navItems.length < 1) {
153
+ return;
154
+ }
155
+ let sections = [...navItems];
156
+ let activeLock = null;
157
+ sections = sections.map((element, index) => {
158
+ const link = element.child('a.toc-link');
159
+ const anchor = (0, dom_1.$dom)(decodeURI(link.getAttribute('href')));
160
+ if (!anchor)
161
+ return null;
162
+ const alink = anchor.child('a.anchor');
163
+ const anchorScroll = (event) => {
164
+ event.preventDefault();
165
+ const target = (0, dom_1.$dom)(decodeURI(event.currentTarget.getAttribute('href')));
166
+ activeLock = index;
167
+ (0, anime_1.pageScroll)(target, null, () => {
168
+ activateNavByIndex(index);
169
+ activeLock = null;
170
+ });
171
+ };
172
+ // TOC item animation navigate.
173
+ link.addEventListener('click', anchorScroll);
174
+ alink && alink.addEventListener('click', (event) => {
175
+ anchorScroll(event);
176
+ (0, tools_1.clipBoard)(globalVars_1.CONFIG.hostname + '/' + LOCAL.path + event.currentTarget.getAttribute('href'));
177
+ });
178
+ return anchor;
179
+ });
180
+ const tocElement = globalVars_1.sideBar.child('.contents.panel');
181
+ const findIndex = (entries) => {
182
+ let index = 0;
183
+ let entry = entries[index];
184
+ if (entry.boundingClientRect.top > 0) {
185
+ index = sections.indexOf(entry.target);
186
+ return index === 0 ? 0 : index - 1;
187
+ }
188
+ for (; index < entries.length; index++) {
189
+ if (entries[index].boundingClientRect.top <= 0) {
190
+ entry = entries[index];
191
+ }
192
+ else {
193
+ return sections.indexOf(entry.target);
194
+ }
195
+ }
196
+ return sections.indexOf(entry.target);
197
+ };
198
+ const createIntersectionObserver = () => {
199
+ const observer = new IntersectionObserver((entries) => {
200
+ const index = findIndex(entries) + (globalVars_1.diffY < 0 ? 1 : 0);
201
+ if (activeLock === null) {
202
+ activateNavByIndex(index);
203
+ }
204
+ }, {
205
+ rootMargin: '0px 0px -100% 0px', threshold: 0
206
+ });
207
+ sections.forEach((element) => {
208
+ element && observer.observe(element);
209
+ });
210
+ };
211
+ createIntersectionObserver();
212
+ };
213
+ exports.sidebarTOC = sidebarTOC;
214
+ const backToTopHandle = () => {
215
+ (0, anime_1.pageScroll)(0);
216
+ };
217
+ exports.backToTopHandle = backToTopHandle;
218
+ const goToBottomHandle = () => {
219
+ (0, anime_1.pageScroll)(parseInt(String((0, proto_1.getHeight)(globalVars_1.Container))));
220
+ };
221
+ exports.goToBottomHandle = goToBottomHandle;
222
+ const goToCommentHandle = () => {
223
+ (0, anime_1.pageScroll)((0, dom_1.$dom)('#comments'));
224
+ };
225
+ exports.goToCommentHandle = goToCommentHandle;
226
+ const menuActive = () => {
227
+ dom_1.$dom.each('.menu .item:not(.title)', (element) => {
228
+ const target = element.child('a[href]');
229
+ const parentItem = element.parentNode.parentNode;
230
+ if (!target)
231
+ return;
232
+ const isSamePath = target.pathname === location.pathname || target.pathname === location.pathname.replace('index.html', '');
233
+ const isSubPath = !globalVars_1.CONFIG.root.startsWith(target.pathname) && location.pathname.startsWith(target.pathname);
234
+ const active = target.hostname === location.hostname && (isSamePath || isSubPath);
235
+ element.toggleClass('active', active);
236
+ if (element.parentNode.child('.active') && parentItem.hasClass('dropdown')) {
237
+ parentItem.removeClass('active').addClass('expand');
238
+ }
239
+ else {
240
+ parentItem.removeClass('expand');
241
+ }
242
+ });
243
+ };
244
+ exports.menuActive = menuActive;