@mintlify/common 1.0.492 → 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.
- package/dist/mdx/getMDXOptions.js +2 -2
- package/dist/mdx/plugins/remark/remarkComponentIds.d.ts +2 -1
- package/dist/mdx/plugins/remark/remarkComponentIds.js +4 -1
- package/dist/mdx/plugins/remark/remarkExtractTableOfContents.d.ts +2 -1
- package/dist/mdx/plugins/remark/remarkExtractTableOfContents.js +4 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -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;
|