Skip to content

Commit

Permalink
Fix 404 error again
Browse files Browse the repository at this point in the history
  • Loading branch information
balazshevesi committed Dec 28, 2023
1 parent 6730ea6 commit 5e500e6
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions src/app/MarkDown.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
let ReactMarkdown: any, RehypeRaw: any;

const importStuff = async () => {
const markdownModule = await import("react-markdown");
const rehypeRawModule = await import("rehype-raw");
ReactMarkdown = markdownModule.default;
RehypeRaw = rehypeRawModule.default;
};
async function loadImports() {
if (!ReactMarkdown) ReactMarkdown = (await import("react-markdown")).default;
if (!RehypeRaw) RehypeRaw = (await import("rehype-raw")).default;
}

importStuff();
loadImports();

async function MarkDown() {
if (!ReactMarkdown || !RehypeRaw) {
await importStuff();
}

const getReadMe = async () => {
try {
const response = await fetch(
Expand All @@ -29,11 +23,6 @@ async function MarkDown() {

const readMe = await getReadMe();

// Ensure that ReactMarkdown and RehypeRaw are available
if (!ReactMarkdown || !RehypeRaw) {
return <div>Loading...</div>; // Or any other loading state
}

return (
<div className="prose dark:prose-invert">
<ReactMarkdown rehypePlugins={[RehypeRaw]}>{readMe}</ReactMarkdown>
Expand Down

0 comments on commit 5e500e6

Please sign in to comment.