Almost MVP
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { useEffect, useRef } from 'preact/hooks'
|
||||
import { useContext, useEffect, useRef } from 'preact/hooks'
|
||||
|
||||
import { unified } from 'unified'
|
||||
import remarkParse from 'remark-parse'
|
||||
@@ -6,6 +6,7 @@ import remarkMath from 'remark-math'
|
||||
import remarkRehype from 'remark-rehype'
|
||||
import rehypeKatex from 'rehype-katex'
|
||||
import rehypeStringify from 'rehype-stringify'
|
||||
import { ServerContext } from '../hooks'
|
||||
|
||||
async function renderMarkdownAsync(source: string) {
|
||||
return await unified()
|
||||
@@ -17,9 +18,7 @@ async function renderMarkdownAsync(source: string) {
|
||||
.process(source)
|
||||
}
|
||||
|
||||
// function renderMarkdownSync(source) {
|
||||
// console.warn(`[Markdown] Rendering ${source.length} characters of markdown in sync mode`)
|
||||
|
||||
// function renderMarkdownSync(source: string): string {
|
||||
// return unified()
|
||||
// .use(remarkParse)
|
||||
// .use(remarkMath)
|
||||
@@ -27,9 +26,24 @@ async function renderMarkdownAsync(source: string) {
|
||||
// .use(rehypeKatex, { throwOnError: false, errorColor: '#c60' })
|
||||
// .use(rehypeStringify)
|
||||
// .processSync(source)
|
||||
// .toString()
|
||||
// }
|
||||
|
||||
export const Markdown = ({ source }: { source: string }) => {
|
||||
// Magia nera per renderizzare il markdown lato server
|
||||
//
|
||||
// const isServer = useContext(ServerContext)
|
||||
// if (isServer) {
|
||||
// return (
|
||||
// <div
|
||||
// class="markdown"
|
||||
// dangerouslySetInnerHTML={{
|
||||
// __html: renderMarkdownSync(source),
|
||||
// }}
|
||||
// ></div>
|
||||
// )
|
||||
// }
|
||||
|
||||
const elementRef = useRef<HTMLDivElement>(null)
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user