@netfoundry/docusaurus-theme 0.2.0 → 0.2.3

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 (141) hide show
  1. package/dist/src/components/Alert/Alert.js +51 -6
  2. package/dist/src/components/Alert/Alert.js.map +7 -1
  3. package/dist/src/components/Alert/index.js +29 -2
  4. package/dist/src/components/Alert/index.js.map +7 -1
  5. package/dist/src/components/CodeBlock/CodeBlock.js +53 -7
  6. package/dist/src/components/CodeBlock/CodeBlock.js.map +7 -1
  7. package/dist/src/components/CodeBlock/index.js +29 -2
  8. package/dist/src/components/CodeBlock/index.js.map +7 -1
  9. package/dist/src/components/Common/Common.js +59 -16
  10. package/dist/src/components/Common/Common.js.map +7 -1
  11. package/dist/src/components/Common/Logos.d.ts +6 -0
  12. package/dist/src/components/Common/Logos.d.ts.map +1 -0
  13. package/dist/src/components/Common/Logos.js +93 -0
  14. package/dist/src/components/Common/Logos.js.map +7 -0
  15. package/dist/src/components/Common/index.d.ts +1 -0
  16. package/dist/src/components/Common/index.d.ts.map +1 -1
  17. package/dist/src/components/Common/index.js +25 -2
  18. package/dist/src/components/Common/index.js.map +7 -1
  19. package/dist/src/components/NetFoundry/Divider/Divider.js +46 -5
  20. package/dist/src/components/NetFoundry/Divider/Divider.js.map +7 -1
  21. package/dist/src/components/NetFoundry/Divider/index.js +23 -2
  22. package/dist/src/components/NetFoundry/Divider/index.js.map +7 -1
  23. package/dist/src/components/NetFoundry/index.js +23 -2
  24. package/dist/src/components/NetFoundry/index.js.map +7 -1
  25. package/dist/src/components/NetFoundryFooter/NetFoundryFooter.d.ts +2 -21
  26. package/dist/src/components/NetFoundryFooter/NetFoundryFooter.d.ts.map +1 -1
  27. package/dist/src/components/NetFoundryFooter/NetFoundryFooter.js +115 -58
  28. package/dist/src/components/NetFoundryFooter/NetFoundryFooter.js.map +7 -1
  29. package/dist/src/components/NetFoundryFooter/defaults.js +50 -23
  30. package/dist/src/components/NetFoundryFooter/defaults.js.map +7 -1
  31. package/dist/src/components/NetFoundryFooter/index.js +23 -2
  32. package/dist/src/components/NetFoundryFooter/index.js.map +7 -1
  33. package/dist/src/components/NetFoundryFooter/types.d.ts +27 -0
  34. package/dist/src/components/NetFoundryFooter/types.d.ts.map +1 -0
  35. package/dist/src/components/NetFoundryFooter/types.js +53 -0
  36. package/dist/src/components/NetFoundryFooter/types.js.map +7 -0
  37. package/dist/src/components/NetFoundryHighlight/NetFoundryHighlight.js +32 -5
  38. package/dist/src/components/NetFoundryHighlight/NetFoundryHighlight.js.map +7 -1
  39. package/dist/src/components/NetFoundryHighlight/index.js +29 -2
  40. package/dist/src/components/NetFoundryHighlight/index.js.map +7 -1
  41. package/dist/src/components/NetFoundryHorizontalSection/NetFoundryHorizontalSection.js +52 -7
  42. package/dist/src/components/NetFoundryHorizontalSection/NetFoundryHorizontalSection.js.map +7 -1
  43. package/dist/src/components/NetFoundryHorizontalSection/index.js +29 -2
  44. package/dist/src/components/NetFoundryHorizontalSection/index.js.map +7 -1
  45. package/dist/src/components/NetFoundryLayout/NetFoundryLayout.js +111 -34
  46. package/dist/src/components/NetFoundryLayout/NetFoundryLayout.js.map +7 -1
  47. package/dist/src/components/NetFoundryLayout/index.js +23 -2
  48. package/dist/src/components/NetFoundryLayout/index.js.map +7 -1
  49. package/dist/src/components/NetFoundryNavbarItems/NetFoundryNavbarItems.js +40 -13
  50. package/dist/src/components/NetFoundryNavbarItems/NetFoundryNavbarItems.js.map +7 -1
  51. package/dist/src/components/NetFoundryNavbarItems/index.js +29 -2
  52. package/dist/src/components/NetFoundryNavbarItems/index.js.map +7 -1
  53. package/dist/src/components/OsTabs/OsTabs.js +53 -17
  54. package/dist/src/components/OsTabs/OsTabs.js.map +7 -1
  55. package/dist/src/components/OsTabs/index.js +29 -2
  56. package/dist/src/components/OsTabs/index.js.map +7 -1
  57. package/dist/src/components/ProductSearch/ProductSearch.js +243 -122
  58. package/dist/src/components/ProductSearch/ProductSearch.js.map +7 -1
  59. package/dist/src/components/ProductSearch/index.js +42 -4
  60. package/dist/src/components/ProductSearch/index.js.map +7 -1
  61. package/dist/src/components/StarUs/StarUs.js +45 -6
  62. package/dist/src/components/StarUs/StarUs.js.map +7 -1
  63. package/dist/src/components/StarUs/index.js +39 -2
  64. package/dist/src/components/StarUs/index.js.map +7 -1
  65. package/dist/src/components/index.js +45 -13
  66. package/dist/src/components/index.js.map +7 -1
  67. package/dist/src/config.d.ts +9 -0
  68. package/dist/src/config.d.ts.map +1 -0
  69. package/dist/src/config.js +34 -0
  70. package/dist/src/config.js.map +7 -0
  71. package/dist/src/css-modules.d.js +2 -0
  72. package/dist/src/css-modules.d.js.map +7 -0
  73. package/dist/src/docusaurus-envhelper.js +111 -64
  74. package/dist/src/docusaurus-envhelper.js.map +7 -1
  75. package/dist/src/docusaurus-plugins/index.js +35 -8
  76. package/dist/src/docusaurus-plugins/index.js.map +7 -1
  77. package/dist/src/docusaurus-plugins/logger.js +66 -38
  78. package/dist/src/docusaurus-plugins/logger.js.map +7 -1
  79. package/dist/src/docusaurus-plugins/remarkCodeSections.js +127 -94
  80. package/dist/src/docusaurus-plugins/remarkCodeSections.js.map +7 -1
  81. package/dist/src/docusaurus-plugins/remarkReplaceMetaUrl.js +50 -22
  82. package/dist/src/docusaurus-plugins/remarkReplaceMetaUrl.js.map +7 -1
  83. package/dist/src/docusaurus-plugins/remarkScopedPath.js +78 -46
  84. package/dist/src/docusaurus-plugins/remarkScopedPath.js.map +7 -1
  85. package/dist/src/docusaurus-plugins/remarkYamlTable.js +84 -49
  86. package/dist/src/docusaurus-plugins/remarkYamlTable.js.map +7 -1
  87. package/dist/src/docusaurus-plugins/remarkYouTube.js +65 -42
  88. package/dist/src/docusaurus-plugins/remarkYouTube.js.map +7 -1
  89. package/dist/src/docusaurus-plugins/timedPlugin.js +42 -15
  90. package/dist/src/docusaurus-plugins/timedPlugin.js.map +7 -1
  91. package/dist/src/docusaurus.d.js +2 -0
  92. package/dist/src/docusaurus.d.js.map +7 -0
  93. package/dist/src/index.d.ts.map +1 -1
  94. package/dist/src/index.js +63 -31
  95. package/dist/src/index.js.map +7 -1
  96. package/dist/src/node.js +23 -7
  97. package/dist/src/node.js.map +7 -1
  98. package/dist/src/options.d.ts +7 -0
  99. package/dist/src/options.d.ts.map +1 -1
  100. package/dist/src/options.js +17 -2
  101. package/dist/src/options.js.map +7 -1
  102. package/dist/src/plugins.js +23 -7
  103. package/dist/src/plugins.js.map +7 -1
  104. package/dist/src/ui.js +25 -8
  105. package/dist/src/ui.js.map +7 -1
  106. package/dist/src/version.js +29 -2
  107. package/dist/src/version.js.map +7 -1
  108. package/dist/theme/BlogPostPage/Metadata.js +35 -2
  109. package/dist/theme/BlogPostPage/Metadata.js.map +7 -1
  110. package/dist/theme/BlogPostPage/StructuredData.js +35 -2
  111. package/dist/theme/BlogPostPage/StructuredData.js.map +7 -1
  112. package/dist/theme/BlogPostPage/index.js +98 -24
  113. package/dist/theme/BlogPostPage/index.js.map +7 -1
  114. package/dist/theme/DocSearch/index.js +95 -27
  115. package/dist/theme/DocSearch/index.js.map +7 -1
  116. package/dist/theme/Layout/index.js +81 -35
  117. package/dist/theme/Layout/index.js.map +7 -1
  118. package/dist/theme/Navbar/Content/index.js +69 -26
  119. package/dist/theme/Navbar/Content/index.js.map +7 -1
  120. package/dist/theme/Navbar/Logo/index.d.ts.map +1 -1
  121. package/dist/theme/Navbar/Logo/index.js +87 -42
  122. package/dist/theme/Navbar/Logo/index.js.map +7 -1
  123. package/dist/theme/OsTabs/index.js +50 -19
  124. package/dist/theme/OsTabs/index.js.map +7 -1
  125. package/dist/theme/SearchBar/index.js +89 -34
  126. package/dist/theme/SearchBar/index.js.map +7 -1
  127. package/package.json +11 -25
  128. package/css/layout.css +0 -14
  129. package/css/legacy.css +0 -2313
  130. package/css/tabs-v1-gradient.css +0 -92
  131. package/css/tabs-v2-glass.css +0 -116
  132. package/css/tabs-v3-minimal.css +0 -86
  133. package/css/tabs-v4-segmented.css +0 -85
  134. package/css/tabs-v5-neon.css +0 -99
  135. package/css/tabs-v6-neumorphic.css +0 -89
  136. package/css/tabs-v7-brutalist.css +0 -81
  137. package/css/tabs-v8-float.css +0 -114
  138. package/css/tabs-v9-line.css +0 -104
  139. package/css/theme.css +0 -72
  140. package/css/vars-dark.css +0 -7
  141. package/css/vars.css +0 -8
