eduproj2/stories/articles/Article.tsx
Michael Zhang ebcce28d5b wtf
2023-08-01 22:20:15 -04:00

30 lines
737 B
TypeScript

"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>
);
}