-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- had to comment out usage of rehype-lint and unified-lint-rule since those weren't migrated yet
- Loading branch information
1 parent
d215d27
commit 1b01fdd
Showing
14 changed files
with
6,066 additions
and
778 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import { ElementSubstitution } from 'lib/pages/posts/[slug]/client' | ||
import s from './Code.module.scss' | ||
import c from 'classnames' | ||
|
||
export const Code: React.FC<React.HTMLAttributes<HTMLElement>> = props => { | ||
export const Code: ElementSubstitution<'code'> = props => { | ||
return <code {...props} className={c(s.code, props.className)} /> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,24 @@ | ||
import { createElement, Fragment } from 'react' | ||
import rehypeReact from 'rehype-react' | ||
import { ComponentsWithoutNodeOptions } from 'rehype-react/lib/complex-types' | ||
import { unified } from 'unified' | ||
import rehypeReact, { | ||
Options as ReactRehypeOptions, | ||
Components | ||
} from 'rehype-react' | ||
import { HastTree } from 'lib/content/posts/types' | ||
import * as prod from 'react/jsx-runtime' | ||
import { unified } from 'unified' | ||
|
||
// @ts-expect-error: the react types are missing. | ||
// https://github.com/rehypejs/rehype-react/tree/93fac074e8e3447088ed2408282e9e089ea7b36c#use | ||
const production = { Fragment: prod.Fragment, jsx: prod.jsx, jsxs: prod.jsxs } | ||
|
||
export type Options = ReactRehypeOptions | ||
|
||
export type ElementSubstitution<Element extends keyof Components> = | ||
Components[Element] | ||
|
||
export const convertToReact = ( | ||
content: HastTree, | ||
components: ComponentsWithoutNodeOptions['components'] | ||
components: ReactRehypeOptions['components'] | ||
): React.ReactNode => | ||
unified() | ||
.use(rehypeReact, { createElement, Fragment, components }) | ||
.use(rehypeReact, { ...production, components }) | ||
.stringify(content) |
Oops, something went wrong.