@@ -1,41 +1,69 @@
1
- import { writeFileSync, appendFileSync, existsSync } from 'fs';
2
- import { join } from 'path';
3
- export var LogLevel;
4
- (function (LogLevel) {
5
- LogLevel[LogLevel["Silent"] = 0] = "Silent";
6
- LogLevel[LogLevel["Info"] = 1] = "Info";
7
- LogLevel[LogLevel["Debug"] = 2] = "Debug";
8
- })(LogLevel || (LogLevel = {}));
9
- const LOG = join(process.cwd(), 'remark-plugins.log');
10
- export class Logger {
11
- constructor(level, name) {
12
- this.level = level;
13
- this.name = name;
14
- }
15
- log(msg, level = LogLevel.Info) {
16
- if (this.level === LogLevel.Silent)
17
- return;
18
- if (level > this.level)
19
- return;
20
- const text = String(msg);
21
- if (!text.trim())
22
- return;
23
- const line = `[${this.name}] ${LogLevel[level]} ${text}`;
24
- if (!existsSync(LOG))
25
- writeFileSync(LOG, '');
26
- appendFileSync(LOG, `[${new Date().toISOString()}] ${line}\n`);
27
- }
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var logger_exports = {};
20
+ __export(logger_exports, {
21
+ LogLevel: () => LogLevel,
22
+ Logger: () => Logger,
23
+ resolveLogLevel: () => resolveLogLevel
24
+ });
25
+ module.exports = __toCommonJS(logger_exports);
26
+ var import_fs = require("fs");
27
+ var import_path = require("path");
28
+ var LogLevel = /* @__PURE__ */ ((LogLevel2) => {
29
+ LogLevel2[LogLevel2["Silent"] = 0] = "Silent";
30
+ LogLevel2[LogLevel2["Info"] = 1] = "Info";
31
+ LogLevel2[LogLevel2["Debug"] = 2] = "Debug";
32
+ return LogLevel2;
33
+ })(LogLevel || {});
34
+ const LOG = (0, import_path.join)(process.cwd(), "remark-plugins.log");
35
+ class Logger {
36
+ constructor(level, name) {
37
+ this.level = level;
38
+ this.name = name;
39
+ }
40
+ log(msg, level = 1 /* Info */) {
41
+ if (this.level === 0 /* Silent */) return;
42
+ if (level > this.level) return;
43
+ const text = String(msg);
44
+ if (!text.trim()) return;
45
+ const line = `[${this.name}] ${LogLevel[level]} ${text}`;
46
+ if (!(0, import_fs.existsSync)(LOG)) (0, import_fs.writeFileSync)(LOG, "");
47
+ (0, import_fs.appendFileSync)(LOG, `[${(/* @__PURE__ */ new Date()).toISOString()}] ${line}
48
+ `);
49
+ }
28
50
  }
29
- export function resolveLogLevel(val) {
30
- if (typeof val === "number" && LogLevel[val] !== undefined) {
31
- return val;
32
- }
33
- if (typeof val === "string") {
34
- const key = val[0].toUpperCase() + val.slice(1).toLowerCase();
35
- if (key in LogLevel) {
36
- return LogLevel[key];
37
- }
51
+ function resolveLogLevel(val) {
52
+ if (typeof val === "number" && LogLevel[val] !== void 0) {
53
+ return val;
54
+ }
55
+ if (typeof val === "string") {
56
+ const key = val[0].toUpperCase() + val.slice(1).toLowerCase();
57
+ if (key in LogLevel) {
58
+ return LogLevel[key];
38
59
  }
39
- return LogLevel.Silent;
60
+ }
61
+ return 0 /* Silent */;
40
62
  }
41
- //# sourceMappingURL=logger.js.map
63
+ // Annotate the CommonJS export names for ESM import in node:
64
+ 0 && (module.exports = {
65
+ LogLevel,
66
+ Logger,
67
+ resolveLogLevel
68
+ });
69
+ //# sourceMappingURL=logger.js.map
@@ -1 +1,7 @@
1
- {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../src/docusaurus-plugins/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,IAAI,CAAA;AAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAE3B,MAAM,CAAN,IAAY,QAIX;AAJD,WAAY,QAAQ;IAChB,2CAAU,CAAA;IACV,uCAAQ,CAAA;IACR,yCAAS,CAAA;AACb,CAAC,EAJW,QAAQ,KAAR,QAAQ,QAInB;AAED,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,oBAAoB,CAAC,CAAA;AAErD,MAAM,OAAO,MAAM;IACf,YAAoB,KAAe,EAAU,IAAY;QAArC,UAAK,GAAL,KAAK,CAAU;QAAU,SAAI,GAAJ,IAAI,CAAQ;IAAG,CAAC;IAC7D,GAAG,CAAC,GAAY,EAAE,QAAkB,QAAQ,CAAC,IAAI;QAC7C,IAAI,IAAI,CAAC,KAAK,KAAK,QAAQ,CAAC,MAAM;YAAE,OAAM;QAC1C,IAAI,KAAK,GAAG,IAAI,CAAC,KAAK;YAAE,OAAM;QAE9B,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,CAAA;QACxB,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;YAAE,OAAM;QAExB,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,CAAA;QACxD,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;YAAE,aAAa,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA;QAC5C,cAAc,CAAC,GAAG,EAAE,IAAI,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,KAAK,IAAI,IAAI,CAAC,CAAA;IAClE,CAAC;CACJ;AAED,MAAM,UAAU,eAAe,CAAC,GAAY;IACxC,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,QAAQ,CAAC,GAAG,CAAC,KAAK,SAAS,EAAE,CAAC;QACzD,OAAO,GAAe,CAAA;IAC1B,CAAC;IACD,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC1B,MAAM,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAA;QAC7D,IAAI,GAAG,IAAI,QAAQ,EAAE,CAAC;YAClB,OAAO,QAAQ,CAAC,GAA4B,CAAC,CAAA;QACjD,CAAC;IACL,CAAC;IACD,OAAO,QAAQ,CAAC,MAAM,CAAA;AAC1B,CAAC"}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/docusaurus-plugins/logger.ts"],
4
+ "sourcesContent": ["import { writeFileSync, appendFileSync, existsSync } from 'fs'\r\nimport { join } from 'path'\r\n\r\nexport enum LogLevel {\r\n Silent = 0,\r\n Info = 1,\r\n Debug = 2,\r\n}\r\n\r\nconst LOG = join(process.cwd(), 'remark-plugins.log')\r\n\r\nexport class Logger {\r\n constructor(private level: LogLevel, private name: string) {}\r\n log(msg: unknown, level: LogLevel = LogLevel.Info) {\r\n if (this.level === LogLevel.Silent) return\r\n if (level > this.level) return\r\n\r\n const text = String(msg)\r\n if (!text.trim()) return\r\n\r\n const line = `[${this.name}] ${LogLevel[level]} ${text}`\r\n if (!existsSync(LOG)) writeFileSync(LOG, '')\r\n appendFileSync(LOG, `[${new Date().toISOString()}] ${line}\\n`)\r\n }\r\n}\r\n\r\nexport function resolveLogLevel(val: unknown): LogLevel {\r\n if (typeof val === \"number\" && LogLevel[val] !== undefined) {\r\n return val as LogLevel\r\n }\r\n if (typeof val === \"string\") {\r\n const key = val[0].toUpperCase() + val.slice(1).toLowerCase()\r\n if (key in LogLevel) {\r\n return LogLevel[key as keyof typeof LogLevel]\r\n }\r\n }\r\n return LogLevel.Silent\r\n}"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAA0D;AAC1D,kBAAqB;AAEd,IAAK,WAAL,kBAAKA,cAAL;AACH,EAAAA,oBAAA,YAAS,KAAT;AACA,EAAAA,oBAAA,UAAO,KAAP;AACA,EAAAA,oBAAA,WAAQ,KAAR;AAHQ,SAAAA;AAAA,GAAA;AAMZ,MAAM,UAAM,kBAAK,QAAQ,IAAI,GAAG,oBAAoB;AAE7C,MAAM,OAAO;AAAA,EAChB,YAAoB,OAAyB,MAAc;AAAvC;AAAyB;AAAA,EAAe;AAAA,EAC5D,IAAI,KAAc,QAAkB,cAAe;AAC/C,QAAI,KAAK,UAAU,eAAiB;AACpC,QAAI,QAAQ,KAAK,MAAO;AAExB,UAAM,OAAO,OAAO,GAAG;AACvB,QAAI,CAAC,KAAK,KAAK,EAAG;AAElB,UAAM,OAAO,IAAI,KAAK,IAAI,KAAK,SAAS,KAAK,CAAC,IAAI,IAAI;AACtD,QAAI,KAAC,sBAAW,GAAG,EAAG,8BAAc,KAAK,EAAE;AAC3C,kCAAe,KAAK,KAAI,oBAAI,KAAK,GAAE,YAAY,CAAC,KAAK,IAAI;AAAA,CAAI;AAAA,EACjE;AACJ;AAEO,SAAS,gBAAgB,KAAwB;AACpD,MAAI,OAAO,QAAQ,YAAY,SAAS,GAAG,MAAM,QAAW;AACxD,WAAO;AAAA,EACX;AACA,MAAI,OAAO,QAAQ,UAAU;AACzB,UAAM,MAAM,IAAI,CAAC,EAAE,YAAY,IAAI,IAAI,MAAM,CAAC,EAAE,YAAY;AAC5D,QAAI,OAAO,UAAU;AACjB,aAAO,SAAS,GAA4B;AAAA,IAChD;AAAA,EACJ;AACA,SAAO;AACX;",
6
+ "names": ["LogLevel"]
7
+ }
@@ -1,96 +1,129 @@
1
- import { visit } from "unist-util-visit";
2
- import { Logger, LogLevel, resolveLogLevel } from "./logger";
3
- export const remarkCodeSections = (options) => {
4
- const logger = new Logger(resolveLogLevel(options?.logLevel), "remarkCodeSections");
5
- const desc_text = "@desc:";
6
- const command_text = "@command:";
7
- const code_text = "@code:";
8
- const results_text = "@results:";
9
- return (tree) => {
10
- visit(tree, "code", (node, index, parent) => {
11
- if (!node?.value)
12
- return;
13
- const hasActivator = /@desc:|@command:|@code:|@results:/.test(node.value);
14
- if (!hasActivator)
15
- return;
16
- logger.log(node, LogLevel.Debug);
17
- if (node.lang && node.lang.startsWith("example")) {
18
- const lang = node.lang.replace("example-", "").trim();
19
- const lines = node.value.split("\n");
20
- let description = "", command = "", code = "", results = "", codeTitle = "";
21
- let currentSection = "";
22
- lines.forEach((line) => {
23
- if (line.startsWith(desc_text)) {
24
- currentSection = "description";
25
- description = line.replace(desc_text, "").trim();
26
- }
27
- else if (line.startsWith(command_text)) {
28
- currentSection = "command";
29
- command = line.replace(command_text, "").trim();
30
- }
31
- else if (line.startsWith(code_text)) {
32
- currentSection = "code";
33
- codeTitle = line.replace(code_text, "").trim();
34
- }
35
- else if (line.startsWith(results_text)) {
36
- currentSection = "results";
37
- results = line.replace(results_text, "").trim();
38
- }
39
- else {
40
- if (currentSection === "description")
41
- description += `\n${line}`;
42
- else if (currentSection === "command")
43
- command += `\n${line}`;
44
- else if (currentSection === "code")
45
- code += `\n${line}`;
46
- else if (currentSection === "results")
47
- results += `\n${line}`;
48
- }
49
- });
50
- const divWrapper = {
51
- type: "div",
52
- data: { hName: "div", hProperties: { className: "code-section" } },
53
- children: [],
54
- };
55
- if (description) {
56
- const descDiv = {
57
- type: "div",
58
- data: { hName: "div", hProperties: { className: "code-section-desc" } },
59
- children: [],
60
- };
61
- descDiv.children.push({ type: "paragraph", children: [{ type: "strong", children: [{ type: "text", value: "Description:" }] }] }, { type: "paragraph", children: [{ type: "text", value: description.trim() }], data: { hProperties: { style: "padding-bottom: 10px;" } } });
62
- divWrapper.children.push(descDiv);
63
- }
64
- if (command) {
65
- const cmdDiv = {
66
- type: "div",
67
- data: { hName: "div", hProperties: { className: "code-section-command" } },
68
- children: [],
69
- };
70
- cmdDiv.children.push({ type: "paragraph", children: [{ type: "strong", children: [{ type: "text", value: "Command:" }] }] }, { type: "code", lang: "sh", value: command.trim() });
71
- divWrapper.children.push(cmdDiv);
72
- }
73
- if (code) {
74
- const codeDiv = {
75
- type: "div",
76
- data: { hName: "div", hProperties: { className: "code-section-code" } },
77
- children: [],
78
- };
79
- codeDiv.children.push({ type: "paragraph", children: [{ type: "strong", children: [{ type: "text", value: codeTitle }] }] }, { type: "code", lang, value: code.trim() });
80
- divWrapper.children.push(codeDiv);
81
- }
82
- if (results) {
83
- const resultsDiv = {
84
- type: "div",
85
- data: { hName: "div", hProperties: { className: "code-section-results" } },
86
- children: [],
87
- };
88
- resultsDiv.children.push({ type: "paragraph", children: [{ type: "strong", children: [{ type: "text", value: "Results:" }] }] }, { type: "code", lang: "buttonless", value: results.trim() });
89
- divWrapper.children.push(resultsDiv);
90
- }
91
- parent.children.splice(index, 1, divWrapper);
92
- }
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var remarkCodeSections_exports = {};
20
+ __export(remarkCodeSections_exports, {
21
+ remarkCodeSections: () => remarkCodeSections
22
+ });
23
+ module.exports = __toCommonJS(remarkCodeSections_exports);
24
+ var import_unist_util_visit = require("unist-util-visit");
25
+ var import_logger = require("./logger");
26
+ const remarkCodeSections = (options) => {
27
+ const logger = new import_logger.Logger((0, import_logger.resolveLogLevel)(options?.logLevel), "remarkCodeSections");
28
+ const desc_text = "@desc:";
29
+ const command_text = "@command:";
30
+ const code_text = "@code:";
31
+ const results_text = "@results:";
32
+ return (tree) => {
33
+ (0, import_unist_util_visit.visit)(tree, "code", (node, index, parent) => {
34
+ if (!node?.value) return;
35
+ const hasActivator = /@desc:|@command:|@code:|@results:/.test(node.value);
36
+ if (!hasActivator) return;
37
+ logger.log(node, import_logger.LogLevel.Debug);
38
+ if (node.lang && node.lang.startsWith("example")) {
39
+ const lang = node.lang.replace("example-", "").trim();
40
+ const lines = node.value.split("\n");
41
+ let description = "", command = "", code = "", results = "", codeTitle = "";
42
+ let currentSection = "";
43
+ lines.forEach((line) => {
44
+ if (line.startsWith(desc_text)) {
45
+ currentSection = "description";
46
+ description = line.replace(desc_text, "").trim();
47
+ } else if (line.startsWith(command_text)) {
48
+ currentSection = "command";
49
+ command = line.replace(command_text, "").trim();
50
+ } else if (line.startsWith(code_text)) {
51
+ currentSection = "code";
52
+ codeTitle = line.replace(code_text, "").trim();
53
+ } else if (line.startsWith(results_text)) {
54
+ currentSection = "results";
55
+ results = line.replace(results_text, "").trim();
56
+ } else {
57
+ if (currentSection === "description") description += `
58
+ ${line}`;
59
+ else if (currentSection === "command") command += `
60
+ ${line}`;
61
+ else if (currentSection === "code") code += `
62
+ ${line}`;
63
+ else if (currentSection === "results") results += `
64
+ ${line}`;
65
+ }
93
66
  });
94
- };
67
+ const divWrapper = {
68
+ type: "div",
69
+ data: { hName: "div", hProperties: { className: "code-section" } },
70
+ children: []
71
+ };
72
+ if (description) {
73
+ const descDiv = {
74
+ type: "div",
75
+ data: { hName: "div", hProperties: { className: "code-section-desc" } },
76
+ children: []
77
+ };
78
+ descDiv.children.push(
79
+ { type: "paragraph", children: [{ type: "strong", children: [{ type: "text", value: "Description:" }] }] },
80
+ { type: "paragraph", children: [{ type: "text", value: description.trim() }], data: { hProperties: { style: "padding-bottom: 10px;" } } }
81
+ );
82
+ divWrapper.children.push(descDiv);
83
+ }
84
+ if (command) {
85
+ const cmdDiv = {
86
+ type: "div",
87
+ data: { hName: "div", hProperties: { className: "code-section-command" } },
88
+ children: []
89
+ };
90
+ cmdDiv.children.push(
91
+ { type: "paragraph", children: [{ type: "strong", children: [{ type: "text", value: "Command:" }] }] },
92
+ { type: "code", lang: "sh", value: command.trim() }
93
+ );
94
+ divWrapper.children.push(cmdDiv);
95
+ }
96
+ if (code) {
97
+ const codeDiv = {
98
+ type: "div",
99
+ data: { hName: "div", hProperties: { className: "code-section-code" } },
100
+ children: []
101
+ };
102
+ codeDiv.children.push(
103
+ { type: "paragraph", children: [{ type: "strong", children: [{ type: "text", value: codeTitle }] }] },
104
+ { type: "code", lang, value: code.trim() }
105
+ );
106
+ divWrapper.children.push(codeDiv);
107
+ }
108
+ if (results) {
109
+ const resultsDiv = {
110
+ type: "div",
111
+ data: { hName: "div", hProperties: { className: "code-section-results" } },
112
+ children: []
113
+ };
114
+ resultsDiv.children.push(
115
+ { type: "paragraph", children: [{ type: "strong", children: [{ type: "text", value: "Results:" }] }] },
116
+ { type: "code", lang: "buttonless", value: results.trim() }
117
+ );
118
+ divWrapper.children.push(resultsDiv);
119
+ }
120
+ parent.children.splice(index, 1, divWrapper);
121
+ }
122
+ });
123
+ };
95
124
  };
96
- //# sourceMappingURL=remarkCodeSections.js.map
125
+ // Annotate the CommonJS export names for ESM import in node:
126
+ 0 && (module.exports = {
127
+ remarkCodeSections
128
+ });
129
+ //# sourceMappingURL=remarkCodeSections.js.map
@@ -1 +1,7 @@
1
-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Q,EAAE,EAAW;qBACxB,CAAA;oBACD,UAAU,CAAC,QAAQ,CAAC,IAAI,CACpB,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC,EAAE,EACtG,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,OAAO,CAAC,IAAI,EAAE,EAAE,CAC9D,CAAA;oBACD,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;gBACxC,CAAC;gBAED,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,EAAE,UAAU,CAAC,CAAA;YAChD,CAAC;QACL,CAAC,CAAC,CAAA;IACN,CAAC,CAAA;AACL,CAAC,CAAA"}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/docusaurus-plugins/remarkCodeSections.ts"],
4
+ "sourcesContent": ["import {visit} from \"unist-util-visit\"\nimport type {Plugin} from \"unified\"\nimport type {Node} from \"unist\"\nimport {Logger, LogLevel, resolveLogLevel} from \"./logger\"\n\ninterface Options {\n logLevel?: LogLevel\n}\n\nexport const remarkCodeSections: Plugin<[Options?]> = (options?: Options) => {\n const logger = new Logger(resolveLogLevel(options?.logLevel), \"remarkCodeSections\")\n\n const desc_text = \"@desc:\"\n const command_text = \"@command:\"\n const code_text = \"@code:\"\n const results_text = \"@results:\"\n\n return (tree: Node) => {\n visit(tree, \"code\", (node: any, index: number, parent: any) => {\n if (!node?.value) return\n\n const hasActivator = /@desc:|@command:|@code:|@results:/.test(node.value)\n if (!hasActivator) return\n\n logger.log(node, LogLevel.Debug)\n if (node.lang && node.lang.startsWith(\"example\")) {\n const lang = node.lang.replace(\"example-\", \"\").trim()\n const lines = node.value.split(\"\\n\")\n let description = \"\", command = \"\", code = \"\", results = \"\", codeTitle = \"\"\n let currentSection = \"\"\n\n lines.forEach((line: string) => {\n if (line.startsWith(desc_text)) {\n currentSection = \"description\"\n description = line.replace(desc_text, \"\").trim()\n } else if (line.startsWith(command_text)) {\n currentSection = \"command\"\n command = line.replace(command_text, \"\").trim()\n } else if (line.startsWith(code_text)) {\n currentSection = \"code\"\n codeTitle = line.replace(code_text, \"\").trim()\n } else if (line.startsWith(results_text)) {\n currentSection = \"results\"\n results = line.replace(results_text, \"\").trim()\n } else {\n if (currentSection === \"description\") description += `\\n${line}`\n else if (currentSection === \"command\") command += `\\n${line}`\n else if (currentSection === \"code\") code += `\\n${line}`\n else if (currentSection === \"results\") results += `\\n${line}`\n }\n })\n\n const divWrapper = {\n type: \"div\",\n data: { hName: \"div\", hProperties: { className: \"code-section\" } },\n children: [] as any[],\n }\n\n if (description) {\n const descDiv = {\n type: \"div\",\n data: { hName: \"div\", hProperties: { className: \"code-section-desc\" } },\n children: [] as any[],\n }\n descDiv.children.push(\n { type: \"paragraph\", children: [{ type: \"strong\", children: [{ type: \"text\", value: \"Description:\" }] }] },\n { type: \"paragraph\", children: [{ type: \"text\", value: description.trim() }], data: { hProperties: { style: \"padding-bottom: 10px;\" } } },\n )\n divWrapper.children.push(descDiv)\n }\n\n if (command) {\n const cmdDiv = {\n type: \"div\",\n data: { hName: \"div\", hProperties: { className: \"code-section-command\" } },\n children: [] as any[],\n }\n cmdDiv.children.push(\n { type: \"paragraph\", children: [{ type: \"strong\", children: [{ type: \"text\", value: \"Command:\" }] }] },\n { type: \"code\", lang: \"sh\", value: command.trim() },\n )\n divWrapper.children.push(cmdDiv)\n }\n\n if (code) {\n const codeDiv = {\n type: \"div\",\n data: { hName: \"div\", hProperties: { className: \"code-section-code\" } },\n children: [] as any[],\n }\n codeDiv.children.push(\n { type: \"paragraph\", children: [{ type: \"strong\", children: [{ type: \"text\", value: codeTitle }] }] },\n { type: \"code\", lang, value: code.trim() },\n )\n divWrapper.children.push(codeDiv)\n }\n\n if (results) {\n const resultsDiv = {\n type: \"div\",\n data: { hName: \"div\", hProperties: { className: \"code-section-results\" } },\n children: [] as any[],\n }\n resultsDiv.children.push(\n { type: \"paragraph\", children: [{ type: \"strong\", children: [{ type: \"text\", value: \"Results:\" }] }] },\n { type: \"code\", lang: \"buttonless\", value: results.trim() },\n )\n divWrapper.children.push(resultsDiv)\n }\n\n parent.children.splice(index, 1, divWrapper)\n }\n })\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAAoB;AAGpB,oBAAgD;AAMzC,MAAM,qBAAyC,CAAC,YAAsB;AACzE,QAAM,SAAS,IAAI,yBAAO,+BAAgB,SAAS,QAAQ,GAAG,oBAAoB;AAElF,QAAM,YAAY;AAClB,QAAM,eAAe;AACrB,QAAM,YAAY;AAClB,QAAM,eAAe;AAErB,SAAO,CAAC,SAAe;AACnB,uCAAM,MAAM,QAAQ,CAAC,MAAW,OAAe,WAAgB;AAC3D,UAAI,CAAC,MAAM,MAAO;AAElB,YAAM,eAAe,oCAAoC,KAAK,KAAK,KAAK;AACxE,UAAI,CAAC,aAAc;AAEnB,aAAO,IAAI,MAAM,uBAAS,KAAK;AAC/B,UAAI,KAAK,QAAQ,KAAK,KAAK,WAAW,SAAS,GAAG;AAC9C,cAAM,OAAO,KAAK,KAAK,QAAQ,YAAY,EAAE,EAAE,KAAK;AACpD,cAAM,QAAQ,KAAK,MAAM,MAAM,IAAI;AACnC,YAAI,cAAc,IAAI,UAAU,IAAI,OAAO,IAAI,UAAU,IAAI,YAAY;AACzE,YAAI,iBAAiB;AAErB,cAAM,QAAQ,CAAC,SAAiB;AAC5B,cAAI,KAAK,WAAW,SAAS,GAAG;AAC5B,6BAAiB;AACjB,0BAAc,KAAK,QAAQ,WAAW,EAAE,EAAE,KAAK;AAAA,UACnD,WAAW,KAAK,WAAW,YAAY,GAAG;AACtC,6BAAiB;AACjB,sBAAU,KAAK,QAAQ,c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IACJ,CAAC;AAAA,EACL;AACJ;",
6
+ "names": []
7
+ }
@@ -1,23 +1,51 @@
1
- import { visit } from 'unist-util-visit';
2
- import { Logger, LogLevel, resolveLogLevel } from './logger';
3
- console.log("🦖 remarkReplaceMetaUrl plugin loaded");
4
- export const remarkReplaceMetaUrl = (options) => {
5
- const { from = '', to = '', logLevel = LogLevel.Silent } = options ?? {};
6
- const logger = new Logger(resolveLogLevel(options?.logLevel), 'remarkReplaceMetaUrl');
7
- logger.log(`initialized: replacing "${from}" → "${to}"`);
8
- return (tree) => {
9
- visit(tree, 'mdxJsxFlowElement', (node) => {
10
- if (node.name === 'meta' && Array.isArray(node.attributes)) {
11
- for (const attr of node.attributes) {
12
- if (attr.name === 'content' && typeof attr.value === 'string' && attr.value.includes(from)) {
13
- const newVal = attr.value.replace(from, to);
14
- logger.log(`rewriting: "${attr.value}" → "${newVal}"`, LogLevel.Info);
15
- attr.value = newVal;
16
- }
17
- }
18
- }
19
- });
20
- };
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
21
9
  };
22
- export default remarkReplaceMetaUrl;
23
- //# sourceMappingURL=remarkReplaceMetaUrl.js.map
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var remarkReplaceMetaUrl_exports = {};
20
+ __export(remarkReplaceMetaUrl_exports, {
21
+ default: () => remarkReplaceMetaUrl_default,
22
+ remarkReplaceMetaUrl: () => remarkReplaceMetaUrl
23
+ });
24
+ module.exports = __toCommonJS(remarkReplaceMetaUrl_exports);
25
+ var import_unist_util_visit = require("unist-util-visit");
26
+ var import_logger = require("./logger");
27
+ console.log("\u{1F996} remarkReplaceMetaUrl plugin loaded");
28
+ const remarkReplaceMetaUrl = (options) => {
29
+ const { from = "", to = "", logLevel = import_logger.LogLevel.Silent } = options ?? {};
30
+ const logger = new import_logger.Logger((0, import_logger.resolveLogLevel)(options?.logLevel), "remarkReplaceMetaUrl");
31
+ logger.log(`initialized: replacing "${from}" \u2192 "${to}"`);
32
+ return (tree) => {
33
+ (0, import_unist_util_visit.visit)(tree, "mdxJsxFlowElement", (node) => {
34
+ if (node.name === "meta" && Array.isArray(node.attributes)) {
35
+ for (const attr of node.attributes) {
36
+ if (attr.name === "content" && typeof attr.value === "string" && attr.value.includes(from)) {
37
+ const newVal = attr.value.replace(from, to);
38
+ logger.log(`rewriting: "${attr.value}" \u2192 "${newVal}"`, import_logger.LogLevel.Info);
39
+ attr.value = newVal;
40
+ }
41
+ }
42
+ }
43
+ });
44
+ };
45
+ };
46
+ var remarkReplaceMetaUrl_default = remarkReplaceMetaUrl;
47
+ // Annotate the CommonJS export names for ESM import in node:
48
+ 0 && (module.exports = {
49
+ remarkReplaceMetaUrl
50
+ });
51
+ //# sourceMappingURL=remarkReplaceMetaUrl.js.map
@@ -1 +1,7 @@
1
- {"version":3,"file":"remarkReplaceMetaUrl.js","sourceRoot":"","sources":["../../../src/docusaurus-plugins/remarkReplaceMetaUrl.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAExC,OAAO,EAAC,MAAM,EAAE,QAAQ,EAAE,eAAe,EAAC,MAAM,UAAU,CAAA;AAE1D,OAAO,CAAC,GAAG,CAAC,uCAAuC,CAAC,CAAA;AAQpD,MAAM,CAAC,MAAM,oBAAoB,GAA4B,CA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plugin } from 'unified'\r\nimport { visit } from 'unist-util-visit'\r\nimport { Root } from 'mdast'\r\nimport {Logger, LogLevel, resolveLogLevel} from './logger'\r\n\r\nconsole.log(\"\uD83E\uDD96 remarkReplaceMetaUrl plugin loaded\")\r\n\r\ninterface Options {\r\n from: string\r\n to: string\r\n logLevel?: LogLevel\r\n}\r\n\r\nexport const remarkReplaceMetaUrl: Plugin<[Options], Root> = (options?: Options) => {\r\n const { from = '', to = '', logLevel = LogLevel.Silent } = options ?? {}\r\n const logger = new Logger(resolveLogLevel(options?.logLevel), 'remarkReplaceMetaUrl')\r\n\r\n logger.log(`initialized: replacing \"${from}\" \u2192 \"${to}\"`)\r\n\r\n return (tree: Root) => {\r\n visit(tree, 'mdxJsxFlowElement', (node: any) => {\r\n if (node.name === 'meta' && Array.isArray(node.attributes)) {\r\n for (const attr of node.attributes) {\r\n if (attr.name === 'content' && typeof attr.value === 'string' && attr.value.includes(from)) {\r\n const newVal = attr.value.replace(from, to)\r\n logger.log(`rewriting: \"${attr.value}\" \u2192 \"${newVal}\"`, LogLevel.Info)\r\n attr.value = newVal\r\n }\r\n }\r\n }\r\n })\r\n }\r\n}\r\n\r\nexport default remarkReplaceMetaUrl\r\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,8BAAsB;AAEtB,oBAAgD;AAEhD,QAAQ,IAAI,8CAAuC;AAQ5C,MAAM,uBAAgD,CAAC,YAAsB;AAChF,QAAM,EAAE,OAAO,IAAI,KAAK,IAAI,WAAW,uBAAS,OAAO,IAAI,WAAW,CAAC;AACvE,QAAM,SAAS,IAAI,yBAAO,+BAAgB,SAAS,QAAQ,GAAG,sBAAsB;AAEpF,SAAO,IAAI,2BAA2B,IAAI,aAAQ,EAAE,GAAG;AAEvD,SAAO,CAAC,SAAe;AACnB,uCAAM,MAAM,qBAAqB,CAAC,SAAc;AAC5C,UAAI,KAAK,SAAS,UAAU,MAAM,QAAQ,KAAK,UAAU,GAAG;AACxD,mBAAW,QAAQ,KAAK,YAAY;AAChC,cAAI,KAAK,SAAS,aAAa,OAAO,KAAK,UAAU,YAAY,KAAK,MAAM,SAAS,IAAI,GAAG;AACxF,kBAAM,SAAS,KAAK,MAAM,QAAQ,MAAM,EAAE;AAC1C,mBAAO,IAAI,eAAe,KAAK,KAAK,aAAQ,MAAM,KAAK,uBAAS,IAAI;AACpE,iBAAK,QAAQ;AAAA,UACjB;AAAA,QACJ;AAAA,MACJ;AAAA,IACJ,CAAC;AAAA,EACL;AACJ;AAEA,IAAO,+BAAQ;",
6
+ "names": []
7
+ }
@@ -1,48 +1,80 @@
1
- import { visit } from 'unist-util-visit';
2
- import { Logger, LogLevel, resolveLogLevel } from './logger';
3
- console.log("🦖 remarkScopedPath plugin module loaded");
4
- export const remarkScopedPath = (options) => {
5
- const { mappings = [], logLevel = LogLevel.Silent } = options ?? {};
6
- const logger = new Logger(resolveLogLevel(options?.logLevel), 'remarkScopedPath');
7
- logger.log(`initialized with ${mappings.length} mappings`);
8
- return (tree, file) => {
9
- const filePath = file?.path || file?.history?.slice(-1)[0] || 'unknown';
10
- logger.log(`processing file: ${filePath}`, LogLevel.Debug);
11
- const rewrite = (val, from, to, ctx) => {
12
- if (val.startsWith(from)) {
13
- const newVal = val.replace(from, to);
14
- logger.log(`🔄 ${ctx} ${val} ${newVal}`, LogLevel.Info);
15
- return newVal;
16
- }
17
- return val;
18
- };
19
- visit(tree, 'image', (node) => {
20
- for (const { from, to } of mappings)
21
- node.url = rewrite(node.url, from, to, 'img');
22
- });
23
- visit(tree, 'link', (node) => {
24
- for (const { from, to } of mappings)
25
- node.url = rewrite(node.url, from, to, 'link');
26
- });
27
- visit(tree, 'mdxJsxFlowElement', (node) => {
28
- node.attributes?.forEach(attr => {
29
- if (attr.type === 'mdxJsxAttribute' && typeof attr.value === 'string') {
30
- for (const { from, to } of mappings)
31
- attr.value = rewrite(attr.value, from, to, `jsx <${node.name}> ${attr.name}:`);
32
- }
33
- });
34
- });
35
- visit(tree, 'mdxjsEsm', (node) => {
36
- for (const { from, to } of mappings) {
37
- const re = new RegExp(`(['"])${from}/`, 'g');
38
- const newVal = node.value.replace(re, `$1${to}/`);
39
- if (newVal !== node.value) {
40
- logger.log(`esm rewrite (${from} → ${to}):\n--- before ---\n${node.value}\n--- after ---\n${newVal}`, LogLevel.Info);
41
- node.value = newVal;
42
- }
43
- }
44
- });
45
- logger.log(` `, LogLevel.Debug);
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var remarkScopedPath_exports = {};
20
+ __export(remarkScopedPath_exports, {
21
+ remarkScopedPath: () => remarkScopedPath
22
+ });
23
+ module.exports = __toCommonJS(remarkScopedPath_exports);
24
+ var import_unist_util_visit = require("unist-util-visit");
25
+ var import_logger = require("./logger");
26
+ console.log("\u{1F996} remarkScopedPath plugin module loaded");
27
+ const remarkScopedPath = (options) => {
28
+ const { mappings = [], logLevel = import_logger.LogLevel.Silent } = options ?? {};
29
+ const logger = new import_logger.Logger((0, import_logger.resolveLogLevel)(options?.logLevel), "remarkScopedPath");
30
+ logger.log(`initialized with ${mappings.length} mappings`);
31
+ return (tree, file) => {
32
+ const filePath = file?.path || file?.history?.slice(-1)[0] || "unknown";
33
+ logger.log(`processing file: ${filePath}`, import_logger.LogLevel.Debug);
34
+ const rewrite = (val, from, to, ctx) => {
35
+ if (val.startsWith(from)) {
36
+ const newVal = val.replace(from, to);
37
+ logger.log(`\u{1F504} ${ctx} ${val} \u2192 ${newVal}`, import_logger.LogLevel.Info);
38
+ return newVal;
39
+ }
40
+ return val;
46
41
  };
42
+ (0, import_unist_util_visit.visit)(tree, "image", (node) => {
43
+ for (const { from, to } of mappings) node.url = rewrite(node.url, from, to, "img");
44
+ });
45
+ (0, import_unist_util_visit.visit)(tree, "link", (node) => {
46
+ for (const { from, to } of mappings) node.url = rewrite(node.url, from, to, "link");
47
+ });
48
+ (0, import_unist_util_visit.visit)(tree, "mdxJsxFlowElement", (node) => {
49
+ node.attributes?.forEach((attr) => {
50
+ if (attr.type === "mdxJsxAttribute" && typeof attr.value === "string") {
51
+ for (const { from, to } of mappings)
52
+ attr.value = rewrite(attr.value, from, to, `jsx <${node.name}> ${attr.name}:`);
53
+ }
54
+ });
55
+ });
56
+ (0, import_unist_util_visit.visit)(tree, "mdxjsEsm", (node) => {
57
+ for (const { from, to } of mappings) {
58
+ const re = new RegExp(`(['"])${from}/`, "g");
59
+ const newVal = node.value.replace(re, `$1${to}/`);
60
+ if (newVal !== node.value) {
61
+ logger.log(
62
+ `esm rewrite (${from} \u2192 ${to}):
63
+ --- before ---
64
+ ${node.value}
65
+ --- after ---
66
+ ${newVal}`,
67
+ import_logger.LogLevel.Info
68
+ );
69
+ node.value = newVal;
70
+ }
71
+ }
72
+ });
73
+ logger.log(` `, import_logger.LogLevel.Debug);
74
+ };
47
75
  };
48
- //# sourceMappingURL=remarkScopedPath.js.map
76
+ // Annotate the CommonJS export names for ESM import in node:
77
+ 0 && (module.exports = {
78
+ remarkScopedPath
79
+ });
80
+ //# sourceMappingURL=remarkScopedPath.js.map