import React, {useEffect, useState} from 'react'; import './Home.css'; import ReactMarkdown from 'react-markdown' import {AllBlogs} from "../static/data/Blogs"; import {Prism as SyntaxHighlighter} from 'react-syntax-highlighter' import {a11yDark as theme} from "react-syntax-highlighter/dist/esm/styles/prism"; import {Link} from "react-router-dom"; import Blog from "../types/Blog"; function SingleBlog() { const [blog, setBlog] = useState(undefined); const [blogText, setBlogText] = useState(''); useEffect(()=> { let blogName = window.location.pathname.split('/').at(-1); setBlog(AllBlogs.find(b => b.uri == blogName)); }, []) useEffect(()=> { if(blog === undefined) return; fetch(blog.mdfile) .then(response => { return response.text() }) .then(text => { setBlogText(text) }) }, [blog]); return ( blog === undefined ?
:

{blog.title}

{blog.date.toLocaleDateString()}

Back

) : ( {children} ) } }} > {blogText}
) : ( {children} ) } }} > {blogText}
); } export default SingleBlog;