@mintlify/common 1.0.303 → 1.0.305

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
- import { rehypeCodeBlocks, rehypeMdxExtractEndpoint, rehypeMdxExtractExamples, rehypeParamFieldIds, rehypeRawComponents, rehypeUnicodeIds, rehypeZoomImages, remarkExtractTableOfContents, remarkFrames, remarkMdxInjectSnippets, remarkMdxRemoveUnusedVariables, remarkRemoveImports, } from './plugins/index.js';
1
+ import { rehypeCodeBlocks, rehypeMdxExtractEndpoint, rehypeMdxExtractExamples, rehypeParamFieldIds, rehypeRawComponents, rehypeUnicodeIds, rehypeZoomImages, remarkExtractChangelogFilters, remarkExtractTableOfContents, remarkFrames, remarkMdxInjectSnippets, remarkMdxRemoveUnusedVariables, remarkRemoveImports, } from './plugins/index.js';
2
2
  import { remarkMdxRemoveUnknownJsx } from './plugins/remark/remarkMdxRemoveUnknownJsx/index.js';
3
3
  import { remarkMermaid } from './plugins/remark/remarkMermaid.js';
4
4
  // avoid running extractors unnecessarily
@@ -15,6 +15,7 @@ export const getMDXOptions = ({ data, remarkPlugins = [], rehypePlugins = [], md
15
15
  remarkPlugins: [
16
16
  [remarkMdxInjectSnippets, data.snippetTreeMap],
17
17
  [remarkExtractTableOfContents, mdxExtracts], // modifies tree so cannot be excluded
18
+ [remarkExtractChangelogFilters, mdxExtracts],
18
19
  remarkMdxRemoveUnusedVariables,
19
20
  remarkFrames,
20
21
  remarkRemoveImports,
@@ -7,3 +7,4 @@ export * from './remarkMdxRemoveUnknownJsx/index.js';
7
7
  export * from './remarkReplaceAllImages.js';
8
8
  export * from './remarkMermaid.js';
9
9
  export * from './remarkMdxRemoveJs.js';
10
+ export * from './remarkExtractChangelogFilters.js';
@@ -7,3 +7,4 @@ export * from './remarkMdxRemoveUnknownJsx/index.js';
7
7
  export * from './remarkReplaceAllImages.js';
8
8
  export * from './remarkMermaid.js';
9
9
  export * from './remarkMdxRemoveJs.js';
10
+ export * from './remarkExtractChangelogFilters.js';
@@ -0,0 +1 @@
1
+ export function remarkExtractChangelogFilters(mdxExtracts: any): (tree: any) => void;
@@ -0,0 +1,52 @@
1
+ export function remarkExtractChangelogFilters(mdxExtracts) {
2
+ return (tree) => {
3
+ const tagCounts = new Map();
4
+ for (let nodeIndex = 0; nodeIndex < tree.children.length; nodeIndex++) {
5
+ const node = tree.children[nodeIndex];
6
+ if (node.type === 'mdxJsxFlowElement' && node.name === 'Update') {
7
+ const tagsAttribute = node.attributes.find((attr) => attr.name === 'tags');
8
+ if (tagsAttribute &&
9
+ tagsAttribute.value &&
10
+ tagsAttribute.value.type === 'mdxJsxAttributeValueExpression') {
11
+ let tags = [];
12
+ try {
13
+ tags = JSON.parse(tagsAttribute.value.value);
14
+ }
15
+ catch (_a) {
16
+ const isProgram = tagsAttribute.value.data.estree.type === 'Program';
17
+ if (isProgram && tagsAttribute.value.data.estree.body.length === 1) {
18
+ const body = tagsAttribute.value.data.estree.body[0];
19
+ if (body.type === 'ExpressionStatement' &&
20
+ body.expression.type === 'ArrayExpression') {
21
+ tags = body.expression.elements
22
+ .map((element) => {
23
+ if (element.type === 'Literal') {
24
+ return element.value;
25
+ }
26
+ return null;
27
+ })
28
+ .filter(Boolean);
29
+ }
30
+ }
31
+ }
32
+ if (Array.isArray(tags)) {
33
+ tags.forEach((tag) => {
34
+ if (!!tag.trim()) {
35
+ tagCounts.set(tag, (tagCounts.get(tag) || 0) + 1);
36
+ }
37
+ });
38
+ }
39
+ }
40
+ }
41
+ }
42
+ const filters = Array.from(tagCounts.entries())
43
+ .map(([tag, count]) => ({
44
+ tag,
45
+ count,
46
+ }))
47
+ .sort((a, b) => b.count - a.count);
48
+ if (mdxExtracts && filters.length) {
49
+ mdxExtracts.changelogFilters = filters;
50
+ }
51
+ };
52
+ }