nodebb-plugin-katex2 1.0.0 → 1.0.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-katex2",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "KaTeX math rendering plugin for NodeBB",
5
5
  "main": "lib/index.js",
6
6
  "repository": {
@@ -27,6 +27,7 @@
27
27
  "eslint": "^9.35.0"
28
28
  },
29
29
  "scripts": {
30
+ "postinstall": "node scripts/copy-katex.js",
30
31
  "lint": "eslint lib/ static/js/",
31
32
  "fix": "eslint --fix lib/ static/js/"
32
33
  },
package/plugin.json CHANGED
@@ -13,6 +13,6 @@
13
13
  "scripts": ["static/js/render.js"],
14
14
  "stylesheets": ["static/css/katex.css"],
15
15
  "staticDirs": {
16
- "katex": "./node_modules/katex/dist"
16
+ "katex": "./static/katex"
17
17
  }
18
18
  }
@@ -0,0 +1,27 @@
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+
4
+ const sourceDir = path.join(__dirname, "../node_modules/katex/dist");
5
+ const targetDir = path.join(__dirname, "../static/katex");
6
+
7
+ // Создаем целевую директорию если её нет
8
+ if (!fs.existsSync(targetDir)) {
9
+ fs.mkdirSync(targetDir, { recursive: true });
10
+ }
11
+
12
+ // Копируем файлы
13
+ function copyRecursive(src, dest) {
14
+ if (fs.statSync(src).isDirectory()) {
15
+ if (!fs.existsSync(dest)) {
16
+ fs.mkdirSync(dest, { recursive: true });
17
+ }
18
+ fs.readdirSync(src).forEach((file) => {
19
+ copyRecursive(path.join(src, file), path.join(dest, file));
20
+ });
21
+ } else {
22
+ fs.copyFileSync(src, dest);
23
+ }
24
+ }
25
+
26
+ copyRecursive(sourceDir, targetDir);
27
+ console.log("KaTeX files copied successfully");