diff --git a/app/mark/page.jsx b/app/mark/page.jsx new file mode 100644 index 0000000..716d9f9 --- /dev/null +++ b/app/mark/page.jsx @@ -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; +} \ No newline at end of file diff --git a/app/mark/page.tsx b/app/mark/page.tsx deleted file mode 100644 index 24cff28..0000000 --- a/app/mark/page.tsx +++ /dev/null @@ -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) - -} \ No newline at end of file