@vxrn/mdx 1.2.47 → 1.2.49

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.2.47",
3
+ "version": "1.2.49",
4
4
  "type": "commonjs",
5
5
  "exports": {
6
6
  "./package.json": "./package.json",
@@ -48,12 +48,13 @@
48
48
  "rehype-autolink-headings": "^6.1.1",
49
49
  "rehype-parse": "^8.0.4",
50
50
  "rehype-slug": "^5.0.1",
51
+ "remark-gfm": "^4.0.1",
51
52
  "shiki": "1.3.0",
52
53
  "unified": "^10.1.2",
53
54
  "unist-util-visit": "^2.0.3"
54
55
  },
55
56
  "devDependencies": {
56
- "@tamagui/build": "^1.142.0"
57
+ "@tamagui/build": "^1.144.0"
57
58
  },
58
59
  "publishConfig": {
59
60
  "access": "public"
@@ -13,7 +13,9 @@ export const getAllFrontmatter = (fromPath: string): Frontmatter[] => {
13
13
  .map((filePath) => {
14
14
  const source = fs.readFileSync(path.join(filePath), 'utf8')
15
15
  const { data, content } = matter(source)
16
- const slug = filePath.replace(`${fromPath.replaceAll('\\', '/')}/`, '').replace('.mdx', '')
16
+ const slug = filePath
17
+ .replace(`${fromPath.replaceAll('\\', '/')}/`, '')
18
+ .replace('.mdx', '')
17
19
  return {
18
20
  ...data,
19
21
  slug,
@@ -21,5 +23,8 @@ export const getAllFrontmatter = (fromPath: string): Frontmatter[] => {
21
23
  readingTime: readingTime(content),
22
24
  } as Frontmatter
23
25
  })
24
- .sort((a, b) => Number(new Date(b.publishedAt || '')) - Number(new Date(a.publishedAt || '')))
26
+ .sort(
27
+ (a, b) =>
28
+ Number(new Date(b.publishedAt || '')) - Number(new Date(a.publishedAt || ''))
29
+ )
25
30
  }
package/src/getMDX.ts CHANGED
@@ -2,6 +2,7 @@ import { bundleMDX } from 'mdx-bundler'
2
2
  import readingTime from 'reading-time'
3
3
  import rehypeAutolinkHeadings from 'rehype-autolink-headings'
4
4
  import rehypeSlug from 'rehype-slug'
5
+ import remarkGfm from 'remark-gfm'
5
6
  import { getHeadings } from './getHeadings'
6
7
  import { rehypeHighlightCode } from './rehypeHighlightCode'
7
8
  import rehypeMetaAttribute from './rehypeMetaAttribute'
@@ -11,6 +12,7 @@ export async function getMDX(source: string, extraPlugins?: UnifiedPlugin) {
11
12
  const { frontmatter, code } = await bundleMDX({
12
13
  source,
13
14
  mdxOptions(options) {
15
+ options.remarkPlugins = [...(options.remarkPlugins ?? []), remarkGfm]
14
16
  const plugins = [
15
17
  ...(extraPlugins || []),
16
18
  ...(options.rehypePlugins ?? []),
@@ -7,7 +7,11 @@ import tsx from 'refractor/lang/tsx.js'
7
7
  import { rehypeHighlightLine } from './rehypeLine'
8
8
  import { rehypeHighlightWord } from './rehypeWord'
9
9
 
10
- let highlighter: (source: string, language: 'tsx' | 'css' | string, line?: string) => string
10
+ let highlighter: (
11
+ source: string,
12
+ language: 'tsx' | 'css' | string,
13
+ line?: string
14
+ ) => string
11
15
 
12
16
  export function createCodeHighlighter() {
13
17
  if (highlighter) return highlighter
@@ -15,7 +15,8 @@ export const rehypeHeroTemplate = (options: RehypeHeroTemplateOptions = {}) => {
15
15
  demosRoot = options.demosPath
16
16
  } else if (options.demosPackage) {
17
17
  // @ts-ignore
18
- const requireFn = typeof require === 'undefined' ? createRequire(import.meta.url) : require
18
+ const requireFn =
19
+ typeof require === 'undefined' ? createRequire(import.meta.url) : require
19
20
  const resolved = requireFn.resolve(options.demosPackage)
20
21
  demosRoot = path.join(resolved, '..', '..', '..')
21
22
  } else {
@@ -75,7 +75,8 @@ const wrapLines = function wrapLines(ast: any[], linesToHighlight) {
75
75
  properties: {
76
76
  dataLine: line,
77
77
  className: 'highlight-line',
78
- dataHighlighted: linesToHighlight.includes(line) || highlightAll ? 'true' : 'false',
78
+ dataHighlighted:
79
+ linesToHighlight.includes(line) || highlightAll ? 'true' : 'false',
79
80
  },
80
81
  children,
81
82
  lineNumber: line,
@@ -7,7 +7,12 @@ const CALLOUT = /__(.*?)__/g
7
7
 
8
8
  export const rehypeHighlightWord = (code) => {
9
9
  const html = toHtml(code)
10
- const result = html.replace(CALLOUT, (_, text) => `<span class="highlight-word">${text}</span>`)
11
- const hast = unified().use(parse, { emitParseErrors: true, fragment: true }).parse(result)
10
+ const result = html.replace(
11
+ CALLOUT,
12
+ (_, text) => `<span class="highlight-word">${text}</span>`
13
+ )
14
+ const hast = unified()
15
+ .use(parse, { emitParseErrors: true, fragment: true })
16
+ .parse(result)
12
17
  return hast['children']
13
18
  }
@@ -1 +1 @@
1
- {"version":3,"file":"getAllFrontmatter.d.ts","sourceRoot":"","sources":["../src/getAllFrontmatter.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAG1C,eAAO,MAAM,iBAAiB,GAAI,UAAU,MAAM,KAAG,WAAW,EAe/D,CAAA"}
1
+ {"version":3,"file":"getAllFrontmatter.d.ts","sourceRoot":"","sources":["../src/getAllFrontmatter.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAG1C,eAAO,MAAM,iBAAiB,GAAI,UAAU,MAAM,KAAG,WAAW,EAoB/D,CAAA"}
@@ -1 +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
+ {"version":3,"file":"getMDX.d.ts","sourceRoot":"","sources":["../src/getMDX.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAEzD,wBAAsB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,aAAa;iBAuBhE,WAAW;;GAGnB"}
@@ -1 +1 @@
1
- {"version":3,"file":"highlightCode.d.ts","sourceRoot":"","sources":["../src/highlightCode.tsx"],"names":[],"mappings":"AAWA,wBAAgB,qBAAqB,aAFX,MAAM,YAAY,KAAK,GAAG,KAAK,GAAG,MAAM,SAAS,MAAM,KAAK,MAAM,CAiB3F"}
1
+ {"version":3,"file":"highlightCode.d.ts","sourceRoot":"","sources":["../src/highlightCode.tsx"],"names":[],"mappings":"AAeA,wBAAgB,qBAAqB,aAL3B,MAAM,YACJ,KAAK,GAAG,KAAK,GAAG,MAAM,SACzB,MAAM,KACV,MAAM,CAiBV"}
@@ -1 +1 @@
1
- {"version":3,"file":"rehypeHeroTemplate.d.ts","sourceRoot":"","sources":["../src/rehypeHeroTemplate.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,yBAAyB,GAAG;IACtC,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,eAAO,MAAM,kBAAkB,GAAI,UAAS,yBAA8B,MAchE,MAAM,GAAG,SAclB,CAAA"}
1
+ {"version":3,"file":"rehypeHeroTemplate.d.ts","sourceRoot":"","sources":["../src/rehypeHeroTemplate.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,yBAAyB,GAAG;IACtC,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,eAAO,MAAM,kBAAkB,GAAI,UAAS,yBAA8B,MAehE,MAAM,GAAG,SAclB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"rehypeLine.d.ts","sourceRoot":"","sources":["../src/rehypeLine.tsx"],"names":[],"mappings":"AA2GA,wBAAgB,mBAAmB,CAAC,GAAG,KAAA,EAAE,KAAK,KAAA,OAI7C"}
1
+ {"version":3,"file":"rehypeLine.d.ts","sourceRoot":"","sources":["../src/rehypeLine.tsx"],"names":[],"mappings":"AA4GA,wBAAgB,mBAAmB,CAAC,GAAG,KAAA,EAAE,KAAK,KAAA,OAI7C"}
@@ -1 +1 @@
1
- {"version":3,"file":"rehypeWord.d.ts","sourceRoot":"","sources":["../src/rehypeWord.tsx"],"names":[],"mappings":"AAOA,eAAO,MAAM,mBAAmB,GAAI,SAAI,iCAKvC,CAAA"}
1
+ {"version":3,"file":"rehypeWord.d.ts","sourceRoot":"","sources":["../src/rehypeWord.tsx"],"names":[],"mappings":"AAOA,eAAO,MAAM,mBAAmB,GAAI,SAAI,iCAUvC,CAAA"}