Skip to content

Commit 5a9e347

Browse files
authored
feat: export Markdown component for reusing (#90)
1 parent d3b5b44 commit 5a9e347

File tree

8 files changed

+424
-370
lines changed

8 files changed

+424
-370
lines changed

.changeset/proud-boats-wink.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@alauda/doom": minor
3+
---
4+
5+
feat: export `Markdown` component for reusing

package.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,17 @@
5858
},
5959
"dependencies": {
6060
"@cspell/eslint-plugin": "^8.19.4 || ^9.0.2",
61-
"@eslint-react/eslint-plugin": "^1.51.3",
61+
"@eslint-react/eslint-plugin": "^1.52.1",
6262
"@inquirer/prompts": "^7.5.3",
6363
"@openapi-contrib/openapi-schema-to-json-schema": "^5.1.0",
6464
"@playwright/browser-chromium": "^1.53.0",
6565
"@rsbuild/plugin-react": "^1.3.2",
6666
"@rsbuild/plugin-sass": "^1.3.2",
6767
"@rsbuild/plugin-svgr": "^1.2.0",
6868
"@rsbuild/plugin-yaml": "^1.0.2",
69-
"@rspress/core": "2.0.0-beta.13",
70-
"@rspress/plugin-algolia": "2.0.0-beta.13",
71-
"@rspress/plugin-llms": "2.0.0-beta.13",
69+
"@rspress/core": "2.0.0-beta.14",
70+
"@rspress/plugin-algolia": "2.0.0-beta.14",
71+
"@rspress/plugin-llms": "2.0.0-beta.14",
7272
"@shikijs/transformers": "^3.6.0",
7373
"@total-typescript/ts-reset": "^0.6.1",
7474
"chokidar": "^4.0.3",
@@ -91,6 +91,8 @@
9191
"picomatch": "^4.0.2",
9292
"playwright": "^1.53.0",
9393
"react-markdown": "^10.1.0",
94+
"rehype-raw": "^7.0.0",
95+
"rehype-sanitize": "^6.0.0",
9496
"remark-directive": "^4.0.0",
9597
"remark-frontmatter": "^5.0.0",
9698
"remark-gfm": "^4.0.1",
@@ -117,13 +119,13 @@
117119
"@types/ejs": "^3.1.5",
118120
"@types/node": "^22.15.31",
119121
"@types/picomatch": "^4.0.0",
120-
"@types/react": "^19.1.7",
122+
"@types/react": "^19.1.8",
121123
"@types/react-dom": "^19.1.6",
122124
"@types/swagger2openapi": "^7.0.4",
123125
"@unts/patch-package": "^8.1.1",
124126
"clean-pkg-json": "^1.3.0",
125127
"eslint-import-resolver-typescript": "^4.4.3",
126-
"eslint-plugin-import-x": "^4.15.1",
128+
"eslint-plugin-import-x": "^4.15.2",
127129
"eslint-plugin-react-hooks": "^5.2.0",
128130
"nano-staged": "^0.8.0",
129131
"npm-run-all2": "^8.0.4",

src/runtime/components/K8sCrd.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { useCallback, useEffect, useMemo, useState } from 'react'
1010
import { useIsPrint, useTranslation } from '../hooks/index.js'
1111

1212
import { Directive } from './Directive.js'
13-
import { Markdown } from './_Markdown.js'
13+
import { Markdown } from './Markdown.js'
1414
import { X } from './_X.js'
1515

1616
export interface K8sCrdProps {
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
import { type ElementType } from 'react'
22
import ReactMarkdown from 'react-markdown'
3+
import rehypeRaw from 'rehype-raw'
4+
import rehypeSanitize from 'rehype-sanitize'
35
import remarkGfm from 'remark-gfm'
46

57
import { X } from './_X.js'
68

9+
const remarkPlugins = [remarkGfm]
10+
const rehypePlugins = [rehypeRaw, rehypeSanitize]
11+
712
export const Markdown = ({ children }: { children?: string }) =>
813
children && (
914
<ReactMarkdown
10-
remarkPlugins={[[remarkGfm]]}
15+
remarkPlugins={remarkPlugins}
16+
rehypePlugins={rehypePlugins}
1117
components={X as Record<string, ElementType>}
12-
skipHtml={true}
1318
>
1419
{children}
1520
</ReactMarkdown>

src/runtime/components/OpenAPIPath.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import { Fragment, useId, useMemo, type ReactNode } from 'react'
88

99
import { omitRoutePathRefs, resolveRef } from '../utils.js'
1010

11+
import { Markdown } from './Markdown.js'
1112
import { OpenAPIProperties, OpenAPIProperty, OpenAPIRef } from './OpenAPIRef.js'
1213
import { HeadingTitle } from './_HeadingTitle.js'
13-
import { Markdown } from './_Markdown.js'
1414
import { RefLink } from './_RefLink.js'
1515
import { X } from './_X.js'
1616

src/runtime/components/OpenAPIRef.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import { type ReactNode, useId, useMemo } from 'react'
55

66
import { modelName, omitRoutePathRefs, resolveRef } from '../utils.js'
77

8+
import { Markdown } from './Markdown.js'
89
import { HeadingTitle } from './_HeadingTitle.js'
9-
import { Markdown } from './_Markdown.js'
1010
import { RefLink } from './_RefLink.js'
1111
import { X } from './_X.js'
1212

src/runtime/components/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export * from './JsonViewer.js'
1010
export * from './K8sCrd.js'
1111
export * from './K8sPermissionTable.js'
1212
export * from './LinkCard.js'
13+
export * from './Markdown.js'
1314
export * from './Mermaid.js'
1415
export * from './OpenAPIPath.js'
1516
export * from './OpenAPIRef.js'

0 commit comments

Comments
 (0)