-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add storybook examples for useRemarkSync
- Loading branch information
1 parent
64f450f
commit d55c5e2
Showing
2 changed files
with
72 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { useEffect } from 'react'; | ||
import remarkGfm from 'remark-gfm'; | ||
import remarkMath from 'remark-math'; | ||
import rehypeKatex from 'rehype-katex'; | ||
import rehypeRaw from 'rehype-raw'; | ||
import rehypeSanitize from 'rehype-sanitize'; | ||
import 'katex/dist/katex.min.css'; | ||
|
||
import { useRemarkSync } from '../src'; | ||
|
||
export default { | ||
title: 'Remark Hooks/sync and ssr with useRemarkSync', | ||
component: useRemarkSync, | ||
}; | ||
|
||
export const CommonMark = ({ content }) => { | ||
return useRemarkSync(content); | ||
}; | ||
CommonMark.args = { | ||
content: `# header | ||
1. ordered | ||
2. list | ||
* unordered | ||
* list`, | ||
}; | ||
|
||
export const GithubFlavoredMarkdown = ({ content }) => { | ||
return ( | ||
useRemarkSync(content, { | ||
remarkPlugins: [remarkGfm], | ||
}) || <></> | ||
); | ||
}; | ||
GithubFlavoredMarkdown.args = { | ||
content: `# header | ||
| column 1 | column 2 | | ||
| -------- | -------- | | ||
| first | row | | ||
`, | ||
}; | ||
|
||
export const MarkdownWithMath = ({ content }) => { | ||
return useRemarkSync(content, { | ||
remarkPlugins: [remarkMath], | ||
rehypePlugins: [rehypeKatex], | ||
}); | ||
}; | ||
MarkdownWithMath.args = { | ||
content: `Lift($L$) can be determined by Lift Coefficient ($C_L$) like the following equation. | ||
$$ | ||
L = \\frac{1}{2} \\rho v^2 S C_L | ||
$$`, | ||
}; | ||
|
||
export const MixedHTMLSanitized = ({ content }) => { | ||
return useRemarkSync(content, { | ||
remarkToRehypeOptions: { allowDangerousHtml: true }, | ||
rehypePlugins: [rehypeRaw, rehypeSanitize], | ||
}); | ||
}; | ||
MixedHTMLSanitized.args = { | ||
content: `# header | ||
<strong>mixed</strong> | ||
<em>with</em> | ||
<kbd>html</kbd>`, | ||
}; |
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