replaced tsx with jsx due to issue in @types/react for jsx-runtime
This commit is contained in:
parent
0ca7a97d26
commit
d709f6657a
|
@ -0,0 +1,37 @@
|
|||
import { unified } from 'unified';
|
||||
import remarkGfm from "remark-gfm";
|
||||
import remarkParse from "remark-parse";
|
||||
import remarkRehype from "remark-rehype";
|
||||
import rehypeSanitize from "rehype-sanitize";
|
||||
import rehypeHighlight from "rehype-highlight";
|
||||
import rehypeReact from "rehype-react";
|
||||
import * as prod from 'react/jsx-runtime';
|
||||
|
||||
import { readFile } from 'node:fs/promises';
|
||||
|
||||
async function markPostString() {
|
||||
let path = ""
|
||||
if ('DUMMY_HTML_DIR' in process.env && typeof process.env.DUMMY_HTML_DIR === "string") {
|
||||
path = process.env.DUMMY_HTML_DIR + "test1.md";
|
||||
}
|
||||
return await readFile(path, "utf-8")
|
||||
}
|
||||
|
||||
|
||||
export default async function Mark() {
|
||||
let content = await markPostString();
|
||||
let result = unified()
|
||||
.use(remarkParse)
|
||||
.use(remarkGfm)
|
||||
.use(remarkRehype)
|
||||
.use(rehypeSanitize)
|
||||
.use(rehypeHighlight)
|
||||
.use(rehypeReact, {
|
||||
Fragment: prod.Fragment,
|
||||
jsx: prod.jsx,
|
||||
jsxs: prod.jsxs,
|
||||
})
|
||||
.processSync(content)
|
||||
|
||||
return result.result;
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
import { MarkPostString } from '@/components/dummyPost';
|
||||
import remarkGfm from "remark-gfm";
|
||||
import rehypeSanitize from "rehype-sanitize";
|
||||
import rehypeHighlight from "rehype-highlight";
|
||||
import remarkRehype from "remark-rehype";
|
||||
import remarkParse from "remark-parse";
|
||||
import { unified } from 'unified';
|
||||
import rehypeReact from "rehype-react";
|
||||
import * as prod from 'react/jsx-runtime';
|
||||
|
||||
export default async function Mark() {
|
||||
let content = await MarkPostString();
|
||||
let result = unified()
|
||||
.use(remarkParse)
|
||||
.use(remarkGfm)
|
||||
.use(remarkRehype)
|
||||
.use(rehypeSanitize)
|
||||
.use(rehypeHighlight)
|
||||
.processSync(content)
|
||||
|
||||
}
|
Loading…
Reference in New Issue