hexo-theme-gnix 10.0.0 → 11.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.
package/README.md CHANGED
@@ -25,10 +25,6 @@ Support multiple light and dark themes:
25
25
 
26
26
  ## Components
27
27
 
28
- ```shell
29
- bun i hexo-renderer-markdown-exit
30
- ```
31
-
32
28
  ### Table, Math, Quote, Callout & Tabs, Highlight
33
29
 
34
30
  <table>
@@ -1,3 +1,129 @@
1
+ const path = require("node:path");
2
+ const { tab } = require("@mdit/plugin-tab");
3
+ const { createMarkdownExit } = require("markdown-exit");
4
+ const mermaidDiagram = require("markdown-exit-mermaid");
5
+ const ratex = require("markdown-exit-ratex");
6
+ const code = require("markdown-exit-shiki");
7
+ const abbr = require("markdown-it-abbr");
8
+ const anchor = require("markdown-it-anchor");
9
+ const footnote = require("markdown-it-footnote");
10
+ const ins = require("markdown-it-ins");
11
+ const mark = require("markdown-it-mark");
12
+ const sub = require("markdown-it-sub");
13
+ const sup = require("markdown-it-sup");
14
+ const taskLists = require("markdown-it-task-lists");
15
+
16
+ function resolveDefault(module) {
17
+ return module && typeof module === "object" && "default" in module ? module.default : module;
18
+ }
19
+
20
+ class MarkdownRenderer {
21
+ constructor(hexo) {
22
+ this.hexo = hexo;
23
+ this.config = {
24
+ render_options: {
25
+ breaks: true,
26
+ html: true,
27
+ langPrefix: "language-",
28
+ linkify: true,
29
+ quotes: "“”‘’",
30
+ typographer: true,
31
+ xhtmlOut: false,
32
+ },
33
+ code_options: {
34
+ themes: {
35
+ light: "catppuccin-latte",
36
+ },
37
+ },
38
+ mermaid_options: {
39
+ theme: "default",
40
+ },
41
+ ...(hexo.config.markdown_exit || {}),
42
+ };
43
+
44
+ this.md = createMarkdownExit(this.config.render_options);
45
+ this.initPlugins();
46
+ }
47
+
48
+ initPlugins() {
49
+ console.time("MarkdownExit: Load Default Plugins");
50
+ if (this.config.defaultPlugins !== false) {
51
+ this.md
52
+ .use(resolveDefault(footnote))
53
+ .use(resolveDefault(mark))
54
+ .use(resolveDefault(sub))
55
+ .use(resolveDefault(sup))
56
+ .use(resolveDefault(abbr))
57
+ .use(resolveDefault(ins))
58
+ .use(resolveDefault(taskLists))
59
+ .use(resolveDefault(code), this.config.code_options)
60
+ .use(resolveDefault(mermaidDiagram), this.config.mermaid_options)
61
+ .use(resolveDefault(ratex), this.config.ratex_options)
62
+ .use(tab)
63
+ .use(resolveDefault(anchor), {
64
+ permalink: resolveDefault(anchor).permalink.headerLink(),
65
+ });
66
+ }
67
+ console.timeEnd("MarkdownExit: Load Default Plugins");
68
+
69
+ console.time("MarkdownExit: Load User Plugins");
70
+ this.loadUserPlugins();
71
+ console.timeEnd("MarkdownExit: Load User Plugins");
72
+ }
73
+
74
+ resolvePluginFunction(plugin) {
75
+ if (plugin && typeof plugin.default === "function") return plugin.default;
76
+ if (typeof plugin === "function") return plugin;
77
+
78
+ if (plugin && typeof plugin === "object") {
79
+ for (const key in plugin) {
80
+ if (typeof plugin[key] === "function") return plugin[key];
81
+ }
82
+ }
83
+
84
+ return plugin;
85
+ }
86
+
87
+ loadUserPlugins() {
88
+ const plugins = this.config.plugins || [];
89
+ for (const pluginConfig of plugins) {
90
+ const isString = typeof pluginConfig === "string";
91
+ const pluginName = isString ? pluginConfig : pluginConfig.name;
92
+ const pluginOptions = isString ? {} : pluginConfig.options || {};
93
+
94
+ try {
95
+ const pluginPath = path.join(this.hexo.base_dir, "node_modules", pluginName);
96
+ const plugin = require(pluginPath);
97
+ const pluginFn = this.resolvePluginFunction(plugin);
98
+
99
+ this.md.use(pluginFn, pluginOptions);
100
+ if (process.env.DEBUG) {
101
+ console.log(`Successfully loaded plugin: ${pluginName}`);
102
+ }
103
+ } catch (error) {
104
+ console.warn(`Failed to load plugin: ${pluginName}`);
105
+ if (process.env.DEBUG) {
106
+ console.warn(` Error: ${error}`);
107
+ }
108
+ }
109
+ }
110
+ }
111
+
112
+ async render(data) {
113
+ if (!data.text) return "";
114
+ return this.md.renderAsync(data.text);
115
+ }
116
+ }
117
+
118
+ const markdownRendererInstances = new WeakMap();
119
+
120
+ function getMarkdownRenderer(hexo) {
121
+ if (!markdownRendererInstances.has(hexo)) {
122
+ markdownRendererInstances.set(hexo, new MarkdownRenderer(hexo));
123
+ }
124
+ return markdownRendererInstances.get(hexo);
125
+ }
126
+
1
127
  const { transformSync } = require("esbuild");
