@vxrn/mdx 1.1.321 → 1.1.323
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/index.js +5 -4
- package/dist/index.js.map +1 -1
- package/dist/index.native.js +5 -4
- package/dist/index.native.js.map +2 -2
- package/package.json +1 -1
- package/src/getHeadings.ts +1 -1
- package/src/getMDXBySlug.tsx +7 -3
- package/src/index.ts +2 -3
- package/types/getMDXBySlug.d.ts +3 -2
- package/types/getMDXBySlug.d.ts.map +1 -1
- package/types/index.d.ts +2 -2
- package/types/index.d.ts.map +1 -1
package/package.json
CHANGED
package/src/getHeadings.ts
CHANGED
package/src/getMDXBySlug.tsx
CHANGED
|
@@ -10,9 +10,12 @@ import rehypeAutolinkHeadings from 'rehype-autolink-headings'
|
|
|
10
10
|
import rehypeSlug from 'rehype-slug'
|
|
11
11
|
import { getHeadings } from './getHeadings'
|
|
12
12
|
|
|
13
|
+
export type UnifiedPlugin = import('unified').Plugin[]
|
|
14
|
+
|
|
13
15
|
export const getMDXBySlug = async (
|
|
14
16
|
basePath: string,
|
|
15
|
-
slug: string
|
|
17
|
+
slug: string,
|
|
18
|
+
extraPlugins?: UnifiedPlugin
|
|
16
19
|
): Promise<{ frontmatter: Frontmatter; code: string }> => {
|
|
17
20
|
let mdxPath = slug
|
|
18
21
|
|
|
@@ -24,7 +27,7 @@ export const getMDXBySlug = async (
|
|
|
24
27
|
|
|
25
28
|
const filePath = path.join(basePath, `${mdxPath}.mdx`)
|
|
26
29
|
const source = fs.readFileSync(filePath, 'utf8')
|
|
27
|
-
const { frontmatter, code } = await getMDX(source)
|
|
30
|
+
const { frontmatter, code } = await getMDX(source, extraPlugins)
|
|
28
31
|
return {
|
|
29
32
|
frontmatter: {
|
|
30
33
|
...frontmatter,
|
|
@@ -35,11 +38,12 @@ export const getMDXBySlug = async (
|
|
|
35
38
|
}
|
|
36
39
|
}
|
|
37
40
|
|
|
38
|
-
export async function getMDX(source: string) {
|
|
41
|
+
export async function getMDX(source: string, extraPlugins?: UnifiedPlugin) {
|
|
39
42
|
return await bundleMDX({
|
|
40
43
|
source,
|
|
41
44
|
mdxOptions(options) {
|
|
42
45
|
const plugins = [
|
|
46
|
+
...(extraPlugins || []),
|
|
43
47
|
...(options.rehypePlugins ?? []),
|
|
44
48
|
rehypeMetaAttribute,
|
|
45
49
|
rehypeHighlightCode,
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
// export { rehypeHighlightCode } from './rehypeHighlightCode'
|
|
2
1
|
export { getAllFrontmatter } from './getAllFrontmatter'
|
|
3
|
-
export {
|
|
4
|
-
export type { Frontmatter } from './types'
|
|
2
|
+
export { getAllVersionsFromPath, getMDXBySlug } from './getMDXBySlug'
|
|
5
3
|
export { createCodeHighlighter } from './highlightCode'
|
|
4
|
+
export type { Frontmatter } from './types'
|
package/types/getMDXBySlug.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { Frontmatter } from './types';
|
|
2
|
-
export
|
|
2
|
+
export type UnifiedPlugin = import('unified').Plugin[];
|
|
3
|
+
export declare const getMDXBySlug: (basePath: string, slug: string, extraPlugins?: UnifiedPlugin) => Promise<{
|
|
3
4
|
frontmatter: Frontmatter;
|
|
4
5
|
code: string;
|
|
5
6
|
}>;
|
|
6
|
-
export declare function getMDX(source: string): Promise<{
|
|
7
|
+
export declare function getMDX(source: string, extraPlugins?: UnifiedPlugin): Promise<{
|
|
7
8
|
code: string;
|
|
8
9
|
frontmatter: {
|
|
9
10
|
[key: string]: any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getMDXBySlug.d.ts","sourceRoot":"","sources":["../src/getMDXBySlug.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAO1C,eAAO,MAAM,YAAY,aACb,MAAM,QACV,MAAM,
|
|
1
|
+
{"version":3,"file":"getMDXBySlug.d.ts","sourceRoot":"","sources":["../src/getMDXBySlug.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAO1C,MAAM,MAAM,aAAa,GAAG,OAAO,SAAS,EAAE,MAAM,EAAE,CAAA;AAEtD,eAAO,MAAM,YAAY,aACb,MAAM,QACV,MAAM,iBACG,aAAa,KAC3B,OAAO,CAAC;IAAE,WAAW,EAAE,WAAW,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAoBpD,CAAA;AAED,wBAAsB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,aAAa;;;;;;;;;;;GAgBxE;AAED,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAOjE"}
|
package/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { getAllFrontmatter } from './getAllFrontmatter';
|
|
2
|
-
export {
|
|
3
|
-
export type { Frontmatter } from './types';
|
|
2
|
+
export { getAllVersionsFromPath, getMDXBySlug } from './getMDXBySlug';
|
|
4
3
|
export { createCodeHighlighter } from './highlightCode';
|
|
4
|
+
export type { Frontmatter } from './types';
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
package/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAA;AACvD,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA"}
|