Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support HTML content!!! but bundle size up by 60kb #132

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
241 changes: 237 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"react-quiz-component": "^0.5.1",
"react-router": "^6.8.0",
"react-router-dom": "^6.8.0",
"rehype-raw": "^6.0.0",
"remark": "^14.0.3",
"remark-gfm": "^3.0.1",
"remark-strip-html": "^1.0.2",
Expand Down
12 changes: 9 additions & 3 deletions src/components/Chapter.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import React from 'react'
import { withTranslation } from 'react-i18next'
import ReactMarkdown from 'react-markdown'
// FIXME: rehypeRaw, used for parsing HTML, adds ~60kb to the bundle size.
// consider if really necessary
import rehypeRaw from 'rehype-raw'
import remarkGfm from 'remark-gfm'
import { LinkComponent } from '../utils/MarkdownComponents'
import type { IconT } from './Section'
Expand Down Expand Up @@ -56,9 +59,12 @@ function Chapter(props: ChapterProps) {
</div>
<div className='chapter-main'>
<Target targets={data.responsible} />
<ReactMarkdown remarkPlugins={[remarkGfm]}
components={LinkComponent}>{data.content}</ReactMarkdown>

<ReactMarkdown
remarkPlugins={[remarkGfm]}
rehypePlugins={[rehypeRaw]} // FIXME: adds 60kb to the bundle, remove?
components={LinkComponent}
children={data.content}
/>
</div>
</div>
</div>
Expand Down
Loading