@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.
- package/dist/src/components/Alert/Alert.js +51 -6
- package/dist/src/components/Alert/Alert.js.map +7 -1
- package/dist/src/components/Alert/index.js +29 -2
- package/dist/src/components/Alert/index.js.map +7 -1
- package/dist/src/components/CodeBlock/CodeBlock.js +53 -7
- package/dist/src/components/CodeBlock/CodeBlock.js.map +7 -1
- package/dist/src/components/CodeBlock/index.js +29 -2
- package/dist/src/components/CodeBlock/index.js.map +7 -1
- package/dist/src/components/Common/Common.js +59 -16
- package/dist/src/components/Common/Common.js.map +7 -1
- package/dist/src/components/Common/Logos.d.ts +6 -0
- package/dist/src/components/Common/Logos.d.ts.map +1 -0
- package/dist/src/components/Common/Logos.js +93 -0
- package/dist/src/components/Common/Logos.js.map +7 -0
- package/dist/src/components/Common/index.d.ts +1 -0
- package/dist/src/components/Common/index.d.ts.map +1 -1
- package/dist/src/components/Common/index.js +25 -2
- package/dist/src/components/Common/index.js.map +7 -1
- package/dist/src/components/NetFoundry/Divider/Divider.js +46 -5
- package/dist/src/components/NetFoundry/Divider/Divider.js.map +7 -1
- package/dist/src/components/NetFoundry/Divider/index.js +23 -2
- package/dist/src/components/NetFoundry/Divider/index.js.map +7 -1
- package/dist/src/components/NetFoundry/index.js +23 -2
- package/dist/src/components/NetFoundry/index.js.map +7 -1
- package/dist/src/components/NetFoundryFooter/NetFoundryFooter.d.ts +2 -21
- package/dist/src/components/NetFoundryFooter/NetFoundryFooter.d.ts.map +1 -1
- package/dist/src/components/NetFoundryFooter/NetFoundryFooter.js +115 -58
- package/dist/src/components/NetFoundryFooter/NetFoundryFooter.js.map +7 -1
- package/dist/src/components/NetFoundryFooter/defaults.js +50 -23
- package/dist/src/components/NetFoundryFooter/defaults.js.map +7 -1
- package/dist/src/components/NetFoundryFooter/index.js +23 -2
- package/dist/src/components/NetFoundryFooter/index.js.map +7 -1
- package/dist/src/components/NetFoundryFooter/types.d.ts +27 -0
- package/dist/src/components/NetFoundryFooter/types.d.ts.map +1 -0
- package/dist/src/components/NetFoundryFooter/types.js +53 -0
- package/dist/src/components/NetFoundryFooter/types.js.map +7 -0
- package/dist/src/components/NetFoundryHighlight/NetFoundryHighlight.js +32 -5
- package/dist/src/components/NetFoundryHighlight/NetFoundryHighlight.js.map +7 -1
- package/dist/src/components/NetFoundryHighlight/index.js +29 -2
- package/dist/src/components/NetFoundryHighlight/index.js.map +7 -1
- package/dist/src/components/NetFoundryHorizontalSection/NetFoundryHorizontalSection.js +52 -7
- package/dist/src/components/NetFoundryHorizontalSection/NetFoundryHorizontalSection.js.map +7 -1
- package/dist/src/components/NetFoundryHorizontalSection/index.js +29 -2
- package/dist/src/components/NetFoundryHorizontalSection/index.js.map +7 -1
- package/dist/src/components/NetFoundryLayout/NetFoundryLayout.js +111 -34
- package/dist/src/components/NetFoundryLayout/NetFoundryLayout.js.map +7 -1
- package/dist/src/components/NetFoundryLayout/index.js +23 -2
- package/dist/src/components/NetFoundryLayout/index.js.map +7 -1
- package/dist/src/components/NetFoundryNavbarItems/NetFoundryNavbarItems.js +40 -13
- package/dist/src/components/NetFoundryNavbarItems/NetFoundryNavbarItems.js.map +7 -1
- package/dist/src/components/NetFoundryNavbarItems/index.js +29 -2
- package/dist/src/components/NetFoundryNavbarItems/index.js.map +7 -1
- package/dist/src/components/OsTabs/OsTabs.js +53 -17
- package/dist/src/components/OsTabs/OsTabs.js.map +7 -1
- package/dist/src/components/OsTabs/index.js +29 -2
- package/dist/src/components/OsTabs/index.js.map +7 -1
- package/dist/src/components/ProductSearch/ProductSearch.js +243 -122
- package/dist/src/components/ProductSearch/ProductSearch.js.map +7 -1
- package/dist/src/components/ProductSearch/index.js +42 -4
- package/dist/src/components/ProductSearch/index.js.map +7 -1
- package/dist/src/components/StarUs/StarUs.js +45 -6
- package/dist/src/components/StarUs/StarUs.js.map +7 -1
- package/dist/src/components/StarUs/index.js +39 -2
- package/dist/src/components/StarUs/index.js.map +7 -1
- package/dist/src/components/index.js +45 -13
- package/dist/src/components/index.js.map +7 -1
- package/dist/src/config.d.ts +9 -0
- package/dist/src/config.d.ts.map +1 -0
- package/dist/src/config.js +34 -0
- package/dist/src/config.js.map +7 -0
- package/dist/src/css-modules.d.js +2 -0
- package/dist/src/css-modules.d.js.map +7 -0
- package/dist/src/docusaurus-envhelper.js +111 -64
- package/dist/src/docusaurus-envhelper.js.map +7 -1
- package/dist/src/docusaurus-plugins/index.js +35 -8
- package/dist/src/docusaurus-plugins/index.js.map +7 -1
- package/dist/src/docusaurus-plugins/logger.js +66 -38
- package/dist/src/docusaurus-plugins/logger.js.map +7 -1
- package/dist/src/docusaurus-plugins/remarkCodeSections.js +127 -94
- package/dist/src/docusaurus-plugins/remarkCodeSections.js.map +7 -1
- package/dist/src/docusaurus-plugins/remarkReplaceMetaUrl.js +50 -22
- package/dist/src/docusaurus-plugins/remarkReplaceMetaUrl.js.map +7 -1
- package/dist/src/docusaurus-plugins/remarkScopedPath.js +78 -46
- package/dist/src/docusaurus-plugins/remarkScopedPath.js.map +7 -1
- package/dist/src/docusaurus-plugins/remarkYamlTable.js +84 -49
- package/dist/src/docusaurus-plugins/remarkYamlTable.js.map +7 -1
- package/dist/src/docusaurus-plugins/remarkYouTube.js +65 -42
- package/dist/src/docusaurus-plugins/remarkYouTube.js.map +7 -1
- package/dist/src/docusaurus-plugins/timedPlugin.js +42 -15
- package/dist/src/docusaurus-plugins/timedPlugin.js.map +7 -1
- package/dist/src/docusaurus.d.js +2 -0
- package/dist/src/docusaurus.d.js.map +7 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +63 -31
- package/dist/src/index.js.map +7 -1
- package/dist/src/node.js +23 -7
- package/dist/src/node.js.map +7 -1
- package/dist/src/options.d.ts +7 -0
- package/dist/src/options.d.ts.map +1 -1
- package/dist/src/options.js +17 -2
- package/dist/src/options.js.map +7 -1
- package/dist/src/plugins.js +23 -7
- package/dist/src/plugins.js.map +7 -1
- package/dist/src/ui.js +25 -8
- package/dist/src/ui.js.map +7 -1
- package/dist/src/version.js +29 -2
- package/dist/src/version.js.map +7 -1
- package/dist/theme/BlogPostPage/Metadata.js +35 -2
- package/dist/theme/BlogPostPage/Metadata.js.map +7 -1
- package/dist/theme/BlogPostPage/StructuredData.js +35 -2
- package/dist/theme/BlogPostPage/StructuredData.js.map +7 -1
- package/dist/theme/BlogPostPage/index.js +98 -24
- package/dist/theme/BlogPostPage/index.js.map +7 -1
- package/dist/theme/DocSearch/index.js +95 -27
- package/dist/theme/DocSearch/index.js.map +7 -1
- package/dist/theme/Layout/index.js +81 -35
- package/dist/theme/Layout/index.js.map +7 -1
- package/dist/theme/Navbar/Content/index.js +69 -26
- package/dist/theme/Navbar/Content/index.js.map +7 -1
- package/dist/theme/Navbar/Logo/index.d.ts.map +1 -1
- package/dist/theme/Navbar/Logo/index.js +87 -42
- package/dist/theme/Navbar/Logo/index.js.map +7 -1
- package/dist/theme/OsTabs/index.js +50 -19
- package/dist/theme/OsTabs/index.js.map +7 -1
- package/dist/theme/SearchBar/index.js +89 -34
- package/dist/theme/SearchBar/index.js.map +7 -1
- package/package.json +11 -25
- package/css/layout.css +0 -14
- package/css/legacy.css +0 -2313
- package/css/tabs-v1-gradient.css +0 -92
- package/css/tabs-v2-glass.css +0 -116
- package/css/tabs-v3-minimal.css +0 -86
- package/css/tabs-v4-segmented.css +0 -85
- package/css/tabs-v5-neon.css +0 -99
- package/css/tabs-v6-neumorphic.css +0 -89
- package/css/tabs-v7-brutalist.css +0 -81
- package/css/tabs-v8-float.css +0 -114
- package/css/tabs-v9-line.css +0 -104
- package/css/theme.css +0 -72
- package/css/vars-dark.css +0 -7
- package/css/vars.css +0 -8
|
@@ -1,41 +1,69 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
|
|
60
|
+
}
|
|
61
|
+
return 0 /* Silent */;
|
|
40
62
|
}
|
|
41
|
-
|
|
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
|
-
{
|
|
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,E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-
|
|
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
|
-
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
|
-
|
|
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
|
-
{
|
|
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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oB,EAAE;AAAA,YACtE,UAAU,CAAC;AAAA,UACf;AACA,kBAAQ,SAAS;AAAA,YACb,EAAE,MAAM,aAAa,UAAU,CAAC,EAAE,MAAM,UAAU,UAAU,CAAC,EAAE,MAAM,QAAQ,OAAO,UAAU,CAAC,EAAE,CAAC,EAAE;AAAA,YACpG,EAAE,MAAM,QAAQ,MAAM,OAAO,KAAK,KAAK,EAAE;AAAA,UAC7C;AACA,qBAAW,SAAS,KAAK,OAAO;AAAA,QACpC;AAEA,YAAI,SAAS;AACT,gBAAM,aAAa;AAAA,YACf,MAAM;AAAA,YACN,MAAM,EAAE,OAAO,OAAO,aAAa,EAAE,WAAW,uBAAuB,EAAE;AAAA,YACzE,UAAU,CAAC;AAAA,UACf;AACA,qBAAW,SAAS;AAAA,YAChB,EAAE,MAAM,aAAa,UAAU,CAAC,EAAE,MAAM,UAAU,UAAU,CAAC,EAAE,MAAM,QAAQ,OAAO,WAAW,CAAC,EAAE,CAAC,EAAE;AAAA,YACrG,EAAE,MAAM,QAAQ,MAAM,cAAc,OAAO,QAAQ,KAAK,EAAE;AAAA,UAC9D;AACA,qBAAW,SAAS,KAAK,UAAU;AAAA,QACvC;AAEA,eAAO,SAAS,OAAO,OAAO,GAAG,UAAU;AAAA,MAC/C;AAAA,IACJ,CAAC;AAAA,EACL;AACJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,23 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
23
|
-
|
|
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
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/docusaurus-plugins/remarkReplaceMetaUrl.ts"],
|
|
4
|
+
"sourcesContent": ["import { 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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
|
|
76
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
77
|
+
0 && (module.exports = {
|
|
78
|
+
remarkScopedPath
|
|
79
|
+
});
|
|
80
|
+
//# sourceMappingURL=remarkScopedPath.js.map
|