我试图在Next.js 13中构建的博客上使用react-markdown和rehypeRaw来实现markdown,以允许其中包含HTML。我在此文件中使用“use client”。然而,我的文本仅在使用markdown时显示(#,##等)和标题级别被忽略,它总是相同的小尺寸。只是为了澄清,使用strong这样的明星造型。当我尝试使用rehypeRaw时:
<ReactMarkdown
// @ts-expect-error
rehypePlugins={[rehypeRaw]}
>
<h1> yessss</h1>
</ReactMarkdown>
字符串
html树中没有显示任何内容,我在行中收到此错误:
Type 'Element' is not assignable to type 'string'.
型
我只想在我的markdown内容中使用HTML和tailwindCSS。或者因为这只是我被允许发布的内容,我应该使用错误的SetInnerHTML吗?我知道至少在我测试的时候,这个解决方案可以与Tailwind一起工作。即使我是唯一一个拥有此网站授权访问权限的人,这也会是一个漏洞吗?// @ts expect error
是许多GitHub问题描述的rehypePlugins抛出此错误的解决方案:
Type '(options?: Options | null | undefined) => (tree: Root, file: VFile) => Root' is not assignable to type 'Pluggable<any[]>'.
Type '(options?: Options | null | undefined) => (tree: Root, file: VFile) => Root' is not assignable to type 'Plugin<any[], any, any>'.
Type '(tree: Root, file: VFile) => Root' is not assignable to type 'void | Transformer<any, any>'.
Type '(tree: Root, file: VFile) => Root' is not assignable to type 'Transformer<any, any>'.
型
我还遵循了这里接受的答案,以便能够正确地呈现常规的markdown:react-markdown don´t render Markdown
1条答案
按热度按时间6mzjoqzu1#
我在这里回答了一个熟悉的问题https://stackoverflow.com/a/77762348/7262646
字符串