@mintlify/common 1.0.621 → 1.0.623
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/frontmatter/index.d.ts +3 -0
- package/dist/frontmatter/index.js +1 -0
- package/dist/frontmatter/parseFrontmatter.d.ts +34 -0
- package/dist/frontmatter/parseFrontmatter.js +35 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/mdx/snippets/resolveImport/injectToTopOfFile.d.ts +0 -4
- package/dist/mdx/snippets/resolveImport/injectToTopOfFile.js +0 -11
- package/dist/slug/getDecoratedNavPageAndSlug.js +2 -2
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { parseFrontmatter, hasFrontmatter } from './parseFrontmatter.js';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { FrontMatterResult } from 'front-matter';
|
|
2
|
+
/**
|
|
3
|
+
* Default type for frontmatter attributes when no specific type is provided.
|
|
4
|
+
* Represents a flexible object that can contain any valid JSON-like values.
|
|
5
|
+
*/
|
|
6
|
+
export type FrontmatterAttributes = Record<string, string | undefined>;
|
|
7
|
+
/**
|
|
8
|
+
* Type-safe wrapper for parsing front-matter from markdown content.
|
|
9
|
+
*
|
|
10
|
+
* @template T - The expected type of the frontmatter attributes
|
|
11
|
+
* @param content - The markdown content string to parse
|
|
12
|
+
* @returns A FrontMatterResult with properly typed attributes
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* interface MyFrontmatter {
|
|
17
|
+
* title: string;
|
|
18
|
+
* description?: string;
|
|
19
|
+
* tags?: string[];
|
|
20
|
+
* }
|
|
21
|
+
*
|
|
22
|
+
* const result = parseFrontmatter<MyFrontmatter>(content);
|
|
23
|
+
* // result.attributes is now typed as MyFrontmatter
|
|
24
|
+
* console.log(result.attributes.title);
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function parseFrontmatter<T = FrontmatterAttributes>(content: string): FrontMatterResult<T>;
|
|
28
|
+
/**
|
|
29
|
+
* Tests whether a string contains frontmatter
|
|
30
|
+
*
|
|
31
|
+
* @param content - The content to test
|
|
32
|
+
* @returns true if the content contains frontmatter
|
|
33
|
+
*/
|
|
34
|
+
export declare function hasFrontmatter(content: string): boolean;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import fm from 'front-matter';
|
|
2
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
3
|
+
const frontmatter = fm;
|
|
4
|
+
/**
|
|
5
|
+
* Type-safe wrapper for parsing front-matter from markdown content.
|
|
6
|
+
*
|
|
7
|
+
* @template T - The expected type of the frontmatter attributes
|
|
8
|
+
* @param content - The markdown content string to parse
|
|
9
|
+
* @returns A FrontMatterResult with properly typed attributes
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* interface MyFrontmatter {
|
|
14
|
+
* title: string;
|
|
15
|
+
* description?: string;
|
|
16
|
+
* tags?: string[];
|
|
17
|
+
* }
|
|
18
|
+
*
|
|
19
|
+
* const result = parseFrontmatter<MyFrontmatter>(content);
|
|
20
|
+
* // result.attributes is now typed as MyFrontmatter
|
|
21
|
+
* console.log(result.attributes.title);
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export function parseFrontmatter(content) {
|
|
25
|
+
return frontmatter(content);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Tests whether a string contains frontmatter
|
|
29
|
+
*
|
|
30
|
+
* @param content - The content to test
|
|
31
|
+
* @returns true if the content contains frontmatter
|
|
32
|
+
*/
|
|
33
|
+
export function hasFrontmatter(content) {
|
|
34
|
+
return frontmatter.test(content);
|
|
35
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export * from './mdx/index.js';
|
|
|
5
5
|
export * from './getFileCategory.js';
|
|
6
6
|
export * from './slug/index.js';
|
|
7
7
|
export * from './fs/index.js';
|
|
8
|
+
export * from './frontmatter/index.js';
|
|
8
9
|
export * from './getSecurityOptionsForAuthMethod.js';
|
|
9
10
|
export * from './getFileCategory.js';
|
|
10
11
|
export * from './topologicalSort.js';
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,7 @@ export * from './mdx/index.js';
|
|
|
5
5
|
export * from './getFileCategory.js';
|
|
6
6
|
export * from './slug/index.js';
|
|
7
7
|
export * from './fs/index.js';
|
|
8
|
+
export * from './frontmatter/index.js';
|
|
8
9
|
export * from './getSecurityOptionsForAuthMethod.js';
|
|
9
10
|
export * from './getFileCategory.js';
|
|
10
11
|
export * from './topologicalSort.js';
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
import type { Root, RootContent } from 'mdast';
|
|
2
|
-
/**
|
|
3
|
-
* Injects content to the top of a file, but below the frontmatter
|
|
4
|
-
*/
|
|
5
|
-
export declare const injectToTopOfFile: (content: string, contentToInject: string) => string;
|
|
6
2
|
/**
|
|
7
3
|
* Injects nodes to the top of a MDX/Markdown AST (Root), but below the frontmatter (YAML node).
|
|
8
4
|
* Modifies the tree in place.
|
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
import matter from 'gray-matter';
|
|
2
|
-
const { test: hasFrontmatter } = matter;
|
|
3
|
-
/**
|
|
4
|
-
* Injects content to the top of a file, but below the frontmatter
|
|
5
|
-
*/
|
|
6
|
-
export const injectToTopOfFile = (content, contentToInject) => {
|
|
7
|
-
if (!hasFrontmatter(content))
|
|
8
|
-
return contentToInject + `\n` + content;
|
|
9
|
-
const { data: frontmatterData, content: contentWithoutFrontmatter } = matter(content);
|
|
10
|
-
return matter.stringify(`\n` + contentToInject + `\n` + contentWithoutFrontmatter, frontmatterData);
|
|
11
|
-
};
|
|
12
1
|
/**
|
|
13
2
|
* Injects nodes to the top of a MDX/Markdown AST (Root), but below the frontmatter (YAML node).
|
|
14
3
|
* Modifies the tree in place.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import matter from 'gray-matter';
|
|
2
1
|
import { getAsyncApiChannelMetadata } from '../asyncapi/getAsyncApiChannelMetadata.js';
|
|
3
2
|
import { prepAsyncApiFrontmatter } from '../asyncapi/prepAsyncApiFrontmatter.js';
|
|
3
|
+
import { parseFrontmatter } from '../frontmatter/index.js';
|
|
4
4
|
import { removeLeadingSlash, optionallyAddLeadingSlash } from '../fs/index.js';
|
|
5
5
|
import { getOpenApiTitleAndDescription } from '../openapi/getOpenApiTitleAndDescription.js';
|
|
6
6
|
import { prepOpenApiFrontmatter } from '../openapi/prepOpenApiFrontmatter.js';
|
|
@@ -9,7 +9,7 @@ import { slugToTitle } from './slugToTitle.js';
|
|
|
9
9
|
export const getDecoratedNavPageAndSlug = (pagePath, pageContent, openApiFiles, asyncApiFiles) => {
|
|
10
10
|
let metadata = {};
|
|
11
11
|
try {
|
|
12
|
-
metadata =
|
|
12
|
+
metadata = parseFrontmatter(pageContent).attributes;
|
|
13
13
|
}
|
|
14
14
|
catch (error) {
|
|
15
15
|
if (error &&
|