@mintlify/common 1.0.497 → 1.0.499

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,5 @@
1
1
  import type { PageMetaTags } from '@mintlify/models';
2
2
  import type { Root } from 'mdast';
3
3
  export declare const HEADING_LEVELS: number[];
4
+ export declare const AVOIDED_PAGE_MODES: string[];
4
5
  export declare const remarkComponentIds: (pageMetadata?: PageMetaTags) => (tree: Root) => void;
@@ -4,12 +4,14 @@ import { slugify } from '../../../slugify.js';
4
4
  import { createMdxJsxAttribute } from '../../lib/remark-utils.js';
5
5
  import { getTableOfContentsTitle } from '../../lib/remark-utils.js';
6
6
  export const HEADING_LEVELS = [1, 2, 3, 4];
7
+ export const AVOIDED_PAGE_MODES = ['custom', 'frame'];
7
8
  export const remarkComponentIds = (pageMetadata) => (tree) => {
9
+ var _a;
8
10
  const slugifyFn = slugifyWithCounter();
9
11
  const tabSlugifyFn = slugifyWithCounter();
10
- const isCustomPageMode = (pageMetadata === null || pageMetadata === void 0 ? void 0 : pageMetadata.mode) === 'custom';
12
+ const isAvoidedPageMode = AVOIDED_PAGE_MODES.includes((_a = pageMetadata === null || pageMetadata === void 0 ? void 0 : pageMetadata.mode) !== null && _a !== void 0 ? _a : '');
11
13
  visit(tree, 'heading', (node) => {
12
- if (isCustomPageMode)
14
+ if (isAvoidedPageMode)
13
15
  return;
14
16
  if (HEADING_LEVELS.includes(node.depth)) {
15
17
  const title = getTableOfContentsTitle(node);
@@ -2,7 +2,7 @@ import { slugifyWithCounter } from '@sindresorhus/slugify';
2
2
  import { visit } from 'unist-util-visit';
3
3
  import { slugify } from '../../../slugify.js';
4
4
  import { createMdxJsxAttribute, getTableOfContentsTitle } from '../../lib/remark-utils.js';
5
- import { HEADING_LEVELS } from './remarkComponentIds.js';
5
+ import { AVOIDED_PAGE_MODES, HEADING_LEVELS } from './remarkComponentIds.js';
6
6
  const HEADING_NAMES = ['h1', 'h2', 'h3', 'h4'];
7
7
  const COMPONENTS_TO_EXCLUDE_HEADINGS = ['Accordion', 'AccordionGroup', 'Expandable', 'Update'];
8
8
  export const remarkExtractTableOfContents = (mdxExtracts, pageMetadata) => {
@@ -42,7 +42,7 @@ export const remarkExtractTableOfContents = (mdxExtracts, pageMetadata) => {
42
42
  }
43
43
  });
44
44
  visit(tree, (node) => {
45
- var _a, _b, _c, _d;
45
+ var _a, _b, _c, _d, _e;
46
46
  if (excludedNodes.has(node))
47
47
  return;
48
48
  const currentTabId = tabContentMap.get(node);
@@ -54,11 +54,11 @@ export const remarkExtractTableOfContents = (mdxExtracts, pageMetadata) => {
54
54
  node.attributes.some((attr) => 'name' in attr && attr.name === 'label');
55
55
  const hasIdAttribute = node.type === 'mdxJsxFlowElement' &&
56
56
  node.attributes.some((attr) => 'name' in attr && attr.name === 'id');
57
- const isCustomPageMode = (pageMetadata === null || pageMetadata === void 0 ? void 0 : pageMetadata.mode) === 'custom';
57
+ const isAvoidedPageMode = AVOIDED_PAGE_MODES.includes((_b = pageMetadata === null || pageMetadata === void 0 ? void 0 : pageMetadata.mode) !== null && _b !== void 0 ? _b : '');
58
58
  if (!isValidHeading && !isValidMdxHeading && !isTransformedHeading && !isValidUpdate) {
59
59
  return;
60
60
  }
61
- if (isCustomPageMode && (isValidHeading || isValidMdxHeading))
61
+ if (isAvoidedPageMode && (isValidHeading || isValidMdxHeading))
62
62
  return;
63
63
  let level;
64
64
  if ('name' in node && node.name === 'Update') {
@@ -75,7 +75,7 @@ export const remarkExtractTableOfContents = (mdxExtracts, pageMetadata) => {
75
75
  level = levelAttr.value;
76
76
  }
77
77
  }
78
- else if ('name' in node && ((_b = node.name) === null || _b === void 0 ? void 0 : _b[1])) {
78
+ else if ('name' in node && ((_c = node.name) === null || _c === void 0 ? void 0 : _c[1])) {
79
79
  const num = Number(node.name[1]);
80
80
  level = !isNaN(num) ? num : undefined;
81
81
  }
@@ -124,7 +124,7 @@ export const remarkExtractTableOfContents = (mdxExtracts, pageMetadata) => {
124
124
  // Account if there is no first layer
125
125
  let arrToPushInto = contents;
126
126
  if (hasTopLayer) {
127
- arrToPushInto = (_d = (_c = contents.at(-1)) === null || _c === void 0 ? void 0 : _c.children) !== null && _d !== void 0 ? _d : [];
127
+ arrToPushInto = (_e = (_d = contents.at(-1)) === null || _d === void 0 ? void 0 : _d.children) !== null && _e !== void 0 ? _e : [];
128
128
  }
129
129
  arrToPushInto.push({ title, slug, depth, children: [], tabId: currentTabId });
130
130
  }