mirror of https://github.com/BRAVO68WEB/shx.git
moved markdown converter to the mardown component
This commit is contained in:
parent
4567df6fdb
commit
16c648bddd
|
@ -1,8 +1,6 @@
|
|||
import Markdown from '@/components/Markdown';
|
||||
import axios from 'axios';
|
||||
import React from 'react';
|
||||
import showdown from 'showdown';
|
||||
const converter = new showdown.Converter();
|
||||
|
||||
const Dashboard = async () => {
|
||||
const { data } = await axios.get(
|
||||
|
@ -10,7 +8,7 @@ const Dashboard = async () => {
|
|||
);
|
||||
return (
|
||||
<>
|
||||
<Markdown markdown={converter.makeHtml(data)} />
|
||||
<Markdown markdown={data} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
'use client';
|
||||
|
||||
import React, { useEffect, useRef } from 'react';
|
||||
import "github-markdown-css"
|
||||
import showdown from 'showdown';
|
||||
import 'github-markdown-css';
|
||||
|
||||
const converter = new showdown.Converter();
|
||||
|
||||
interface MarkdownProps {
|
||||
markdown: string;
|
||||
|
@ -11,7 +13,7 @@ interface MarkdownProps {
|
|||
function Markdown({ markdown }: MarkdownProps) {
|
||||
const ref = useRef<HTMLDivElement>(null);
|
||||
useEffect(() => {
|
||||
if (ref.current?.innerHTML) ref.current.innerHTML = markdown;
|
||||
if (ref.current?.innerHTML) ref.current.innerHTML = converter.makeHtml(markdown);
|
||||
}, [markdown]);
|
||||
return (
|
||||
<div className="markdown-body w-full p-10" ref={ref}>
|
||||
|
|
Loading…
Reference in New Issue