2
128
  const { createElement } = require("inferno-create-element");
3
129
  const { renderToStaticMarkup } = require("inferno-server");
@@ -50,5 +176,10 @@ function renderer(data, locals) {
50
176
  renderer.compile = compile;
51
177
 
52
178
  module.exports = (hexo) => {
179
+ const markdownConfig = hexo.config.markdown_exit || {};
180
+ const markdownRenderer = async (data) => getMarkdownRenderer(hexo).render(data);
181
+ markdownRenderer.disableNunjucks = Boolean(markdownConfig.disableNunjucks);
182
+
183
+ hexo.extend.renderer.register("md", "html", markdownRenderer);
53
184
  hexo.extend.renderer.register("jsx", "html", renderer, true);
54
185
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hexo-theme-gnix",
3
- "version": "10.0.0",
3
+ "version": "11.0.0",
4
4
  "author": "Efterklang <gaojiaxing0220@gmail.com> (https://vluv.space)",
5
5
  "license": "MIT",
6
6
  "description": "Second generation of Hexo theme Icarus, now with Catppuccin flavor and night mode support.",
@@ -34,6 +34,7 @@
34
34
  "README.md"
35
35
  ],
36
36
  "dependencies": {
37
+ "@mdit/plugin-tab": "^0.24.2",
37
38
  "@swup/head-plugin": "^2.3.1",
38
39
  "@swup/scripts-plugin": "^2.1.0",
39
40
  "esbuild": "^0.28.0",
@@ -43,6 +44,18 @@
43
44
  "inferno-create-element": "^9.1.0",
44
45
  "inferno-server": "^9.1.0",
45
46
  "js-yaml": "^4.1.1",
47
+ "markdown-exit": "^1.0.0-beta.9",
48
+ "markdown-exit-mermaid": "^2.2.3",
49
+ "markdown-exit-ratex": "^0.2.2",
50
+ "markdown-exit-shiki": "^0.3.2",
51
+ "markdown-it-abbr": "^2.0.0",
52
+ "markdown-it-anchor": "^9.2.0",
53
+ "markdown-it-footnote": "^4.0.0",
54
+ "markdown-it-ins": "^4.0.0",
55
+ "markdown-it-mark": "^4.0.0",
56
+ "markdown-it-sub": "^2.0.0",
57
+ "markdown-it-sup": "^2.0.0",
58
+ "markdown-it-task-lists": "^2.1.1",
46
59
  "swup": "^4.8.3"
47
60
  },
48
61
  "peerDependencies": {