eduproj2/stories/articles/Article.tsx

31 lines
737 B
TypeScript
Raw Normal View History

2023-08-02 02:20:15 +00:00
"use client";
import mkMarkdownIt from "markdown-it";
import styles from "./Article.module.scss";
import { markdownPreprocessor } from "../../lib/mdpp";
import ConvertNode from "./ConvertNode";
const markdownIt = mkMarkdownIt({
html: true,
linkify: true,
}).use(markdownPreprocessor);
export interface ArticleProps {
source: string;
}
export function Article({ source }: ArticleProps) {
const compiled = markdownIt.render(source);
// const parser = new window.DOMParser();
// const result = parser.parseFromString(compiled, "text/html");
return (
<div className={styles.article}>
{compiled}
{/* {[...result.body.childNodes].map((x) => (
<ConvertNode node={x} />
))} */}
</div>
);
}