react-router-markdown 0.9.0 → 0.9.1

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/LICENSE.md CHANGED
File without changes
package/dist/vite.mjs CHANGED
@@ -13,7 +13,8 @@ function reactRouterMarkdown(options = {}) {
13
13
  const handleData = handleDataFn(transformedContent, transformedFrontmatter);
14
14
  return {
15
15
  code: [
16
- `import { MarkdownPage } from 'react-router-markdown';`,
16
+ "import { MarkdownPage } from 'react-router-markdown';",
17
+ "import { jsx } from 'react/jsx-runtime';",
17
18
  wrapperModule ? `import Wrapper from ${JSON.stringify(wrapperModule)};` : "const Wrapper = null;",
18
19
  "",
19
20
  `export const frontmatter = ${JSON.stringify(transformedFrontmatter || {})};`,
@@ -23,7 +24,7 @@ function reactRouterMarkdown(options = {}) {
23
24
  `export const handle = ${JSON.stringify(handleData)};`,
24
25
  "",
25
26
  `function Page() {
26
- return _jsx(MarkdownPage, {
27
+ return jsx(MarkdownPage, {
27
28
  Wrapper,
28
29
  parseHtml: ${parseHtml ? "true" : "false"},
29
30
  rawContent: rawContent,
package/dist/vite.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"vite.mjs","names":[],"sources":["../src/lib/vite-plugin.ts","../src/vite.ts"],"sourcesContent":["import matter from 'gray-matter'\nimport { type Plugin } from 'vite'\n\nexport type ReactRouterMarkdownOptions<D = Record<string, any>> = {\n /**\n * Module specifier to import a wrapper component from.\n * Must default-export a React component.\n *\n * Example: '#/components/markdown/wrapper'\n * @default undefined\n */\n wrapperModule?: string\n /**\n * If true, any HTML tags in the markdown content will be parsed as HTML instead of escaped.\n * @default false\n */\n parseHtml?: boolean\n /**\n * A function to return the handle data to be used for each page.\n * It accepts the post-processed content and frontmatter as arguments.\n * @default undefined\n */\n handleData?: (content: string, frontmatter: Record<string, any>) => Partial<D>\n\n /**\n * A function to transform the raw MD file content before it is parsed.\n * @default undefined\n */\n beforeTransform?: (content: string) => string\n\n /**\n * A function to transform the parsed MD content and/or frontmatter after they are parsed.\n * It should return back the transformed content and frontmatter.\n * @default undefined\n */\n afterTransform?: (\n content: string,\n frontmatter: Record<string, any>,\n ) => [string, Record<string, any>]\n}\n\nexport function reactRouterMarkdown<D = Record<string, any>>(\n options: ReactRouterMarkdownOptions<D> = {},\n): Plugin {\n const {\n wrapperModule,\n parseHtml = false,\n handleData: handleDataFn = () => ({}) as Partial<D>,\n beforeTransform = (content) => content,\n afterTransform = (content, frontmatter) => [content, frontmatter],\n }: ReactRouterMarkdownOptions<D> = options\n\n return {\n name: 'react-router-markdown',\n enforce: 'pre',\n\n transform(code, id) {\n const filePath = id.split('?', 1)[0] ?? id\n if (!filePath.endsWith('.md')) return null\n\n const transformedCode = beforeTransform(code)\n const { data, content } = matter(transformedCode)\n const [transformedContent, transformedFrontmatter] = afterTransform(content, data || {})\n const handleData = handleDataFn(transformedContent, transformedFrontmatter)\n\n return {\n code: [\n `import { MarkdownPage } from 'react-router-markdown';`,\n wrapperModule\n ? `import Wrapper from ${JSON.stringify(wrapperModule)};`\n : 'const Wrapper = null;',\n '',\n `export const frontmatter = ${JSON.stringify(transformedFrontmatter || {})};`,\n `export const rawContent = ${JSON.stringify(transformedContent || '')};`,\n '',\n 'export const meta = () => frontmatter.meta || [];',\n `export const handle = ${JSON.stringify(handleData)};`,\n '',\n `function Page() {\n return _jsx(MarkdownPage, {\n Wrapper,\n parseHtml: ${parseHtml ? 'true' : 'false'},\n rawContent: rawContent,\n frontmatter: frontmatter,\n })\n }\n export default Page;\n `,\n ].join('\\n'),\n map: null,\n }\n },\n }\n}\n","export { type ReactRouterMarkdownOptions } from './lib/vite-plugin'\n\nimport { reactRouterMarkdown } from './lib/vite-plugin'\n\nexport default reactRouterMarkdown\n"],"mappings":";;;AAyCA,SAAgB,oBACd,UAAyC,EAAE,EACnC;CACR,MAAM,EACJ,eACA,YAAY,OACZ,YAAY,sBAAsB,EAAE,GACpC,mBAAmB,YAAY,SAC/B,kBAAkB,SAAS,gBAAgB,CAAC,SAAS,YAAY,KAChC;AAEnC,QAAO;EACL,MAAM;EACN,SAAS;EAET,UAAU,MAAM,IAAI;AAElB,OAAI,EADa,GAAG,MAAM,KAAK,EAAE,CAAC,MAAM,IAC1B,SAAS,MAAM,CAAE,QAAO;GAGtC,MAAM,EAAE,MAAM,YAAY,OADF,gBAAgB,KAAK,CACI;GACjD,MAAM,CAAC,oBAAoB,0BAA0B,eAAe,SAAS,QAAQ,EAAE,CAAC;GACxF,MAAM,aAAa,aAAa,oBAAoB,uBAAuB;AAE3E,UAAO;IACL,MAAM;KACJ;KACA,gBACI,uBAAuB,KAAK,UAAU,cAAc,CAAC,KACrD;KACJ;KACA,8BAA8B,KAAK,UAAU,0BAA0B,EAAE,CAAC,CAAC;KAC3E,6BAA6B,KAAK,UAAU,sBAAsB,GAAG,CAAC;KACtE;KACA;KACA,yBAAyB,KAAK,UAAU,WAAW,CAAC;KACpD;KACA;;;2BAGiB,YAAY,SAAS,QAAQ;;;;;;;KAO/C,CAAC,KAAK,KAAK;IACZ,KAAK;IACN;;EAEJ;;;;ACxFH,IAAA,eAAe"}
1
+ {"version":3,"file":"vite.mjs","names":[],"sources":["../src/lib/vite-plugin.ts","../src/vite.ts"],"sourcesContent":["import matter from 'gray-matter'\nimport { type Plugin } from 'vite'\n\nexport type ReactRouterMarkdownOptions<D = Record<string, any>> = {\n /**\n * Module specifier to import a wrapper component from.\n * Must default-export a React component.\n *\n * Example: '#/components/markdown/wrapper'\n * @default undefined\n */\n wrapperModule?: string\n /**\n * If true, any HTML tags in the markdown content will be parsed as HTML instead of escaped.\n * @default false\n */\n parseHtml?: boolean\n /**\n * A function to return the handle data to be used for each page.\n * It accepts the post-processed content and frontmatter as arguments.\n * @default undefined\n */\n handleData?: (content: string, frontmatter: Record<string, any>) => Partial<D>\n\n /**\n * A function to transform the raw MD file content before it is parsed.\n * @default undefined\n */\n beforeTransform?: (content: string) => string\n\n /**\n * A function to transform the parsed MD content and/or frontmatter after they are parsed.\n * It should return back the transformed content and frontmatter.\n * @default undefined\n */\n afterTransform?: (\n content: string,\n frontmatter: Record<string, any>,\n ) => [string, Record<string, any>]\n}\n\nexport function reactRouterMarkdown<D = Record<string, any>>(\n options: ReactRouterMarkdownOptions<D> = {},\n): Plugin {\n const {\n wrapperModule,\n parseHtml = false,\n handleData: handleDataFn = () => ({}) as Partial<D>,\n beforeTransform = (content) => content,\n afterTransform = (content, frontmatter) => [content, frontmatter],\n }: ReactRouterMarkdownOptions<D> = options\n\n return {\n name: 'react-router-markdown',\n enforce: 'pre',\n\n transform(code, id) {\n const filePath = id.split('?', 1)[0] ?? id\n if (!filePath.endsWith('.md')) return null\n\n const transformedCode = beforeTransform(code)\n const { data, content } = matter(transformedCode)\n const [transformedContent, transformedFrontmatter] = afterTransform(content, data || {})\n const handleData = handleDataFn(transformedContent, transformedFrontmatter)\n\n return {\n code: [\n \"import { MarkdownPage } from 'react-router-markdown';\",\n \"import { jsx } from 'react/jsx-runtime';\",\n wrapperModule\n ? `import Wrapper from ${JSON.stringify(wrapperModule)};`\n : 'const Wrapper = null;',\n '',\n `export const frontmatter = ${JSON.stringify(transformedFrontmatter || {})};`,\n `export const rawContent = ${JSON.stringify(transformedContent || '')};`,\n '',\n 'export const meta = () => frontmatter.meta || [];',\n `export const handle = ${JSON.stringify(handleData)};`,\n '',\n `function Page() {\n return jsx(MarkdownPage, {\n Wrapper,\n parseHtml: ${parseHtml ? 'true' : 'false'},\n rawContent: rawContent,\n frontmatter: frontmatter,\n })\n }\n export default Page;\n `,\n ].join('\\n'),\n map: null,\n }\n },\n }\n}\n","export { type ReactRouterMarkdownOptions } from './lib/vite-plugin'\n\nimport { reactRouterMarkdown } from './lib/vite-plugin'\n\nexport default reactRouterMarkdown\n"],"mappings":";;;AAyCA,SAAgB,oBACd,UAAyC,EAAE,EACnC;CACR,MAAM,EACJ,eACA,YAAY,OACZ,YAAY,sBAAsB,EAAE,GACpC,mBAAmB,YAAY,SAC/B,kBAAkB,SAAS,gBAAgB,CAAC,SAAS,YAAY,KAChC;AAEnC,QAAO;EACL,MAAM;EACN,SAAS;EAET,UAAU,MAAM,IAAI;AAElB,OAAI,EADa,GAAG,MAAM,KAAK,EAAE,CAAC,MAAM,IAC1B,SAAS,MAAM,CAAE,QAAO;GAGtC,MAAM,EAAE,MAAM,YAAY,OADF,gBAAgB,KAAK,CACI;GACjD,MAAM,CAAC,oBAAoB,0BAA0B,eAAe,SAAS,QAAQ,EAAE,CAAC;GACxF,MAAM,aAAa,aAAa,oBAAoB,uBAAuB;AAE3E,UAAO;IACL,MAAM;KACJ;KACA;KACA,gBACI,uBAAuB,KAAK,UAAU,cAAc,CAAC,KACrD;KACJ;KACA,8BAA8B,KAAK,UAAU,0BAA0B,EAAE,CAAC,CAAC;KAC3E,6BAA6B,KAAK,UAAU,sBAAsB,GAAG,CAAC;KACtE;KACA;KACA,yBAAyB,KAAK,UAAU,WAAW,CAAC;KACpD;KACA;;;2BAGiB,YAAY,SAAS,QAAQ;;;;;;;KAO/C,CAAC,KAAK,KAAK;IACZ,KAAK;IACN;;EAEJ;;;;ACzFH,IAAA,eAAe"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-router-markdown",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "description": "Vite plugin to parse and use markdown files as React Router pages, including frontmatter support.",
5
5
  "keywords": [
6
6
  "markdown",
@@ -38,18 +38,6 @@
38
38
  },
39
39
  "./references": "./dist/references.d.ts"
40
40
  },
41
- "scripts": {
42
- "build": "tsdown",
43
- "dev": "tsdown --watch",
44
- "format": "oxfmt --write .",
45
- "format:check": "oxfmt --check .",
46
- "lint": "pnpm typecheck && pnpm publint",
47
- "publint": "publint",
48
- "test": "vitest --run",
49
- "test:coverage": "vitest --run --coverage",
50
- "test:watch": "vitest --watch",
51
- "typecheck": "tsc --noEmit"
52
- },
53
41
  "dependencies": {
54
42
  "gray-matter": "^4.0.3",
55
43
  "hast-util-raw": "^9.1.0",
@@ -71,5 +59,16 @@
71
59
  "react": "^19.2.4",
72
60
  "vite": "^7.0.0 || ^8.0.0"
73
61
  },
74
- "packageManager": "pnpm@10.33.0"
75
- }
62
+ "scripts": {
63
+ "build": "tsdown",
64
+ "dev": "tsdown --watch",
65
+ "format": "oxfmt --write .",
66
+ "format:check": "oxfmt --check .",
67
+ "lint": "pnpm typecheck && pnpm publint",
68
+ "publint": "publint",
69
+ "test": "vitest --run",
70
+ "test:coverage": "vitest --run --coverage",
71
+ "test:watch": "vitest --watch",
72
+ "typecheck": "tsc --noEmit"
73
+ }
74
+ }