hexo-theme-redefine-x 2.8.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.
Files changed (319) hide show
  1. package/.github/ISSUE_TEMPLATE/bug-chinese.yml +115 -0
  2. package/.github/ISSUE_TEMPLATE/bug-english.yml +106 -0
  3. package/.github/ISSUE_TEMPLATE/enhancement-chinese.yml +55 -0
  4. package/.github/ISSUE_TEMPLATE/enhancement-english.yml +55 -0
  5. package/.github/workflows/build-and-commit.yml +49 -0
  6. package/.github/workflows/npm-publish.yml +34 -0
  7. package/.github/workflows/stale-issues.yml +20 -0
  8. package/CHANGELOG_REDEFINE_X.md +236 -0
  9. package/CODE_OF_CONDUCT.md +128 -0
  10. package/CONTRIBUTING.md +51 -0
  11. package/DONATION.md +82 -0
  12. package/LICENSE +674 -0
  13. package/README.md +135 -0
  14. package/README_zh-CN.md +138 -0
  15. package/README_zh-TW.md +137 -0
  16. package/TODO.md +215 -0
  17. package/_config.yml +489 -0
  18. package/languages/en.yml +93 -0
  19. package/languages/es.yml +92 -0
  20. package/languages/fr.yml +92 -0
  21. package/languages/ja.yml +92 -0
  22. package/languages/zh-CN.yml +95 -0
  23. package/languages/zh-TW.yml +94 -0
  24. package/layout/404.ejs +1 -0
  25. package/layout/archive.ejs +1 -0
  26. package/layout/category.ejs +1 -0
  27. package/layout/components/comments/comment.ejs +22 -0
  28. package/layout/components/comments/giscus.ejs +42 -0
  29. package/layout/components/comments/gitalk.ejs +47 -0
  30. package/layout/components/comments/twikoo.ejs +50 -0
  31. package/layout/components/comments/waline.ejs +34 -0
  32. package/layout/components/footer/footer.ejs +99 -0
  33. package/layout/components/header/head.ejs +222 -0
  34. package/layout/components/header/navbar.ejs +163 -0
  35. package/layout/components/header/preloader.ejs +148 -0
  36. package/layout/components/header/progress-bar.ejs +12 -0
  37. package/layout/components/plugins/aplayer.ejs +3 -0
  38. package/layout/components/scripts.ejs +90 -0
  39. package/layout/components/sidebar/author.ejs +6 -0
  40. package/layout/components/sidebar/avatar.ejs +3 -0
  41. package/layout/components/sidebar/statistics.ejs +14 -0
  42. package/layout/components/swup.ejs +27 -0
  43. package/layout/index.ejs +1 -0
  44. package/layout/layout.ejs +13 -0
  45. package/layout/page.ejs +57 -0
  46. package/layout/pages/archive/archive.ejs +3 -0
  47. package/layout/pages/bookmarks/bookmarks.ejs +68 -0
  48. package/layout/pages/category/categories.ejs +11 -0
  49. package/layout/pages/category/category-detail.ejs +6 -0
  50. package/layout/pages/friends/friends-link.ejs +59 -0
  51. package/layout/pages/home/home-article.ejs +52 -0
  52. package/layout/pages/home/home-background.ejs +33 -0
  53. package/layout/pages/home/home-banner.ejs +234 -0
  54. package/layout/pages/home/home-content.ejs +62 -0
  55. package/layout/pages/home/home-sidebar.ejs +78 -0
  56. package/layout/pages/masonry/masonry.ejs +28 -0
  57. package/layout/pages/notfound/notfound.ejs +8 -0
  58. package/layout/pages/page-template.ejs +23 -0
  59. package/layout/pages/post/article-content.ejs +153 -0
  60. package/layout/pages/post/article-copyright.ejs +69 -0
  61. package/layout/pages/post/article-info.ejs +78 -0
  62. package/layout/pages/post/post-tools.ejs +17 -0
  63. package/layout/pages/post/toc.ejs +15 -0
  64. package/layout/pages/shuoshuo/essays.ejs +23 -0
  65. package/layout/pages/tag/tag-detail.ejs +6 -0
  66. package/layout/pages/tag/tags.ejs +24 -0
  67. package/layout/post.ejs +1 -0
  68. package/layout/tag.ejs +1 -0
  69. package/layout/tags.ejs +1 -0
  70. package/layout/utils/image-viewer.ejs +3 -0
  71. package/layout/utils/local-search.ejs +20 -0
  72. package/layout/utils/paginator.ejs +8 -0
  73. package/layout/utils/posts-list.ejs +28 -0
  74. package/layout/utils/side-tools.ejs +51 -0
  75. package/package.json +45 -0
  76. package/scripts/config-export.js +66 -0
  77. package/scripts/data-handle.js +37 -0
  78. package/scripts/events/404.js +16 -0
  79. package/scripts/events/welcome.js +141 -0
  80. package/scripts/filters/delete-mask-handle.js +27 -0
  81. package/scripts/filters/encrypt.js +202 -0
  82. package/scripts/filters/img-handle.js +9 -0
  83. package/scripts/filters/lazyload-handle.js +350 -0
  84. package/scripts/filters/lib/hbe.default.js +15 -0
  85. package/scripts/filters/link-handle.js +42 -0
  86. package/scripts/filters/stylus-handle.js +9 -0
  87. package/scripts/filters/table-handle.js +11 -0
  88. package/scripts/helpers/meta-helpers.js +38 -0
  89. package/scripts/helpers/page-helpers.js +153 -0
  90. package/scripts/helpers/recommendation-helpers.js +367 -0
  91. package/scripts/helpers/theme-helpers.js +251 -0
  92. package/scripts/helpers/waline-helpers.js +33 -0
  93. package/scripts/modules/btn.js +85 -0
  94. package/scripts/modules/btns.js +71 -0
  95. package/scripts/modules/folding.js +34 -0
  96. package/scripts/modules/note-large.js +72 -0
  97. package/scripts/modules/note.js +64 -0
  98. package/scripts/modules/tabs.js +99 -0
  99. package/source/assets/hbe.style.css +220 -0
  100. package/source/assets/odometer-theme-minimal.css +81 -0
  101. package/source/css/build/tailwind.css +2 -0
  102. package/source/css/common/animated.styl +71 -0
  103. package/source/css/common/basic.styl +239 -0
  104. package/source/css/common/codeblock/code-block.styl +158 -0
  105. package/source/css/common/codeblock/code-theme.styl +82 -0
  106. package/source/css/common/codeblock/highlight.styl +189 -0
  107. package/source/css/common/codeblock/hljs-themes/dark/a11y-dark.styl +18 -0
  108. package/source/css/common/codeblock/hljs-themes/dark/agate.styl +18 -0
  109. package/source/css/common/codeblock/hljs-themes/dark/atom-one-dark.styl +18 -0
  110. package/source/css/common/codeblock/hljs-themes/dark/github-dark.styl +18 -0
  111. package/source/css/common/codeblock/hljs-themes/dark/monokai-sublime.styl +18 -0
  112. package/source/css/common/codeblock/hljs-themes/dark/night-owl.styl +18 -0
  113. package/source/css/common/codeblock/hljs-themes/dark/nord.styl +18 -0
  114. package/source/css/common/codeblock/hljs-themes/dark/tokyo-night-dark.styl +18 -0
  115. package/source/css/common/codeblock/hljs-themes/dark/vs2015.styl +18 -0
  116. package/source/css/common/codeblock/hljs-themes/light/atom-one-light.styl +18 -0
  117. package/source/css/common/codeblock/hljs-themes/light/default.styl +18 -0
  118. package/source/css/common/codeblock/hljs-themes/light/github.styl +18 -0
  119. package/source/css/common/colors.styl +112 -0
  120. package/source/css/common/markdown.styl +337 -0
  121. package/source/css/common/redefine-theme.styl +65 -0
  122. package/source/css/common/theme.styl +72 -0
  123. package/source/css/common/variables.styl +145 -0
  124. package/source/css/layout/_modules/aplayer.styl +799 -0
  125. package/source/css/layout/_modules/buttons.styl +42 -0
  126. package/source/css/layout/_modules/folding.styl +180 -0
  127. package/source/css/layout/_modules/notes.styl +181 -0
  128. package/source/css/layout/_modules/tabs.styl +105 -0
  129. package/source/css/layout/_partials/404.styl +14 -0
  130. package/source/css/layout/_partials/archive-list.styl +49 -0
  131. package/source/css/layout/_partials/article-copyright-info.styl +27 -0
  132. package/source/css/layout/_partials/article-meta-info.styl +62 -0
  133. package/source/css/layout/_partials/comments/comment.styl +11 -0
  134. package/source/css/layout/_partials/comments/gitalk.styl +529 -0
  135. package/source/css/layout/_partials/comments/twikoo.styl +62 -0
  136. package/source/css/layout/_partials/comments/waline.styl +1151 -0
  137. package/source/css/layout/_partials/footer.styl +59 -0
  138. package/source/css/layout/_partials/home-banner.styl +48 -0
  139. package/source/css/layout/_partials/image-viewer.styl +37 -0
  140. package/source/css/layout/_partials/local-search.styl +137 -0
  141. package/source/css/layout/_partials/navbar.styl +309 -0
  142. package/source/css/layout/_partials/page-template.styl +147 -0
  143. package/source/css/layout/_partials/paginator.styl +65 -0
  144. package/source/css/layout/_partials/post-tools.styl +43 -0
  145. package/source/css/layout/_partials/progress-bar.styl +33 -0
  146. package/source/css/layout/_partials/side-tools.styl +87 -0
  147. package/source/css/layout/_partials/tagcloud.styl +136 -0
  148. package/source/css/layout/_partials/toc.styl +105 -0
  149. package/source/css/layout/animations.styl +42 -0
  150. package/source/css/layout/archive-content.styl +8 -0
  151. package/source/css/layout/article-content.styl +257 -0
  152. package/source/css/layout/bookmarks.styl +8 -0
  153. package/source/css/layout/category-content.styl +21 -0
  154. package/source/css/layout/category-list.styl +119 -0
  155. package/source/css/layout/home-content.styl +114 -0
  156. package/source/css/layout/home-sidebar.styl +126 -0
  157. package/source/css/layout/page.styl +144 -0
  158. package/source/css/layout/tag-content.styl +30 -0
  159. package/source/css/style.styl +26 -0
  160. package/source/css/tailwind.source.css +236 -0
  161. package/source/fontawesome/all.min.css +6 -0
  162. package/source/fontawesome/brands.min.css +6 -0
  163. package/source/fontawesome/duotone.min.css +6 -0
  164. package/source/fontawesome/fontawesome.min.css +6 -0
  165. package/source/fontawesome/light.min.css +6 -0
  166. package/source/fontawesome/regular.min.css +6 -0
  167. package/source/fontawesome/sharp-solid.min.css +6 -0
  168. package/source/fontawesome/solid.min.css +6 -0
  169. package/source/fontawesome/svg-with-js.min.css +6 -0
  170. package/source/fontawesome/thin.min.css +6 -0
  171. package/source/fontawesome/v4-font-face.min.css +6 -0
  172. package/source/fontawesome/v4-shims.min.css +6 -0
  173. package/source/fontawesome/v5-font-face.min.css +6 -0
  174. package/source/fonts/Chillax/Chillax-Variable.eot +0 -0
  175. package/source/fonts/Chillax/Chillax-Variable.ttf +0 -0
  176. package/source/fonts/Chillax/Chillax-Variable.woff +0 -0
  177. package/source/fonts/Chillax/Chillax-Variable.woff2 +0 -0
  178. package/source/fonts/Chillax/chillax.css +39 -0
  179. package/source/fonts/Geist/GeistVF.ttf +0 -0
  180. package/source/fonts/Geist/GeistVF.woff +0 -0
  181. package/source/fonts/Geist/GeistVF.woff2 +0 -0
  182. package/source/fonts/Geist/geist.css +16 -0
  183. package/source/fonts/GeistMono/GeistMonoVF.ttf +0 -0
  184. package/source/fonts/GeistMono/GeistMonoVF.woff +0 -0
  185. package/source/fonts/GeistMono/GeistMonoVF.woff2 +0 -0
  186. package/source/fonts/GeistMono/geist-mono.css +16 -0
  187. package/source/images/bookmark-placeholder.svg +9 -0
  188. package/source/images/loading.svg +5 -0
  189. package/source/images/redefine-avatar.svg +1 -0
  190. package/source/images/redefine-favicon.svg +1 -0
  191. package/source/images/redefine-logo.svg +1 -0
  192. package/source/images/redefine-logo.webp +0 -0
  193. package/source/images/redefine-og.webp +0 -0
  194. package/source/images/wallhaven-wqery6-dark.webp +0 -0
  195. package/source/images/wallhaven-wqery6-light.webp +0 -0
  196. package/source/js/build/layouts/bookmarkNav.js +2 -0
  197. package/source/js/build/layouts/bookmarkNav.js.map +1 -0
  198. package/source/js/build/layouts/categoryList.js +2 -0
  199. package/source/js/build/layouts/categoryList.js.map +1 -0
  200. package/source/js/build/layouts/essays.js +2 -0
  201. package/source/js/build/layouts/essays.js.map +1 -0
  202. package/source/js/build/layouts/lazyload.js +2 -0
  203. package/source/js/build/layouts/lazyload.js.map +1 -0
  204. package/source/js/build/layouts/navbarShrink.js +2 -0
  205. package/source/js/build/layouts/navbarShrink.js.map +1 -0
  206. package/source/js/build/layouts/toc.js +2 -0
  207. package/source/js/build/layouts/toc.js.map +1 -0
  208. package/source/js/build/libs/APlayer.min.js +2 -0
  209. package/source/js/build/libs/Swup.min.js +2 -0
  210. package/source/js/build/libs/SwupPreloadPlugin.min.js +1 -0
  211. package/source/js/build/libs/SwupProgressPlugin.min.js +1 -0
  212. package/source/js/build/libs/SwupScriptsPlugin.min.js +1 -0
  213. package/source/js/build/libs/SwupScrollPlugin.min.js +1 -0
  214. package/source/js/build/libs/SwupSlideTheme.min.js +1 -0
  215. package/source/js/build/libs/Typed.min.js +10 -0
  216. package/source/js/build/libs/anime.min.js +8 -0
  217. package/source/js/build/libs/mermaid.min.js +2314 -0
  218. package/source/js/build/libs/minimasonry.min.js +1 -0
  219. package/source/js/build/libs/moment-with-locales.min.js +2 -0
  220. package/source/js/build/libs/moment.min.js +2 -0
  221. package/source/js/build/libs/odometer.min.js +2 -0
  222. package/source/js/build/libs/pangu.min.js +9 -0
  223. package/source/js/build/libs/pjax.min.js +1 -0
  224. package/source/js/build/libs/waline.js +84 -0
  225. package/source/js/build/main.js +2 -0
  226. package/source/js/build/main.js.map +1 -0
  227. package/source/js/build/plugins/aplayer.js +2 -0
  228. package/source/js/build/plugins/aplayer.js.map +1 -0
  229. package/source/js/build/plugins/hbe.js +2 -0
  230. package/source/js/build/plugins/hbe.js.map +1 -0
  231. package/source/js/build/plugins/masonry.js +2 -0
  232. package/source/js/build/plugins/masonry.js.map +1 -0
  233. package/source/js/build/plugins/mermaid.js +2 -0
  234. package/source/js/build/plugins/mermaid.js.map +1 -0
  235. package/source/js/build/plugins/pangu.js +2 -0
  236. package/source/js/build/plugins/pangu.js.map +1 -0
  237. package/source/js/build/plugins/tabs.js +2 -0
  238. package/source/js/build/plugins/tabs.js.map +1 -0
  239. package/source/js/build/plugins/typed.js +2 -0
  240. package/source/js/build/plugins/typed.js.map +1 -0
  241. package/source/js/build/tools/codeBlock.js +2 -0
  242. package/source/js/build/tools/codeBlock.js.map +1 -0
  243. package/source/js/build/tools/imageViewer.js +2 -0
  244. package/source/js/build/tools/imageViewer.js.map +1 -0
  245. package/source/js/build/tools/lightDarkSwitch.js +2 -0
  246. package/source/js/build/tools/lightDarkSwitch.js.map +1 -0
  247. package/source/js/build/tools/localSearch.js +2 -0
  248. package/source/js/build/tools/localSearch.js.map +1 -0
  249. package/source/js/build/tools/runtime.js +2 -0
  250. package/source/js/build/tools/runtime.js.map +1 -0
  251. package/source/js/build/tools/scrollTopBottom.js +2 -0
  252. package/source/js/build/tools/scrollTopBottom.js.map +1 -0
  253. package/source/js/build/tools/tocToggle.js +2 -0
  254. package/source/js/build/tools/tocToggle.js.map +1 -0
  255. package/source/js/build/utils.js +2 -0
  256. package/source/js/build/utils.js.map +1 -0
  257. package/source/js/build.js +148 -0
  258. package/source/js/layouts/bookmarkNav.js +65 -0
  259. package/source/js/layouts/categoryList.js +53 -0
  260. package/source/js/layouts/essays.js +25 -0
  261. package/source/js/layouts/lazyload.js +199 -0
  262. package/source/js/layouts/navbarShrink.js +135 -0
  263. package/source/js/layouts/toc.js +115 -0
  264. package/source/js/libs/APlayer.min.js +2 -0
  265. package/source/js/libs/APlayer.min.js.map +1 -0
  266. package/source/js/libs/Swup.min.js +2 -0
  267. package/source/js/libs/Swup.min.js.map +1 -0
  268. package/source/js/libs/SwupPreloadPlugin.min.js +1 -0
  269. package/source/js/libs/SwupPreloadPlugin.min.js.map +1 -0
  270. package/source/js/libs/SwupProgressPlugin.min.js +1 -0
  271. package/source/js/libs/SwupScriptsPlugin.min.js +1 -0
  272. package/source/js/libs/SwupScrollPlugin.min.js +1 -0
  273. package/source/js/libs/SwupScrollPlugin.min.js.map +1 -0
  274. package/source/js/libs/SwupSlideTheme.min.js +1 -0
  275. package/source/js/libs/Typed.min.js +10 -0
  276. package/source/js/libs/anime.min.js +8 -0
  277. package/source/js/libs/mermaid.min.js +2314 -0
  278. package/source/js/libs/mermaid.min.js.map +7 -0
  279. package/source/js/libs/minimasonry.min.js +1 -0
  280. package/source/js/libs/moment-with-locales.min.js +2 -0
  281. package/source/js/libs/moment.min.js +2 -0
  282. package/source/js/libs/odometer.min.js +2 -0
  283. package/source/js/libs/pangu.min.js +9 -0
  284. package/source/js/libs/pjax.min.js +1 -0
  285. package/source/js/libs/waline.js +84 -0
  286. package/source/js/libs/waline.js.map +1 -0
  287. package/source/js/main.js +95 -0
  288. package/source/js/plugins/aplayer.js +33 -0
  289. package/source/js/plugins/hbe.js +350 -0
  290. package/source/js/plugins/masonry.js +115 -0
  291. package/source/js/plugins/mermaid.js +7 -0
  292. package/source/js/plugins/pangu.js +12 -0
  293. package/source/js/plugins/tabs.js +29 -0
  294. package/source/js/plugins/typed.js +62 -0
  295. package/source/js/tools/codeBlock.js +48 -0
  296. package/source/js/tools/imageViewer.js +194 -0
  297. package/source/js/tools/lightDarkSwitch.js +165 -0
  298. package/source/js/tools/localSearch.js +327 -0
  299. package/source/js/tools/runtime.js +28 -0
  300. package/source/js/tools/scrollTopBottom.js +34 -0
  301. package/source/js/tools/tocToggle.js +58 -0
  302. package/source/js/utils.js +383 -0
  303. package/source/webfonts/fa-brands-400.ttf +0 -0
  304. package/source/webfonts/fa-brands-400.woff2 +0 -0
  305. package/source/webfonts/fa-duotone-900.ttf +0 -0
  306. package/source/webfonts/fa-duotone-900.woff2 +0 -0
  307. package/source/webfonts/fa-light-300.ttf +0 -0
  308. package/source/webfonts/fa-light-300.woff2 +0 -0
  309. package/source/webfonts/fa-regular-400.ttf +0 -0
  310. package/source/webfonts/fa-regular-400.woff2 +0 -0
  311. package/source/webfonts/fa-sharp-solid-900.ttf +0 -0
  312. package/source/webfonts/fa-sharp-solid-900.woff2 +0 -0
  313. package/source/webfonts/fa-solid-900.ttf +0 -0
  314. package/source/webfonts/fa-solid-900.woff2 +0 -0
  315. package/source/webfonts/fa-thin-100.ttf +0 -0
  316. package/source/webfonts/fa-thin-100.woff2 +0 -0
  317. package/source/webfonts/fa-v4compatibility.ttf +0 -0
  318. package/source/webfonts/fa-v4compatibility.woff2 +0 -0
  319. package/vercel.json +7 -0
