@vxrn/mdx 1.1.371 → 1.1.372

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vxrn/mdx",
3
- "version": "1.1.371",
3
+ "version": "1.1.372",
4
4
  "types": "./types/index.d.ts",
5
5
  "main": "dist/index.js",
6
6
  "type": "commonjs",
@@ -46,7 +46,7 @@
46
46
  "unist-util-visit": "^2.0.3"
47
47
  },
48
48
  "devDependencies": {
49
- "@tamagui/build": "^1.120.2"
49
+ "@tamagui/build": "^1.121.2"
50
50
  },
51
51
  "publishConfig": {
52
52
  "access": "public"
package/src/getMDX.ts ADDED
@@ -0,0 +1,35 @@
1
+ import { bundleMDX } from 'mdx-bundler'
2
+ import readingTime from 'reading-time'
3
+ import rehypeAutolinkHeadings from 'rehype-autolink-headings'
4
+ import rehypeSlug from 'rehype-slug'
5
+ import { rehypeHighlightCode } from './rehypeHighlightCode'
6
+ import rehypeMetaAttribute from './rehypeMetaAttribute'
7
+ import { getHeadings } from './getHeadings'
8
+ import type { Frontmatter, UnifiedPlugin } from './types'
9
+
10
+ export async function getMDX(source: string, extraPlugins?: UnifiedPlugin) {
11
+ const { frontmatter, code } = await bundleMDX({
12
+ source,
13
+ mdxOptions(options) {
14
+ const plugins = [
15
+ ...(extraPlugins || []),
16
+ ...(options.rehypePlugins ?? []),
17
+ rehypeMetaAttribute,
18
+ rehypeHighlightCode,
19
+ rehypeAutolinkHeadings,
20
+ rehypeSlug,
21
+ ]
22
+ options.rehypePlugins = plugins as any
23
+ return options
24
+ },
25
+ })
26
+
27
+ return {
28
+ frontmatter: {
29
+ ...frontmatter,
30
+ headings: getHeadings(source),
31
+ readingTime: readingTime(code),
32
+ } as Frontmatter,
33
+ code,
34
+ }
35
+ }
@@ -1,16 +1,8 @@
1
1
  import fs from 'node:fs'
2
2
  import path from 'node:path'
3
3
  import compareVersions from 'compare-versions'
4
- import { bundleMDX } from 'mdx-bundler'
5
- import readingTime from 'reading-time'
6
- import type { Frontmatter } from './types'
7
- import { rehypeHighlightCode } from './rehypeHighlightCode'
8
- import rehypeMetaAttribute from './rehypeMetaAttribute'
9
- import rehypeAutolinkHeadings from 'rehype-autolink-headings'
10
- import rehypeSlug from 'rehype-slug'
11
- import { getHeadings } from './getHeadings'
12
-
13
- export type UnifiedPlugin = import('unified').Plugin[]
4
+ import type { Frontmatter, UnifiedPlugin } from './types'
5
+ import { getMDX } from './getMDX'
14
6
 
15
7
  export const getMDXBySlug = async (
16
8
  basePath: string,
@@ -27,33 +19,8 @@ export const getMDXBySlug = async (
27
19
 
28
20
  const filePath = path.join(basePath, `${mdxPath}.mdx`)
29
21
  const source = fs.readFileSync(filePath, 'utf8')
30
- const { frontmatter, code } = await getMDX(source, extraPlugins)
31
- return {
32
- frontmatter: {
33
- ...frontmatter,
34
- headings: getHeadings(source),
35
- readingTime: readingTime(code),
36
- } as Frontmatter,
37
- code,
38
- }
39
- }
40
-
41
- export async function getMDX(source: string, extraPlugins?: UnifiedPlugin) {
42
- return await bundleMDX({
43
- source,
44
- mdxOptions(options) {
45
- const plugins = [
46
- ...(extraPlugins || []),
47
- ...(options.rehypePlugins ?? []),
48
- rehypeMetaAttribute,
49
- rehypeHighlightCode,
50
- rehypeAutolinkHeadings,
51
- rehypeSlug,
52
- ]
53
- options.rehypePlugins = plugins as any
54
- return options
55
- },
56
- })
22
+ const bundle = await getMDX(source, extraPlugins)
23
+ return bundle
57
24
  }
58
25
 
59
26
  export function getAllVersionsFromPath(fromPath: string): string[] {
package/src/index.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export { getAllFrontmatter } from './getAllFrontmatter'
2
+ export { getMDX } from './getMDX'
2
3
  export { getAllVersionsFromPath, getMDXBySlug } from './getMDXBySlug'
3
4
  export { createCodeHighlighter } from './highlightCode'
4
5
  export type { Frontmatter } from './types'
package/src/types.ts CHANGED
@@ -18,3 +18,5 @@ export type Frontmatter = {
18
18
  package?: string
19
19
  demoName?: string
20
20
  }
21
+
22
+ export type UnifiedPlugin = import('unified').Plugin[]
@@ -0,0 +1,6 @@
1
+ import type { Frontmatter, UnifiedPlugin } from './types';
2
+ export declare function getMDX(source: string, extraPlugins?: UnifiedPlugin): Promise<{
3
+ frontmatter: Frontmatter;
4
+ code: string;
5
+ }>;
6
+ //# sourceMappingURL=getMDX.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getMDX.d.ts","sourceRoot":"","sources":["../src/getMDX.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAEzD,wBAAsB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,aAAa;iBAsBhE,WAAW;;GAGnB"}
@@ -1,20 +1,7 @@
1
- import type { Frontmatter } from './types';
2
- export type UnifiedPlugin = import('unified').Plugin[];
1
+ import type { Frontmatter, UnifiedPlugin } from './types';
3
2
  export declare const getMDXBySlug: (basePath: string, slug: string, extraPlugins?: UnifiedPlugin) => Promise<{
4
3
  frontmatter: Frontmatter;
5
4
  code: string;
6
5
  }>;
7
- export declare function getMDX(source: string, extraPlugins?: UnifiedPlugin): Promise<{
8
- code: string;
9
- frontmatter: {
10
- [key: string]: any;
11
- };
12
- errors: import("esbuild").Message[];
13
- matter: Omit<import("gray-matter").GrayMatterFile<string>, "data"> & {
14
- data: {
15
- [key: string]: any;
16
- };
17
- };
18
- }>;
19
6
  export declare function getAllVersionsFromPath(fromPath: string): string[];
20
7
  //# sourceMappingURL=getMDXBySlug.d.ts.map
@@ -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,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"}
1
+ {"version":3,"file":"getMDXBySlug.d.ts","sourceRoot":"","sources":["../src/getMDXBySlug.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAGzD,eAAO,MAAM,YAAY,aACb,MAAM,QACV,MAAM,iBACG,aAAa,KAC3B,OAAO,CAAC;IAAE,WAAW,EAAE,WAAW,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAapD,CAAA;AAED,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAOjE"}
package/types/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export { getAllFrontmatter } from './getAllFrontmatter';
2
+ export { getMDX } from './getMDX';
2
3
  export { getAllVersionsFromPath, getMDXBySlug } from './getMDXBySlug';
3
4
  export { createCodeHighlighter } from './highlightCode';
4
5
  export type { Frontmatter } from './types';
@@ -1 +1 @@
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"}
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,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,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"}
package/types/types.d.ts CHANGED
@@ -27,4 +27,5 @@ export type Frontmatter = {
27
27
  package?: string;
28
28
  demoName?: string;
29
29
  };
30
+ export type UnifiedPlugin = import('unified').Plugin[];
30
31
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;IAC5D,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;IACnB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;IACrB,IAAI,CAAC,EAAE,WAAW,GAAG,MAAM,CAAA;IAC3B,WAAW,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KA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