managed to convert back to typescript by updating @types/react and @types/react-dom using specific version

This commit is contained in:
2024-05-10 11:43:51 +10:00
parent 15b7b30b08
commit d7a9fb6a8c
4 changed files with 40 additions and 56 deletions

View File

@@ -1,37 +0,0 @@
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;
}

27
app/mark/page.tsx Normal file
View File

@@ -0,0 +1,27 @@
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, { Options as RehypeReactOptions } from 'rehype-react';
import { Fragment, jsx, jsxs } from 'react/jsx-runtime';
import { MarkPostString } from '@/components/dummyPost';
export default async function Mark() {
let content = await MarkPostString();
let result = await unified()
.use(remarkParse)
.use(remarkGfm)
.use(remarkRehype)
.use(rehypeHighlight)
.use(rehypeSanitize)
.use(rehypeReact, {
Fragment: Fragment,
jsx: jsx,
jsxs: jsxs
} as RehypeReactOptions)
.process(content);
return result.result;
}