@mintlify/common 1.0.105 → 1.0.107
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/mdx/getMDXOptions.d.ts +5 -2
- package/dist/mdx/getMDXOptions.js +14 -13
- package/dist/mdx/lib/remark-utils.d.ts +0 -7
- package/dist/mdx/lib/remark-utils.js +0 -118
- package/dist/mdx/plugins/rehype/index.d.ts +1 -3
- package/dist/mdx/plugins/rehype/index.js +1 -3
- package/dist/mdx/plugins/rehype/rehypeMdxExtractEndpoint/index.d.ts +4 -0
- package/dist/mdx/plugins/rehype/{rehypeMdxInjectEndpoint → rehypeMdxExtractEndpoint}/index.js +2 -5
- package/dist/mdx/plugins/rehype/rehypeMdxExtractExamples.d.ts +2 -1
- package/dist/mdx/plugins/rehype/rehypeMdxExtractExamples.js +6 -3
- package/dist/mdx/plugins/rehype/rehypeMdxRemoveUnknownJsx/index.d.ts +1 -3
- package/dist/mdx/plugins/rehype/rehypeMdxRemoveUnknownJsx/index.js +2 -3
- package/dist/mdx/plugins/remark/index.d.ts +1 -1
- package/dist/mdx/plugins/remark/index.js +1 -1
- package/dist/mdx/plugins/remark/remarkExtractTableOfContents.d.ts +1 -0
- package/dist/mdx/plugins/remark/{remarkTableOfContents.js → remarkExtractTableOfContents.js} +5 -3
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/mdx/MdxExtracts.d.ts +11 -0
- package/dist/types/mdx/MdxExtracts.js +1 -0
- package/dist/types/mdx/TableOfContentsSectionType.d.ts +6 -0
- package/dist/types/mdx/TableOfContentsSectionType.js +1 -0
- package/dist/types/mdx/index.d.ts +2 -0
- package/dist/types/mdx/index.js +2 -0
- package/package.json +5 -5
- package/dist/mdx/plugins/rehype/rehypeLayouts.d.ts +0 -1
- package/dist/mdx/plugins/rehype/rehypeLayouts.js +0 -133
- package/dist/mdx/plugins/rehype/rehypeListRoles.d.ts +0 -1
- package/dist/mdx/plugins/rehype/rehypeListRoles.js +0 -10
- package/dist/mdx/plugins/rehype/rehypeMdxInjectEndpoint/index.d.ts +0 -3
- package/dist/mdx/plugins/remark/remarkTableOfContents.d.ts +0 -1
- /package/dist/mdx/plugins/rehype/{rehypeMdxInjectEndpoint → rehypeMdxExtractEndpoint}/findParentSchema.d.ts +0 -0
- /package/dist/mdx/plugins/rehype/{rehypeMdxInjectEndpoint → rehypeMdxExtractEndpoint}/findParentSchema.js +0 -0
- /package/dist/mdx/plugins/rehype/{rehypeMdxInjectEndpoint → rehypeMdxExtractEndpoint}/insertSchema.d.ts +0 -0
- /package/dist/mdx/plugins/rehype/{rehypeMdxInjectEndpoint → rehypeMdxExtractEndpoint}/insertSchema.js +0 -0
- /package/dist/mdx/plugins/rehype/{rehypeMdxInjectEndpoint → rehypeMdxExtractEndpoint}/parsers.d.ts +0 -0
- /package/dist/mdx/plugins/rehype/{rehypeMdxInjectEndpoint → rehypeMdxExtractEndpoint}/parsers.js +0 -0
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import type { SerializeOptions } from '@mintlify/mdx';
|
|
1
2
|
import type { MintConfig, PageMetaTags } from '@mintlify/models';
|
|
2
3
|
import type { Root } from 'remark-mdx';
|
|
3
4
|
import type { Pluggable } from 'unified';
|
|
5
|
+
import { MdxExtracts } from '../types/mdx/MdxExtracts.js';
|
|
4
6
|
type MDXOptionsData = {
|
|
5
7
|
snippetTreeMap: Record<string, Root>;
|
|
6
8
|
allowedComponents: string[];
|
|
@@ -8,9 +10,10 @@ type MDXOptionsData = {
|
|
|
8
10
|
mintConfig?: MintConfig;
|
|
9
11
|
subdomain?: string;
|
|
10
12
|
};
|
|
11
|
-
export declare const getMDXOptions: ({ data, remarkPlugins, rehypePlugins, }: {
|
|
13
|
+
export declare const getMDXOptions: ({ data, remarkPlugins, rehypePlugins, mdxExtracts, }: {
|
|
12
14
|
data: MDXOptionsData;
|
|
13
15
|
remarkPlugins?: Pluggable[] | undefined;
|
|
14
16
|
rehypePlugins?: Pluggable[] | undefined;
|
|
15
|
-
|
|
17
|
+
mdxExtracts?: MdxExtracts | undefined;
|
|
18
|
+
}) => SerializeOptions['mdxOptions'];
|
|
16
19
|
export {};
|
|
@@ -1,30 +1,31 @@
|
|
|
1
|
-
import { rehypeCodeBlocks,
|
|
1
|
+
import { rehypeCodeBlocks, rehypeMdxExtractExamples, rehypeMdxExtractEndpoint, rehypeRawComponents, rehypeZoomImages, remarkFrames, remarkMdxInjectSnippets, remarkMdxRemoveUnusedVariables, remarkRemoveImports, remarkExtractTableOfContents, } from './plugins/index.js';
|
|
2
2
|
import rehypeMdxRemoveUnknownJsx from './plugins/rehype/rehypeMdxRemoveUnknownJsx/index.js';
|
|
3
3
|
import { remarkMermaid } from './plugins/remark/remarkMermaid.js';
|
|
4
|
-
|
|
4
|
+
// avoid running extractors unnecessarily
|
|
5
|
+
const rehypeExtractors = (mdxExtracts, data) => {
|
|
6
|
+
if (!mdxExtracts)
|
|
7
|
+
return [];
|
|
8
|
+
return [
|
|
9
|
+
[rehypeMdxExtractExamples, mdxExtracts],
|
|
10
|
+
[rehypeMdxExtractEndpoint, data.pageMetadata, data.mintConfig, mdxExtracts],
|
|
11
|
+
];
|
|
12
|
+
};
|
|
13
|
+
export const getMDXOptions = ({ data, remarkPlugins = [], rehypePlugins = [], mdxExtracts, }) => {
|
|
5
14
|
return {
|
|
6
15
|
remarkPlugins: [
|
|
7
16
|
[remarkMdxInjectSnippets, data.snippetTreeMap],
|
|
17
|
+
[remarkExtractTableOfContents, mdxExtracts],
|
|
8
18
|
remarkMdxRemoveUnusedVariables,
|
|
9
19
|
remarkFrames,
|
|
10
|
-
remarkTableOfContents,
|
|
11
20
|
remarkRemoveImports,
|
|
12
21
|
remarkMermaid,
|
|
13
22
|
...remarkPlugins,
|
|
14
23
|
],
|
|
15
24
|
rehypePlugins: [
|
|
16
|
-
[
|
|
17
|
-
rehypeMdxRemoveUnknownJsx,
|
|
18
|
-
{
|
|
19
|
-
allowedComponents: data.allowedComponents,
|
|
20
|
-
},
|
|
21
|
-
],
|
|
25
|
+
[rehypeMdxRemoveUnknownJsx, data.allowedComponents],
|
|
22
26
|
rehypeCodeBlocks,
|
|
23
|
-
|
|
24
|
-
rehypeMdxExtractExamples,
|
|
25
|
-
[rehypeMdxInjectEndpoint, data.pageMetadata, data.mintConfig || {}],
|
|
27
|
+
...rehypeExtractors(mdxExtracts, data),
|
|
26
28
|
rehypeRawComponents,
|
|
27
|
-
rehypeLayouts,
|
|
28
29
|
rehypeZoomImages,
|
|
29
30
|
...rehypePlugins,
|
|
30
31
|
],
|
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
export function addImportString(tree: any, jsx: any): void;
|
|
2
|
-
export function addImport(tree: any, mod: any, name: any): string;
|
|
3
|
-
export function addDefaultImport(tree: any, mod: any, name: any): string;
|
|
4
|
-
export function addExport(tree: any, name: any, value: any): void;
|
|
5
|
-
export function normalizeTokens(tokens: any): any[][];
|
|
6
|
-
export function simplifyToken(token: any): string | any[];
|
|
7
1
|
export function createMdxJsxAttribute(key: any, value: any): {
|
|
8
2
|
type: string;
|
|
9
3
|
name: any;
|
|
10
4
|
value: any;
|
|
11
5
|
};
|
|
12
6
|
export function toMdxJsxFlowElement(input: any): import("mdast").Content | undefined;
|
|
13
|
-
export function getEsmNode(input: any): import("mdast").Content | undefined;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import * as acorn from 'acorn';
|
|
2
2
|
import { fromMarkdown } from 'mdast-util-from-markdown';
|
|
3
3
|
import { mdxJsxFromMarkdown } from 'mdast-util-mdx-jsx';
|
|
4
|
-
import { mdxjsEsmFromMarkdown } from 'mdast-util-mdxjs-esm';
|
|
5
4
|
import { mdxJsx } from 'micromark-extension-mdx-jsx';
|
|
6
|
-
import { mdxjsEsm } from 'micromark-extension-mdxjs-esm';
|
|
7
5
|
export const createMdxJsxAttribute = (key, value) => {
|
|
8
6
|
return {
|
|
9
7
|
type: 'mdxJsxAttribute',
|
|
@@ -18,119 +16,3 @@ export const toMdxJsxFlowElement = (input) => {
|
|
|
18
16
|
});
|
|
19
17
|
return tree.children[0];
|
|
20
18
|
};
|
|
21
|
-
export const getEsmNode = (input) => {
|
|
22
|
-
const tree = fromMarkdown(input, {
|
|
23
|
-
extensions: [mdxjsEsm({ acorn, addResult: true })],
|
|
24
|
-
mdastExtensions: [mdxjsEsmFromMarkdown],
|
|
25
|
-
});
|
|
26
|
-
return tree.children[0];
|
|
27
|
-
};
|
|
28
|
-
export function addImportString(tree, jsx) {
|
|
29
|
-
tree.children.unshift(getEsmNode(jsx));
|
|
30
|
-
}
|
|
31
|
-
export function addImport(tree, mod, name) {
|
|
32
|
-
const jsx = `import { ${name} as _${name} } from '${mod}'`;
|
|
33
|
-
tree.children.unshift(getEsmNode(jsx));
|
|
34
|
-
return `_${name}`;
|
|
35
|
-
}
|
|
36
|
-
export function addDefaultImport(tree, mod, name) {
|
|
37
|
-
const jsx = `import _${name} from '${mod}'`;
|
|
38
|
-
tree.children.unshift(getEsmNode(jsx));
|
|
39
|
-
return `_${name}`;
|
|
40
|
-
}
|
|
41
|
-
export function addExport(tree, name, value) {
|
|
42
|
-
const jsx = `export const ${name} = ${JSON.stringify(value)}`;
|
|
43
|
-
tree.children.push(getEsmNode(jsx));
|
|
44
|
-
}
|
|
45
|
-
const newlineRe = /\r\n|\r|\n/;
|
|
46
|
-
// Empty lines need to contain a single empty token, denoted with { empty: true }
|
|
47
|
-
function normalizeEmptyLines(line) {
|
|
48
|
-
if (line.length === 0) {
|
|
49
|
-
line.push({
|
|
50
|
-
types: ['plain'],
|
|
51
|
-
content: '',
|
|
52
|
-
empty: true,
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
else if (line.length === 1 && line[0].content === '') {
|
|
56
|
-
line[0].empty = true;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
function appendTypes(types, add) {
|
|
60
|
-
const typesSize = types.length;
|
|
61
|
-
if (typesSize > 0 && types[typesSize - 1] === add) {
|
|
62
|
-
return types;
|
|
63
|
-
}
|
|
64
|
-
return types.concat(add);
|
|
65
|
-
}
|
|
66
|
-
// Takes an array of Prism's tokens and groups them by line, turning plain
|
|
67
|
-
// strings into tokens as well. Tokens can become recursive in some cases,
|
|
68
|
-
// which means that their types are concatenated. Plain-string tokens however
|
|
69
|
-
// are always of type "plain".
|
|
70
|
-
// This is not recursive to avoid exceeding the call-stack limit, since it's unclear
|
|
71
|
-
// how nested Prism's tokens can become
|
|
72
|
-
export function normalizeTokens(tokens) {
|
|
73
|
-
const typeArrStack = [[]];
|
|
74
|
-
const tokenArrStack = [tokens];
|
|
75
|
-
const tokenArrIndexStack = [0];
|
|
76
|
-
const tokenArrSizeStack = [tokens.length];
|
|
77
|
-
let i = 0;
|
|
78
|
-
let stackIndex = 0;
|
|
79
|
-
let currentLine = [];
|
|
80
|
-
const acc = [currentLine];
|
|
81
|
-
while (stackIndex > -1) {
|
|
82
|
-
while ((i = tokenArrIndexStack[stackIndex]++) < tokenArrSizeStack[stackIndex]) {
|
|
83
|
-
let content;
|
|
84
|
-
let types = typeArrStack[stackIndex];
|
|
85
|
-
const tokenArr = tokenArrStack[stackIndex];
|
|
86
|
-
const token = tokenArr[i];
|
|
87
|
-
// Determine content and append type to types if necessary
|
|
88
|
-
if (typeof token === 'string') {
|
|
89
|
-
types = stackIndex > 0 ? types : ['plain'];
|
|
90
|
-
content = token;
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
types = appendTypes(types, token.type);
|
|
94
|
-
if (token.alias) {
|
|
95
|
-
types = appendTypes(types, token.alias);
|
|
96
|
-
}
|
|
97
|
-
content = token.content;
|
|
98
|
-
}
|
|
99
|
-
// If token.content is an array, increase the stack depth and repeat this while-loop
|
|
100
|
-
if (typeof content !== 'string') {
|
|
101
|
-
stackIndex++;
|
|
102
|
-
typeArrStack.push(types);
|
|
103
|
-
tokenArrStack.push(content);
|
|
104
|
-
tokenArrIndexStack.push(0);
|
|
105
|
-
tokenArrSizeStack.push(content.length);
|
|
106
|
-
continue;
|
|
107
|
-
}
|
|
108
|
-
// Split by newlines
|
|
109
|
-
const splitByNewlines = content.split(newlineRe);
|
|
110
|
-
const newlineCount = splitByNewlines.length;
|
|
111
|
-
currentLine.push({ types, content: splitByNewlines[0] });
|
|
112
|
-
// Create a new line for each string on a new line
|
|
113
|
-
for (let i = 1; i < newlineCount; i++) {
|
|
114
|
-
normalizeEmptyLines(currentLine);
|
|
115
|
-
acc.push((currentLine = []));
|
|
116
|
-
currentLine.push({ types, content: splitByNewlines[i] });
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
// Decreate the stack depth
|
|
120
|
-
stackIndex--;
|
|
121
|
-
typeArrStack.pop();
|
|
122
|
-
tokenArrStack.pop();
|
|
123
|
-
tokenArrIndexStack.pop();
|
|
124
|
-
tokenArrSizeStack.pop();
|
|
125
|
-
}
|
|
126
|
-
normalizeEmptyLines(currentLine);
|
|
127
|
-
return acc;
|
|
128
|
-
}
|
|
129
|
-
export function simplifyToken(token) {
|
|
130
|
-
if (typeof token === 'string')
|
|
131
|
-
return token;
|
|
132
|
-
return [
|
|
133
|
-
token.type,
|
|
134
|
-
Array.isArray(token.content) ? token.content.map(simplifyToken) : token.content,
|
|
135
|
-
];
|
|
136
|
-
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './rehypeMdxExtractEndpoint/index.js';
|
|
2
2
|
export * from './rehypeMdxRemoveUnknownJsx/index.js';
|
|
3
3
|
export * from './rehypeMdxExtractExamples.js';
|
|
4
4
|
export * from './rehypeCodeBlocks.js';
|
|
5
|
-
export * from './rehypeLayouts.js';
|
|
6
|
-
export * from './rehypeListRoles.js';
|
|
7
5
|
export * from './rehypeRawComponents.js';
|
|
8
6
|
export * from './rehypeZoomImages.js';
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './rehypeMdxExtractEndpoint/index.js';
|
|
2
2
|
export * from './rehypeMdxRemoveUnknownJsx/index.js';
|
|
3
3
|
export * from './rehypeMdxExtractExamples.js';
|
|
4
4
|
export * from './rehypeCodeBlocks.js';
|
|
5
|
-
export * from './rehypeLayouts.js';
|
|
6
|
-
export * from './rehypeListRoles.js';
|
|
7
5
|
export * from './rehypeRawComponents.js';
|
|
8
6
|
export * from './rehypeZoomImages.js';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { MintConfig } from '@mintlify/models';
|
|
2
|
+
import type { Node } from 'unist';
|
|
3
|
+
import { MdxExtracts } from '../../../../index.js';
|
|
4
|
+
export declare const rehypeMdxExtractEndpoint: (metadata: unknown, config: MintConfig | undefined, mdxExtracts: MdxExtracts) => <T extends Node<import("unist").Data>>(tree: T) => T | undefined;
|
package/dist/mdx/plugins/rehype/{rehypeMdxInjectEndpoint → rehypeMdxExtractEndpoint}/index.js
RENAMED
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
import { generateExampleFromSchema } from '@mintlify/validation';
|
|
2
2
|
import { visitParents } from 'unist-util-visit-parents';
|
|
3
3
|
import { isMdxJsxFlowElementHast } from '../../../lib/mdx-utils.js';
|
|
4
|
-
import { addExport } from '../../../lib/remark-utils.js';
|
|
5
4
|
import { findParentSchema } from './findParentSchema.js';
|
|
6
5
|
import { insertSchema } from './insertSchema.js';
|
|
7
6
|
import { parseApiString, parseAuthMethod, parseField } from './parsers.js';
|
|
8
|
-
export const
|
|
7
|
+
export const rehypeMdxExtractEndpoint = (metadata, config, mdxExtracts) => {
|
|
9
8
|
return (tree) => {
|
|
10
9
|
var _a;
|
|
11
10
|
if (!(metadata &&
|
|
12
11
|
typeof metadata === 'object' &&
|
|
13
12
|
'api' in metadata &&
|
|
14
13
|
typeof metadata.api === 'string')) {
|
|
15
|
-
addExport(tree, 'endpoint', undefined);
|
|
16
14
|
return;
|
|
17
15
|
}
|
|
18
16
|
let parseResult = undefined;
|
|
@@ -21,7 +19,6 @@ export const rehypeMdxInjectEndpoint = (metadata, config) => {
|
|
|
21
19
|
}
|
|
22
20
|
catch (_b) {
|
|
23
21
|
console.error(`error parsing api string: "${metadata.api}"`);
|
|
24
|
-
addExport(tree, 'endpoint', undefined);
|
|
25
22
|
return;
|
|
26
23
|
}
|
|
27
24
|
const { servers, path, method } = parseResult;
|
|
@@ -86,7 +83,7 @@ export const rehypeMdxInjectEndpoint = (metadata, config) => {
|
|
|
86
83
|
if (response) {
|
|
87
84
|
response.examples['example'] = { value: generateExampleFromSchema(response.schemaArray[0]) };
|
|
88
85
|
}
|
|
89
|
-
|
|
86
|
+
mdxExtracts.endpoint = endpoint;
|
|
90
87
|
return tree;
|
|
91
88
|
};
|
|
92
89
|
};
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import type { Node } from 'unist';
|
|
2
|
-
|
|
2
|
+
import type { MdxExtracts } from '../../../types/index.js';
|
|
3
|
+
export declare const rehypeMdxExtractExamples: (mdxExtracts: MdxExtracts) => <T extends Node<import("unist").Data>>(tree: T) => T;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { toHtml } from 'hast-util-to-html';
|
|
2
2
|
import { visit } from 'unist-util-visit';
|
|
3
|
-
import {
|
|
3
|
+
import { isMdxJsxFlowElementHast } from '../../lib/index.js';
|
|
4
4
|
const langFilename = (className) => {
|
|
5
5
|
switch (className) {
|
|
6
6
|
case 'language-shell':
|
|
@@ -14,7 +14,7 @@ const langFilename = (className) => {
|
|
|
14
14
|
return language.charAt(0).toUpperCase() + language.slice(1);
|
|
15
15
|
}
|
|
16
16
|
};
|
|
17
|
-
export const rehypeMdxExtractExamples = () => {
|
|
17
|
+
export const rehypeMdxExtractExamples = (mdxExtracts) => {
|
|
18
18
|
return (tree) => {
|
|
19
19
|
let request;
|
|
20
20
|
let response;
|
|
@@ -36,7 +36,10 @@ export const rehypeMdxExtractExamples = () => {
|
|
|
36
36
|
parent.children.splice(i, 1);
|
|
37
37
|
}
|
|
38
38
|
});
|
|
39
|
-
|
|
39
|
+
mdxExtracts.codeExamples = {
|
|
40
|
+
request,
|
|
41
|
+
response,
|
|
42
|
+
};
|
|
40
43
|
return tree;
|
|
41
44
|
};
|
|
42
45
|
};
|
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
import type { Node } from 'unist';
|
|
2
|
-
declare const rehypeMdxRemoveUnknownJsx: (
|
|
3
|
-
allowedComponents?: string[];
|
|
4
|
-
}) => (tree: Node) => Node<import("unist").Data>;
|
|
2
|
+
declare const rehypeMdxRemoveUnknownJsx: (allowedComponents?: string[]) => (tree: Node) => Node<import("unist").Data>;
|
|
5
3
|
export default rehypeMdxRemoveUnknownJsx;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { map } from 'unist-util-map';
|
|
2
2
|
import { findExportedNodes, isMdxJsxFlowElementHast } from '../../../lib/index.js';
|
|
3
3
|
import { createCommentNode } from './createCommentNode.js';
|
|
4
|
-
const rehypeMdxRemoveUnknownJsx = (
|
|
4
|
+
const rehypeMdxRemoveUnknownJsx = (allowedComponents) => (tree) => {
|
|
5
5
|
const exportedComponentNames = findExportedNodes(tree, 'ArrowFunctionExpression');
|
|
6
6
|
return map(tree, (node) => {
|
|
7
|
-
var _a;
|
|
8
7
|
if (isMdxJsxFlowElementHast(node)) {
|
|
9
8
|
if (node.name &&
|
|
10
|
-
!(
|
|
9
|
+
!(allowedComponents === null || allowedComponents === void 0 ? void 0 : allowedComponents.includes(node.name)) &&
|
|
11
10
|
!exportedComponentNames.includes(node.name)) {
|
|
12
11
|
return createCommentNode(node.name);
|
|
13
12
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export * from './remarkMdxInjectSnippets.js';
|
|
2
2
|
export * from './remarkFrames.js';
|
|
3
3
|
export * from './remarkRemoveImports.js';
|
|
4
|
-
export * from './
|
|
4
|
+
export * from './remarkExtractTableOfContents.js';
|
|
5
5
|
export * from './remarkMdxRemoveUnusedVariables.js';
|
|
6
6
|
export * from './remarkReplaceAllImages.js';
|
|
7
7
|
export * from './remarkMermaid.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export * from './remarkMdxInjectSnippets.js';
|
|
2
2
|
export * from './remarkFrames.js';
|
|
3
3
|
export * from './remarkRemoveImports.js';
|
|
4
|
-
export * from './
|
|
4
|
+
export * from './remarkExtractTableOfContents.js';
|
|
5
5
|
export * from './remarkMdxRemoveUnusedVariables.js';
|
|
6
6
|
export * from './remarkReplaceAllImages.js';
|
|
7
7
|
export * from './remarkMermaid.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function remarkExtractTableOfContents(mdxExtracts: any): (tree: any) => void;
|
package/dist/mdx/plugins/remark/{remarkTableOfContents.js → remarkExtractTableOfContents.js}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { slugifyWithCounter } from '@sindresorhus/slugify';
|
|
2
|
-
import {
|
|
2
|
+
import { createMdxJsxAttribute } from '../../lib/remark-utils.js';
|
|
3
3
|
const getTOCTitle = (node, i = 1, a = []) => {
|
|
4
4
|
var _a, _b;
|
|
5
5
|
if ((node.type === 'text' &&
|
|
@@ -16,7 +16,7 @@ const getTOCTitle = (node, i = 1, a = []) => {
|
|
|
16
16
|
}
|
|
17
17
|
return '';
|
|
18
18
|
};
|
|
19
|
-
export const
|
|
19
|
+
export const remarkExtractTableOfContents = (mdxExtracts) => {
|
|
20
20
|
// slugifyWithCounter adds a counter (eg. slug, slug-2, slug-3) to the end of the slug if the header
|
|
21
21
|
// already exists. No counter is added for the first occurence.
|
|
22
22
|
const slugify = slugifyWithCounter();
|
|
@@ -52,6 +52,8 @@ export const remarkTableOfContents = () => {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
-
|
|
55
|
+
if (mdxExtracts) {
|
|
56
|
+
mdxExtracts.tableOfContents = contents;
|
|
57
|
+
}
|
|
56
58
|
};
|
|
57
59
|
};
|