@mintlify/common 1.0.1176 → 1.0.1177

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.
@@ -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-util-mdxjs-esm").MdxjsEsm | import("mdast-util-mdx-expression").MdxFlowExpression | import("mdast-util-mdx-expression").MdxTextExpression | import("mdast").Code | import("mdast").Delete | import("mdast").Link | import("mdast-util-mdx").MdxJsxFlowElement | import("mdast").Table | import("mdast").Blockquote | import("mdast").Break | import("mdast").Definition | import("mdast").Emphasis | import("mdast").FootnoteDefinition | import("mdast").FootnoteReference | import("mdast").Heading | 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").TableCell | import("mdast").TableRow | import("mdast").Text | import("mdast").ThematicBreak | import("mdast").Yaml | import("mdast-util-math").InlineMath | import("mdast-util-math").Math | import("mdast-util-mdx").MdxJsxTextElement;
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;
@@ -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
- if (decoratedNavChildren(node).some((c) => contains(c, target)))
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
  });