@mintlify/common 1.0.413 → 1.0.415

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": "@mintlify/common",
3
- "version": "1.0.413",
3
+ "version": "1.0.415",
4
4
  "description": "Commonly shared code within Mintlify",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -82,5 +82,5 @@
82
82
  "typescript": "^5.5.3",
83
83
  "vitest": "^2.0.4"
84
84
  },
85
- "gitHead": "fdde2d500bbaf25feec2259f6d32ec7da4db6d8c"
85
+ "gitHead": "0eff87abe9b52c6a27278adacffbb988cf3e2e84"
86
86
  }
@@ -1,59 +0,0 @@
1
- import { visit } from 'unist-util-visit';
2
- const exampleNames = ['RequestExample', 'ResponseExample'];
3
- const flowElementType = 'mdxJsxFlowElement';
4
- function isElement(node, key = 'type', element = 'element') {
5
- return node != undefined && node[key] === element;
6
- }
7
- function addCodeBlocks(tree) {
8
- visit(tree, (node, i, parent) => {
9
- var _a, _b;
10
- if (parent == null || i == null || !isElement(node) || !isElement(node, 'tagName', 'pre')) {
11
- return;
12
- }
13
- const code = node.children[0];
14
- if (!isElement(code, 'tagName', 'code'))
15
- return;
16
- let filename = undefined;
17
- let isExpandable = false;
18
- const isFlowElement = isElement(parent, 'type', flowElementType);
19
- const parentName = isFlowElement ? parent.name : undefined;
20
- const properties = code.type === 'element' ? Object.entries(code.properties) : [];
21
- if (parentName && exampleNames.includes(parentName)) {
22
- const parentType = parentName.slice(0, -7);
23
- filename = i === 0 ? parentType : `${parentType} ${i + 1}`;
24
- isExpandable = filename.includes('[expandable]');
25
- filename = filename.replaceAll('[expandable]', '').trim();
26
- if (!((_a = code.data) === null || _a === void 0 ? void 0 : _a.meta)) {
27
- code.data = Object.assign(Object.assign({}, code.data), { meta: filename });
28
- }
29
- }
30
- if (((_b = code.data) === null || _b === void 0 ? void 0 : _b.meta) && typeof code.data.meta === 'string') {
31
- filename = code.data.meta;
32
- isExpandable = filename.includes('[expandable]');
33
- filename = filename.replaceAll('[expandable]', '').trim();
34
- }
35
- const wrap = {
36
- type: flowElementType,
37
- name: 'CodeBlock',
38
- attributes: [
39
- { type: 'mdxJsxAttribute', name: 'filename', value: filename !== null && filename !== void 0 ? filename : '' },
40
- { type: 'mdxJsxAttribute', name: 'expandable', value: isExpandable.toString() },
41
- ...properties
42
- .filter(([_key, val]) => val != null)
43
- .map(([key, val]) => ({
44
- type: 'mdxJsxAttribute',
45
- name: key,
46
- value: Array.isArray(val) ? val.join(' ') : val === null || val === void 0 ? void 0 : val.toString(),
47
- })),
48
- ],
49
- data: { _mdxExplicitJsx: true },
50
- children: [],
51
- };
52
- wrap.children = [node];
53
- parent.children[i] = wrap;
54
- });
55
- tree.children = [...tree.children];
56
- }
57
- export function rehypeCodeBlocks() {
58
- return addCodeBlocks;
59
- }