@mintlify/common 1.0.491 → 1.0.493

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.
@@ -14,8 +14,8 @@ export const getMDXOptions = ({ data, remarkPlugins = [], rehypePlugins = [], md
14
14
  return {
15
15
  remarkPlugins: [
16
16
  [remarkMdxInjectSnippets, data.snippetTreeMap],
17
- remarkComponentIds,
18
- [remarkExtractTableOfContents, mdxExtracts], // modifies tree so cannot be excluded
17
+ [remarkComponentIds, data.pageMetadata],
18
+ [remarkExtractTableOfContents, mdxExtracts, data.pageMetadata], // modifies tree so cannot be excluded
19
19
  [remarkExtractChangelogFilters, mdxExtracts],
20
20
  [remarkMdxExtractPanel, mdxExtracts],
21
21
  remarkMdxRemoveUnusedVariables,
@@ -1,3 +1,4 @@
1
+ import type { PageMetaTags } from '@mintlify/models';
1
2
  import type { Root } from 'mdast';
2
3
  export declare const HEADING_LEVELS: number[];
3
- export declare const remarkComponentIds: () => (tree: Root) => void;
4
+ export declare const remarkComponentIds: (pageMetadata?: PageMetaTags) => (tree: Root) => void;
@@ -4,10 +4,13 @@ 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 remarkComponentIds = () => (tree) => {
7
+ export const remarkComponentIds = (pageMetadata) => (tree) => {
8
8
  const slugifyFn = slugifyWithCounter();
9
9
  const tabSlugifyFn = slugifyWithCounter();
10
+ const isCustomPageMode = (pageMetadata === null || pageMetadata === void 0 ? void 0 : pageMetadata.mode) === 'custom';
10
11
  visit(tree, 'heading', (node) => {
12
+ if (isCustomPageMode)
13
+ return;
11
14
  if (HEADING_LEVELS.includes(node.depth)) {
12
15
  const title = getTableOfContentsTitle(node);
13
16
  const slug = slugify(title, slugifyFn);
@@ -1,3 +1,4 @@
1
+ import type { PageMetaTags } from '@mintlify/models';
1
2
  import type { Root } from 'mdast';
2
3
  import type { MdxExtracts } from '../../../types/index.js';
3
- export declare const remarkExtractTableOfContents: (mdxExtracts?: MdxExtracts) => (tree: Root) => void;
4
+ export declare const remarkExtractTableOfContents: (mdxExtracts?: MdxExtracts, pageMetadata?: PageMetaTags) => (tree: Root) => void;
@@ -5,7 +5,7 @@ import { createMdxJsxAttribute, getTableOfContentsTitle } from '../../lib/remark
5
5
  import { 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
- export const remarkExtractTableOfContents = (mdxExtracts) => {
8
+ export const remarkExtractTableOfContents = (mdxExtracts, pageMetadata) => {
9
9
  // slugifyWithCounter adds a counter (eg. slug, slug-2, slug-3) to the end of the slug if the header
10
10
  // already exists. No counter is added for the first occurence.
11
11
  const slugifyFn = slugifyWithCounter();
@@ -54,9 +54,12 @@ export const remarkExtractTableOfContents = (mdxExtracts) => {
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
58
  if (!isValidHeading && !isValidMdxHeading && !isTransformedHeading && !isValidUpdate) {
58
59
  return;
59
60
  }
61
+ if (isCustomPageMode && (isValidHeading || isValidMdxHeading))
62
+ return;
60
63
  let level;
61
64
  if ('name' in node && node.name === 'Update') {
62
65
  level = 1;
@@ -1,6 +1,6 @@
1
1
  import { type SerializeSuccess } from '@mintlify/mdx';
2
2
  import type { PageMetaTags } from '@mintlify/models';
3
- import type { DocsConfig } from '@mintlify/validation';
3
+ import { CodeStyling } from '@mintlify/validation/dist/mint-config/schemas/v2/index.js';
4
4
  import { MdxExtracts } from '../../index.js';
5
5
  import { createSnippetTreeMap, type Snippet } from './getMdx/snippets.js';
6
6
  export type GetMdxType = {
@@ -10,13 +10,13 @@ export type GetMdxType = {
10
10
  panelMdxSource?: SerializeSuccess;
11
11
  panelMdxSourceWithNoJs?: SerializeSuccess;
12
12
  };
13
- export declare function getMdx({ path, content, metadata, snippets, subdomain, config, tailwindSelectors, pageType, }: {
13
+ export declare function getMdx({ path, content, metadata, snippets, subdomain, codeStyling, tailwindSelectors, pageType, }: {
14
14
  path: string;
15
15
  content: string;
16
16
  metadata: PageMetaTags;
17
17
  snippets: Snippet[];
18
18
  subdomain: string;
19
- config: DocsConfig;
19
+ codeStyling: CodeStyling;
20
20
  tailwindSelectors?: string[] | undefined;
21
21
  pageType?: 'default' | 'pdf';
22
22
  }): Promise<GetMdxType>;
@@ -12,7 +12,7 @@ import { getTailwindSelectors } from '../../css/tailwind.js';
12
12
  import { getMDXOptions, remarkMdxRemoveJs, remarkExpandContent, remarkSplitCodeGroup, remarkSplitTabs, remarkValidateSteps, remarkValidateTabs, } from '../../index.js';
13
13
  import { createSnippetTreeMap } from './getMdx/snippets.js';
14
14
  export function getMdx(_a) {
15
- return __awaiter(this, arguments, void 0, function* ({ path, content, metadata, snippets, subdomain, config, tailwindSelectors = undefined, pageType = 'default', }) {
15
+ return __awaiter(this, arguments, void 0, function* ({ path, content, metadata, snippets, subdomain, codeStyling, tailwindSelectors = undefined, pageType = 'default', }) {
16
16
  if (!tailwindSelectors)
17
17
  tailwindSelectors = yield getTailwindSelectors({ content });
18
18
  const snippetTreeMap = yield createSnippetTreeMap(snippets);
@@ -20,7 +20,7 @@ export function getMdx(_a) {
20
20
  subdomain,
21
21
  snippetTreeMap,
22
22
  pageMetadata: metadata,
23
- config,
23
+ codeStyling,
24
24
  tailwindSelectors,
25
25
  };
26
26
  let mdxExtracts = {};
@@ -34,16 +34,16 @@ export function getMdx(_a) {
34
34
  remarkPlugins: [remarkMdxRemoveJs, ...plugins],
35
35
  });
36
36
  const scope = {
37
- config,
37
+ codeStyling,
38
38
  pageMetadata: metadata,
39
39
  };
40
- const { mdxSource, mdxSourceWithNoJs } = yield compileMdx(content, scope, mdxOptions, mdxOptionsNoJs, config, path);
40
+ const { mdxSource, mdxSourceWithNoJs } = yield compileMdx(content, scope, mdxOptions, mdxOptionsNoJs, codeStyling, path);
41
41
  const originalMdxExtracts = structuredClone(mdxExtracts);
42
42
  let panelMdxSource;
43
43
  let panelMdxSourceWithNoJs;
44
44
  if (mdxExtracts.panel && mdxExtracts.panel.content) {
45
45
  const panelContent = mdxExtracts.panel.content;
46
- const compiledMdx = yield compileMdx(panelContent, scope, mdxOptions, mdxOptionsNoJs, config, path);
46
+ const compiledMdx = yield compileMdx(panelContent, scope, mdxOptions, mdxOptionsNoJs, codeStyling, path);
47
47
  panelMdxSource = compiledMdx.mdxSource;
48
48
  panelMdxSourceWithNoJs = compiledMdx.mdxSourceWithNoJs;
49
49
  // serializing mdx content with the panel content will remove the original mdxExtracts
@@ -59,28 +59,28 @@ export function getMdx(_a) {
59
59
  };
60
60
  });
61
61
  }
62
- function compileMdx(content, scope, mdxOptions, mdxOptionsNoJs, config, path) {
62
+ function compileMdx(content, scope, mdxOptions, mdxOptionsNoJs, codeStyling, path) {
63
63
  return __awaiter(this, void 0, void 0, function* () {
64
- const mdxSource = yield getCompiledMdxWithFallback(content, scope, mdxOptions, config, path);
65
- const mdxSourceWithNoJs = yield getCompiledMdxWithFallback(content, scope, mdxOptionsNoJs, config, path);
64
+ const mdxSource = yield getCompiledMdxWithFallback(content, scope, mdxOptions, codeStyling, path);
65
+ const mdxSourceWithNoJs = yield getCompiledMdxWithFallback(content, scope, mdxOptionsNoJs, codeStyling, path);
66
66
  return { mdxSource, mdxSourceWithNoJs };
67
67
  });
68
68
  }
69
- function getCompiledMdxWithFallback(source, scope, mdxOptions, config, path) {
69
+ function getCompiledMdxWithFallback(source, scope, mdxOptions, codeStyling, path) {
70
70
  return __awaiter(this, void 0, void 0, function* () {
71
- var _a;
72
71
  try {
73
72
  const result = yield serialize({
74
73
  source,
75
74
  scope,
76
75
  mdxOptions,
77
76
  syntaxHighlightingOptions: {
78
- codeStyling: (_a = config.styling) === null || _a === void 0 ? void 0 : _a.codeblocks,
77
+ codeStyling,
79
78
  },
80
79
  });
81
80
  if ('error' in result) {
82
81
  throw result.error;
83
82
  }
83
+ result.scope = Object.assign(Object.assign({}, result.scope), { config: {} });
84
84
  return result;
85
85
  }
86
86
  catch (err) {
@@ -95,6 +95,7 @@ function getCompiledMdxWithFallback(source, scope, mdxOptions, config, path) {
95
95
  if ('error' in fallbackResult) {
96
96
  throw fallbackResult.error;
97
97
  }
98
+ fallbackResult.scope = Object.assign(Object.assign({}, fallbackResult.scope), { config: {} });
98
99
  return fallbackResult;
99
100
  }
100
101
  });