This commit is contained in:
h z
2024-12-03 09:41:58 +00:00
parent 8bbfc10a39
commit b355b867a5
8 changed files with 233 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
//src/components/MarkdownContent.js
import React, { useEffect, useState } from "react";
import { useParams } from "react-router-dom";
import {fetchWithCache} from "../utils/fetchWIthCache";
const MarkdownContent = () => {
const { id } = useParams();
const [content, setContent] = useState(null);
const [error, setError] = useState(null);
useEffect(() => {
fetchWithCache(`/api/markdown/${id}`)
.then((data) => setContent(data))
.catch((error) => setError(error));
}, [id]);
if (error) {
return <div>Error: {error}</div>;
}
if (!content) {
return <div>Loading...</div>;
}
return (
<div className="markdown-content">
<pre>{content}</pre>
</div>
);
};
export default MarkdownContent;