@mintlify/common 1.0.1176 → 1.0.1178
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/plugins/remark/remarkMdxRemoveUnknownJsx/index.d.ts +1 -1
- package/dist/mdx/remark.d.ts +1 -0
- package/dist/mdx/remark.js +10 -2
- package/dist/navigation/decoratedNavTree.js +13 -2
- package/dist/navigation/decoratedNavTree.test.js +12 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Root } from 'mdast';
|
|
2
2
|
export declare const remarkMdxRemoveUnknownJsx: ({ allowlist }?: {
|
|
3
3
|
allowlist?: string[];
|
|
4
|
-
}) => (tree: Root) => Root | import("mdast
|
|
4
|
+
}) => (tree: Root) => Root | import("mdast").Link | import("mdast").Delete | import("mdast").Code | import("mdast").Text | import("mdast").Heading | import("mdast-util-mdx").MdxJsxFlowElement | import("mdast-util-mdx").MdxJsxTextElement | import("mdast").Blockquote | import("mdast").Break | import("mdast").Definition | import("mdast").Emphasis | import("mdast").FootnoteDefinition | import("mdast").FootnoteReference | import("mdast").Html | import("mdast").Image | import("mdast").ImageReference | import("mdast").InlineCode | import("mdast").LinkReference | import("mdast").List | import("mdast").ListItem | import("mdast").Paragraph | import("mdast").Strong | import("mdast").Table | import("mdast").TableCell | import("mdast").TableRow | import("mdast").ThematicBreak | import("mdast").Yaml | import("mdast-util-math").InlineMath | import("mdast-util-math").Math | import("mdast-util-mdx-expression").MdxTextExpression | import("mdast-util-mdx-expression").MdxFlowExpression | import("mdast-util-mdxjs-esm").MdxjsEsm;
|
package/dist/mdx/remark.d.ts
CHANGED
|
@@ -5,5 +5,6 @@ export declare const coreRemarkMdxPlugins: PluggableList;
|
|
|
5
5
|
export declare const coreRemark: import("unified").Processor<Root, undefined, undefined, Root, string>;
|
|
6
6
|
export declare const getAST: (str: string, filePath?: string) => Root;
|
|
7
7
|
export declare const stringifyTree: (tree: Root) => string;
|
|
8
|
+
export declare const stringifyTreeForAgents: (tree: Root) => string;
|
|
8
9
|
export declare function stripVisibilityForMarkdown(mdx: string): string;
|
|
9
10
|
export declare function transformContentForMarkdown(mdx: string, mentionOptions?: RemarkUserMentionsOptions): string;
|
package/dist/mdx/remark.js
CHANGED
|
@@ -17,6 +17,13 @@ export const coreRemarkMdxPlugins = [
|
|
|
17
17
|
remarkMath,
|
|
18
18
|
];
|
|
19
19
|
export const coreRemark = remark().use(coreRemarkMdxPlugins).freeze();
|
|
20
|
+
const agentRemarkMdxPlugins = [
|
|
21
|
+
remarkMdx,
|
|
22
|
+
[remarkGfm, { tablePipeAlign: false }],
|
|
23
|
+
[remarkFrontmatter, ['yaml', 'toml']],
|
|
24
|
+
remarkMath,
|
|
25
|
+
];
|
|
26
|
+
const agentRemark = remark().use(agentRemarkMdxPlugins).freeze();
|
|
20
27
|
export const getAST = (str, filePath) => {
|
|
21
28
|
if (isJsxOrTsx(filePath)) {
|
|
22
29
|
return getJsxEsmTree(str, filePath);
|
|
@@ -24,14 +31,15 @@ export const getAST = (str, filePath) => {
|
|
|
24
31
|
return coreRemark().parse(preprocessCustomHeadingIds(preprocessMdxFragmentCode(str)));
|
|
25
32
|
};
|
|
26
33
|
export const stringifyTree = (tree) => coreRemark().use(remarkStringify).stringify(tree);
|
|
34
|
+
export const stringifyTreeForAgents = (tree) => agentRemark().use(remarkStringify).stringify(tree);
|
|
27
35
|
export function stripVisibilityForMarkdown(mdx) {
|
|
28
36
|
const tree = getAST(mdx);
|
|
29
37
|
remarkVisibilityForMarkdown()(tree);
|
|
30
|
-
return
|
|
38
|
+
return stringifyTreeForAgents(tree);
|
|
31
39
|
}
|
|
32
40
|
export function transformContentForMarkdown(mdx, mentionOptions = {}) {
|
|
33
41
|
const tree = getAST(mdx);
|
|
34
42
|
remarkVisibilityForMarkdown()(tree);
|
|
35
43
|
remarkUserMentions(mentionOptions)(tree);
|
|
36
|
-
return
|
|
44
|
+
return stringifyTreeForAgents(tree);
|
|
37
45
|
}
|
|
@@ -54,8 +54,14 @@ function findPage(node, path) {
|
|
|
54
54
|
}
|
|
55
55
|
export const decoratedNavContains = (node, path) => contains(node, normalizeNavPath(path));
|
|
56
56
|
export const findDecoratedNavPage = (node, path) => findPage(node, normalizeNavPath(path));
|
|
57
|
+
// reachable through groups and pages alone, without entering a division
|
|
58
|
+
function containsDirect(node, path) {
|
|
59
|
+
return matches(node, path) || decoratedNavChildren(node).some((c) => containsDirect(c, path));
|
|
60
|
+
}
|
|
57
61
|
// the nodes whose own pages (not a nested division's) hold the path: the
|
|
58
|
-
// root for a flat nav, else the innermost division chain down to the page
|
|
62
|
+
// root for a flat nav, else the innermost division chain down to the page.
|
|
63
|
+
// a child that only reaches the path through divisions of its own (a menu
|
|
64
|
+
// item split by version) is passed through, never the owner itself
|
|
59
65
|
export function decoratedNavSections(nav, path) {
|
|
60
66
|
const target = normalizeNavPath(path);
|
|
61
67
|
const out = [];
|
|
@@ -64,8 +70,13 @@ export function decoratedNavSections(nav, path) {
|
|
|
64
70
|
if (contains(division, target))
|
|
65
71
|
walk(division);
|
|
66
72
|
}
|
|
67
|
-
|
|
73
|
+
const children = decoratedNavChildren(node);
|
|
74
|
+
if (children.some((c) => containsDirect(c, target)))
|
|
68
75
|
out.push(node);
|
|
76
|
+
for (const child of children) {
|
|
77
|
+
if (!containsDirect(child, target) && contains(child, target))
|
|
78
|
+
walk(child);
|
|
79
|
+
}
|
|
69
80
|
};
|
|
70
81
|
walk(nav);
|
|
71
82
|
return out;
|
|
@@ -48,4 +48,16 @@ describe('decoratedNavSections', () => {
|
|
|
48
48
|
};
|
|
49
49
|
expect(decoratedNavSections(flat, '/a')).toEqual([flat]);
|
|
50
50
|
});
|
|
51
|
+
it('passes through a menu item split by version to the version that owns the page', () => {
|
|
52
|
+
const v3 = {
|
|
53
|
+
version: 'v3',
|
|
54
|
+
groups: [{ group: 'Start', pages: [{ href: '/studio/v3', title: 'Overview' }] }],
|
|
55
|
+
};
|
|
56
|
+
const v1 = { version: 'v1', pages: [{ href: '/studio/v1', title: 'v1' }] };
|
|
57
|
+
const menuNav = {
|
|
58
|
+
tabs: [{ tab: 'Studio', menu: [{ item: 'Studio', versions: [v3, v1] }] }],
|
|
59
|
+
};
|
|
60
|
+
expect(decoratedNavSections(menuNav, '/studio/v3')).toEqual([v3]);
|
|
61
|
+
expect(decoratedNavSections(menuNav, '/studio/v1')).toEqual([v1]);
|
|
62
|
+
});
|
|
51
63
|
});
|