@@ -0,0 +1,367 @@
1
+ /*
2
+ * Optimized by: EvanNotFound
3
+ */
4
+
5
+ const articleLibrary = [];
6
+ const corpus = [];
7
+ let flag = null;
8
+
9
+ hexo.extend.filter.register("template_locals", function (localVariables) {
10
+ const cfg = hexo.theme.config.articles.recommendation;
11
+ if (!cfg.enable) {
12
+ return localVariables;
13
+ }
14
+ if (!flag) {
15
+ flag = 1;
16
+ fetchData(localVariables.site.posts, cfg);
17
+ fetchData(localVariables.site.pages, cfg);
18
+ articleRecommendation(cfg);
19
+ }
20
+ return localVariables;
21
+ });
22
+
23
+ function fetchData(s, cfg) {
24
+ s.each(function (p) {
25
+ if (["post", "docs"].includes(p.layout)) {
26
+ articleLibrary.push({
27
+ path: p.path,
28
+ title: p.title || p.seo_title || p.short_title,
29
+ headimg: p.thumbnail || p.banner || p.cover || cfg.placeholder,
30
+ });
31
+ corpus.push(tokenize(p.raw));
32
+ }
33
+ });
34
+ }
35
+
36
+ function cleanData(data) {
37
+ const symbolLists = [
38
+ ",",
39
+ ".",
40
+ "?",
41
+ "!",
42
+ ":",
43
+ ";",
44
+ "、",
45
+ "……",
46
+ "~",
47
+ "&",
48
+ "@",
49
+ "#",
50
+ ",",
51
+ "。",
52
+ "?",
53
+ "!",
54
+ ":",
55
+ ";",
56
+ "·",
57
+ "…",
58
+ "~",
59
+ "&",
60
+ "@",
61
+ "#",
62
+ "“",
63
+ "”",
64
+ "‘",
65
+ "’",
66
+ "〝",
67
+ "〞",
68
+ '"',
69
+ "'",
70
+ """,
71
+ "'",
72
+ "´",
73
+ "'",
74
+ "(",
75
+ ")",
76
+ "【",
77
+ "】",
78
+ "《",
79
+ "》",
80
+ "<",
81
+ ">",
82
+ "﹝",
83
+ "﹞",
84
+ "<",
85
+ ">",
86
+ "(",
87
+ ")",
88
+ "[",
89
+ "]",
90
+ "«",
91
+ "»",
92
+ "‹",
93
+ "›",
94
+ "〔",
95
+ "〕",
96
+ "〈",
97
+ "〉",
98
+ "{",
99
+ "}",
100
+ "[",
101
+ "]",
102
+ "「",
103
+ "」",
104
+ "{",
105
+ "}",
106
+ "〖",
107
+ "〗",
108
+ "『",
109
+ "』",
110
+ "︵",
111
+ "︷",
112
+ "︹",
113
+ "︿",
114
+ "︽",
115
+ "﹁",
116
+ "﹃",
117
+ "︻",
118
+ "︗",
119
+ "/",
120
+ "|",
121
+ "\\",
122
+ "︶",
123
+ "︸",
124
+ "︺",
125
+ "﹀",
126
+ "︾",
127
+ "﹂",
128
+ "﹄",
129
+ "﹄",
130
+ "︼",
131
+ "︘",
132
+ "/",
133
+ "|",
134
+ "\",
135
+ "_",
136
+ "¯",
137
+ "_",
138
+ " ̄",
139
+ "﹏",
140
+ "﹋",
141
+ "﹍",
142
+ "﹉",
143
+ "﹎",
144
+ "﹊",
145
+ "`",
146
+ "ˋ",
147
+ "¦",
148
+ "︴",
149
+ "¡",
150
+ "¿",
151
+ "^",
152
+ "ˇ",
153
+ "­",
154
+ "¨",
155
+ "ˊ",
156
+ " ",
157
+ " ",
158
+ "%",
159
+ "*",
160
+ "-",
161
+ "+",
162
+ "=",
163
+ "¥",
164
+ "$",
165
+ "(",
166
+ ")",
167
+ ];
168
+ data = data.replace(/\s/g, " ");
169
+ data = data.replace(/\!\[(.*?)\]\(.*?\)/g, (_a, b) => {
170
+ return b;
171
+ });
172
+ data = data.replace(
173
+ /(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&amp;:/~\+#]*[\w\-\@?^=%&amp;/~\+#])?/g,
174
+ " ",
175
+ );
176
+ for (const symbol of symbolLists) {
177
+ data = data.replace(new RegExp("\\" + symbol, "g"), " ");
178
+ }
179
+ data = data.replace(/\d+/g, " ");
180
+ data = data.replace(/\s/g, " ");
181
+ return data;
182
+ }
183
+
184
+ const Jieba = require("@node-rs/jieba").Jieba;
185
+ const jiebaInstance = new Jieba();
186
+ function tokenize(data) {
187
+ const cleaned = cleanData(data);
188
+ const words = jiebaInstance.cut(cleaned, true);
189
+ return words.filter((word) => word && word !== " " && !/^[0-9]*$/.test(word));
190
+ }
191
+
192
+ function cosineSimilarity(vector1, vector2) {
193
+ let numerator = 0;
194
+ let sqrt1 = 0;
195
+ let sqrt2 = 0;
196
+ if (vector1.length == vector2.length) {
197
+ for (let i = 0; i < vector1.length; i++) {
198
+ numerator += vector1[i] * vector2[i];
199
+ sqrt1 += vector1[i] * vector1[i];
200
+ sqrt2 += vector2[i] * vector2[i];
201
+ }
202
+ return numerator / (Math.sqrt(sqrt1) * Math.sqrt(sqrt2));
203
+ }
204
+ }
205
+
206
+ function createWordLibrary(allWords) {
207
+ const wordLibrary = {};
208
+ allWords.forEach((word) => {
209
+ wordLibrary[word] = 0;
210
+ });
211
+ return wordLibrary;
212
+ }
213
+
214
+ function calculateWordFrequency(wordLibrary, wordsInArticle) {
215
+ const wordOccurrenceLibrary = wordsInArticle.reduce(
216
+ (wordCountObj, wordName) => {
217
+ if (wordName in wordCountObj) {
218
+ wordCountObj[wordName]++;
219
+ }
220
+ return wordCountObj;
221
+ },
222
+ JSON.parse(JSON.stringify(wordLibrary)),
223
+ );
224
+
225
+ const wordFrequency = JSON.parse(JSON.stringify(wordLibrary));
226
+ for (const word of Object.keys(wordLibrary)) {
227
+ wordFrequency[word] = wordOccurrenceLibrary[word] / wordsInArticle.length;
228
+ }
229
+ return wordFrequency;
230
+ }
231
+
232
+ function articleRecommendation(cfg) {
233
+ const dataSet = {};
234
+ const similaritySet = {};
235
+ const recommendationSet = {};
236
+ let allWordsInAllArticles = [];
237
+
238
+ for (const wordList of corpus) {
239
+ allWordsInAllArticles = [
240
+ ...new Set(allWordsInAllArticles.concat(wordList)),
241
+ ];
242
+ }
243
+
244
+ const wordLibrary = createWordLibrary(allWordsInAllArticles);
245
+ const documentCountLibrary = JSON.parse(JSON.stringify(wordLibrary));
246
+
247
+ for (let i = 0; i < corpus.length; i++) {
248
+ const articlePath = articleLibrary[i].path;
249
+ const wordsInArticle = corpus[i];
250
+
251
+ const wordFrequency = calculateWordFrequency(wordLibrary, wordsInArticle);
252
+ dataSet[articlePath] = { wordFrequency };
253
+
254
+ for (const word of Object.keys(wordLibrary)) {
255
+ if (wordFrequency[word]) {
256
+ documentCountLibrary[word]++;
257
+ }
258
+ }
259
+ }
260
+
261
+ for (let i = 0; i < corpus.length; i++) {
262
+ const articlePath = articleLibrary[i].path;
263
+ dataSet[articlePath]["inverseDocumentFrequency"] = JSON.parse(
264
+ JSON.stringify(wordLibrary),
265
+ );
266
+ dataSet[articlePath]["wordFrequency-inverseDocumentFrequency"] = JSON.parse(
267
+ JSON.stringify(wordLibrary),
268
+ );
269
+ dataSet[articlePath]["wordFrequencyVector"] = [];
270
+ for (const word of Object.keys(wordLibrary)) {
271
+ const inverseDocumentFrequency = Math.log(
272
+ corpus.length / (documentCountLibrary[word] + 1),
273
+ );
274
+ const wordFrequencyInverseDocumentFrequency =
275
+ dataSet[articlePath]["wordFrequency"][word] * inverseDocumentFrequency;
276
+ dataSet[articlePath]["wordFrequencyVector"].push(
277
+ wordFrequencyInverseDocumentFrequency,
278
+ );
279
+ }
280
+ }
281
+
282
+ for (let i = 0; i < corpus.length; i++) {
283
+ const articlePath1 = articleLibrary[i].path;
284
+ similaritySet[articlePath1] = {};
285
+ for (let j = 0; j < corpus.length; j++) {
286
+ const articlePath2 = articleLibrary[j].path;
287
+ similaritySet[articlePath1][articlePath2] = cosineSimilarity(
288
+ dataSet[articlePath1]["wordFrequencyVector"],
289
+ dataSet[articlePath2]["wordFrequencyVector"],
290
+ );
291
+ }
292
+ for (let j = 0; j < corpus.length; j++) {
293
+ recommendationSet[articlePath1] = Object.keys(
294
+ similaritySet[articlePath1],
295
+ ).sort(function (a, b) {
296
+ return similaritySet[articlePath1][b] - similaritySet[articlePath1][a]; // Descending order
297
+ });
298
+ }
299
+ const index = recommendationSet[articlePath1].indexOf(articlePath1);
300
+ if (index > -1) {
301
+ recommendationSet[articlePath1].splice(index, 1);
302
+ }
303
+ recommendationSet[articlePath1] = recommendationSet[articlePath1].slice(
304
+ 0,
305
+ cfg.limit,
306
+ );
307
+ for (let j = 0; j < recommendationSet[articlePath1].length; j++) {
308
+ const e = recommendationSet[articlePath1][j];
309
+ recommendationSet[articlePath1][j] = articleLibrary.filter(
310
+ (w) => w.path == e,
311
+ )[0];
312
+ }
313
+ }
314
+ hexo.locals.set("recommendationSet", function () {
315
+ return recommendationSet;
316
+ });
317
+ }
318
+
319
+ hexo.extend.helper.register("articleRecommendationGenerator", function (post) {
320
+ if (!post) return "";
321
+ const cfg = hexo.theme.config.articles.recommendation;
322
+ if (!cfg.enable) {
323
+ return "";
324
+ }
325
+ for (const dir of cfg.skip_dirs) {
326
+ if (new RegExp("^" + dir, "g").test(post.path)) {
327
+ return "";
328
+ }
329
+ }
330
+ const recommendationSet = hexo.locals.get("recommendationSet");
331
+ const recommendedArticles = recommendationSet[post.path];
332
+ return userInterface(recommendedArticles, cfg);
333
+ });
334
+
335
+ function userInterface(recommendedArticles, cfg) {
336
+ let html = "";
337
+ let htmlMobile = "";
338
+ for (const item of recommendedArticles) {
339
+ html += itemInterface(item);
340
+ }
341
+ for (const itemMobile of recommendedArticles.slice(0, cfg.mobile_limit)) {
342
+ htmlMobile += itemInterface(itemMobile);
343
+ }
344
+ return `
345
+ <div class="recommended-article px-2 sm:px-6 md:px-8">
346
+ <div class="recommended-desktop">
347
+ <div class="recommended-article-header text-xl md:text-3xl font-bold mt-10">
348
+ <i aria-hidden="true"></i><span>${cfg.title}</span>
349
+ </div>
350
+ <div class="recommended-article-group">${html}</div>
351
+ </div>
352
+ <div class="recommended-mobile">
353
+ <div class="recommended-article-header text-xl md:text-3xl font-bold mt-10">
354
+ <i aria-hidden="true"></i><span>${cfg.title}</span>
355
+ </div>
356
+ <div class="recommended-article-group">${htmlMobile}</div>
357
+ </div>
358
+ </div>`;
359
+ }
360
+
361
+ function itemInterface(item) {
362
+ const url = hexo.extend.helper.get('url_for').call(hexo, item.path);
363
+ return `<a class="recommended-article-item" href="${url}" title="${item.title}" rel="bookmark">
364
+ <img src="/${item.headimg}" alt="${item.title}" class="!max-w-none">
365
+ <span class="title">${item.title}</span>
366
+ </a>`;
367
+ }
@@ -0,0 +1,251 @@
1
+ /* main hexo */
2
+
3
+ "use strict";
4
+
5
+ const url = require("url");
6
+ const { version } = require("../../package.json");
7
+ const themeVersion = version;
8
+
9
+ hexo.extend.helper.register("isHomePagePagination", function (pagePath, route) {
10
+ if (pagePath.length > 5 && route === "/") {
11
+ return pagePath.slice(0, 5) === "page/";
12
+ }
13
+
14
+ return false;
15
+ });
16
+
17
+ /* code block language display */
18
+ hexo.extend.filter.register("after_post_render", function (data) {
19
+ // Only process if not already processed
20
+ if (data._processedHighlight) return data;
21
+
22
+ // Updated pattern to include numbers and other special characters
23
+ const pattern = /<figure class="highlight ([^"]+)">([\s\S]*?)<\/figure>/g;
24
+ data.content = data.content.replace(pattern, function (match, p1, p2) {
25
+ // If already has code-container anywhere in the match, return unchanged
26
+ if (match.includes('code-container')) {
27
+ return match;
28
+ }
29
+
30
+ let language = p1 || "code";
31
+ if (language === "plain") {
32
+ language = "code";
33
+ }
34
+
35
+ return '<div class="code-container" data-rel="' +
36
+ language.charAt(0).toUpperCase() +
37
+ language.slice(1) +
38
+ '">' +
39
+ match.replace(
40
+ '<figure class="highlight ',
41
+ '<figure class="iseeu highlight '
42
+ ) +
43
+ "</div>";
44
+ });
45
+
46
+ // Mark as processed
47
+ data._processedHighlight = true;
48
+ return data;
49
+ });
50
+
51
+ hexo.extend.helper.register("createNewArchivePosts", function (posts) {
52
+ const postList = [],
53
+ postYearList = [];
54
+ posts.forEach((post) => postYearList.push(post.date.year()));
55
+ Array.from(new Set(postYearList)).forEach((year) => {
56
+ postList.push({
57
+ year: year,
58
+ postList: [],
59
+ });
60
+ });
61
+ postList.sort((a, b) => b.year - a.year);
62
+ postList.forEach((item) => {
63
+ posts.forEach(
64
+ (post) => item.year === post.date.year() && item.postList.push(post),
65
+ );
66
+ });
67
+ postList.forEach((item) =>
68
+ item.postList.sort((a, b) => b.date.unix() - a.date.unix()),
69
+ );
70
+ return postList;
71
+ });
72
+
73
+ hexo.extend.helper.register(
74
+ "getAuthorLabel",
75
+ function (postCount, isAuto, labelList) {
76
+ let level = Math.floor(Math.log2(postCount));
77
+ level = level < 2 ? 1 : level - 1;
78
+
79
+ if (isAuto === false && Array.isArray(labelList) && labelList.length > 0) {
80
+ return level > labelList.length
81
+ ? labelList[labelList.length - 1]
82
+ : labelList[level - 1];
83
+ } else {
84
+ return `Lv${level}`;
85
+ }
86
+ },
87
+ );
88
+
89
+ hexo.extend.helper.register("getPostUrl", function (rootUrl, path) {
90
+ if (rootUrl) {
91
+ let { href } = new URL(rootUrl);
92
+ if (href.substring(href.length - 1) !== "/") {
93
+ href = href + "/";
94
+ }
95
+ return href + path;
96
+ } else {
97
+ return path;
98
+ }
99
+ });
100
+
101
+ hexo.extend.helper.register("renderJS", function (path, options = {}) {
102
+ const _js = hexo.extend.helper.get("js").bind(hexo);
103
+ const { module = false, async = false, swupReload = false } = options;
104
+
105
+ if (Array.isArray(path)) {
106
+ path = path.map((p) => "js/build/" + p);
107
+ } else {
108
+ path = "js/build/" + path;
109
+ }
110
+
111
+ const cdnProviders = {
112
+ zstatic:
113
+ "https://s4.zstatic.net/ajax/libs/hexo-theme-redefine/:version/:path",
114
+ cdnjs:
115
+ "https://cdnjs.cloudflare.com/ajax/libs/hexo-theme-redefine/:version/:path",
116
+ unpkg: "https://unpkg.com/hexo-theme-redefine@:version/source/:path",
117
+ jsdelivr:
118
+ "https://cdn.jsdelivr.net/npm/hexo-theme-redefine@:version/source/:path",
119
+ aliyun:
120
+ "https://evan.beee.top/projects/hexo-theme-redefine@:version/source/:path",
121
+ npmmirror:
122
+ "https://registry.npmmirror.com/hexo-theme-redefine/:version/files/source/:path",
123
+ custom: this.theme.cdn.custom_url,
124
+ };
125
+
126
+ const cdnPathHandle = (path) => {
127
+ const cdnBase =
128
+ cdnProviders[this.theme.cdn.provider] || cdnProviders.npmmirror;
129
+ let scriptTag;
130
+
131
+ const typeAttr = module ? 'type="module"' : "";
132
+ // const asyncAttr = async ? "async" : "";
133
+ const swupAttr = swupReload ? "data-swup-reload-script" : "";
134
+
135
+ if (this.theme.cdn.enable) {
136
+ if (this.theme.cdn.provider === "custom") {
137
+ const customUrl = cdnBase
138
+ .replace(":version", themeVersion)
139
+ .replace(":path", path);
140
+ scriptTag = `<script ${typeAttr} src="${
141
+ this.theme.cdn.enable ? customUrl : _js({ src: path })
142
+ }" ${swupAttr}></script>`;
143
+ } else {
144
+ scriptTag = `<script ${typeAttr} src="${cdnBase
145
+ .replace(":version", themeVersion)
146
+ .replace(":path", path)}" ${swupAttr}></script>`;
147
+ }
148
+ } else {
149
+ scriptTag = _js({
150
+ src: path,
151
+ type: module ? "module" : undefined,
152
+ "data-swup-reload-script": swupReload ? "" : undefined,
153
+ // async: async,
154
+ });
155
+ }
156
+
157
+ return scriptTag;
158
+ };
159
+
160
+ let renderedScripts = "";
161
+
162
+ if (Array.isArray(path)) {
163
+ renderedScripts = path.map(cdnPathHandle).join("");
164
+ } else {
165
+ renderedScripts = cdnPathHandle(path);
166
+ }
167
+
168
+ return renderedScripts;
169
+ });
170
+
171
+ hexo.extend.helper.register("renderCSS", function (path) {
172
+ const _css = hexo.extend.helper.get("css").bind(hexo);
173
+
174
+ const cdnProviders = {
175
+ zstatic:
176
+ "https://s4.zstatic.net/ajax/libs/hexo-theme-redefine/:version/:path",
177
+ cdnjs:
178
+ "https://cdnjs.cloudflare.com/ajax/libs/hexo-theme-redefine/:version/:path",
179
+ unpkg: "https://unpkg.com/hexo-theme-redefine@:version/source/:path",
180
+ jsdelivr:
181
+ "https://cdn.jsdelivr.net/npm/hexo-theme-redefine@:version/source/:path",
182
+ aliyun:
183
+ "https://evan.beee.top/projects/hexo-theme-redefine@:version/source/:path",
184
+ npmmirror:
185
+ "https://registry.npmmirror.com/hexo-theme-redefine/:version/files/source/:path",
186
+ custom: this.theme.cdn.custom_url,
187
+ };
188
+
189
+ const cdnPathHandle = (path) => {
190
+ const cdnBase =
191
+ cdnProviders[this.theme.cdn.provider] || cdnProviders.npmmirror;
192
+ let cssLink;
193
+
194
+ if (this.theme.cdn.enable) {
195
+ if (this.theme.cdn.provider === "custom") {
196
+ const customUrl = cdnBase
197
+ .replace(":version", themeVersion)
198
+ .replace(":path", path);
199
+ cssLink = `<link rel="stylesheet" href="${customUrl}">`;
200
+ } else {
201
+ cssLink = `<link rel="stylesheet" href="${cdnBase
202
+ .replace(":version", themeVersion)
203
+ .replace(":path", path)}">`;
204
+ }
205
+ } else {
206
+ cssLink = _css(path);
207
+ }
208
+
209
+ return cssLink;
210
+ };
211
+
212
+ if (Array.isArray(path)) {
213
+ return path.map(cdnPathHandle).join("");
214
+ } else {
215
+ return cdnPathHandle(path);
216
+ }
217
+ });
218
+
219
+ hexo.extend.helper.register("getThemeVersion", function () {
220
+ return themeVersion;
221
+ });
222
+
223
+ hexo.extend.helper.register("checkDeprecation", function (condition, id, message) {
224
+ if (condition) {
225
+ // Use Set to ensure each warning is only logged once per Hexo process
226
+ if (!global.deprecationWarnings) {
227
+ global.deprecationWarnings = new Set();
228
+ }
229
+
230
+ if (!global.deprecationWarnings.has(id)) {
231
+ hexo.log.warn(`${message}`);
232
+ global.deprecationWarnings.add(id);
233
+ }
234
+ return true;
235
+ }
236
+ return false;
237
+ });
238
+
239
+ hexo.extend.helper.register("configOptions", function (obj, indent = ' ') {
240
+ if (!obj || typeof obj !== 'object') return '';
241
+
242
+ return Object.entries(obj)
243
+ .filter(([key, value]) => value !== undefined && value !== null && value !== '')
244
+ .map(([key, value]) => {
245
+ if (typeof value === 'string') {
246
+ return `${indent}${key}: '${value}',`;
247
+ }
248
+ return `${indent}${key}: ${value},`;
249
+ })
250
+ .join('\n');
251
+ });
@@ -0,0 +1,33 @@
1
+ hexo.extend.helper.register('waline_reaction_config', function(reactionConfig) {
2
+ if (Array.isArray(reactionConfig) && reactionConfig.length) {
3
+ return `[${reactionConfig.map(item => `'${item}'`).join(', ')}]`;
4
+ } else {
5
+ return Boolean(reactionConfig);
6
+ }
7
+ });
8
+
9
+ hexo.extend.helper.register('waline_array_config', function(arrayConfig) {
10
+ if (Array.isArray(arrayConfig) && arrayConfig.length) {
11
+ return `[${arrayConfig.map(item => `'${item}'`).join(', ')}]`;
12
+ }
13
+ return '[]';
14
+ });
15
+
16
+ hexo.extend.helper.register('waline_config_options', function(config) {
17
+ if (!config || typeof config !== 'object') return '';
18
+
19
+ const formatValue = (value) => {
20
+ if (typeof value === 'string') {
21
+ return `'${value}'`;
22
+ }
23
+ if (Array.isArray(value)) {
24
+ return `[${value.map(item => typeof item === 'string' ? `'${item}'` : item).join(', ')}]`;
25
+ }
26
+ return value;
27
+ };
28
+
29
+ return Object.entries(config)
30
+ .filter(([key, value]) => value !== undefined && value !== null && value !== '')
31
+ .map(([key, value]) => ` ${key}: ${formatValue(value)},`)
32
+ .join('\n');
33
+ });