import React from "react"
import marked from "marked"
import { Helmet } from "react-helmet-async"
import pages from "../pages.json"
import NotFound from "./NotFound"
export default class Page extends React.Component {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
fetched: any
constructor(props) {
super(props)
const fetched = pages[location.pathname.replace(/\/$/, "")] // remove a trailing slash
if (!fetched) return
fetched.content = fetched?.content ? fetched.content : "No content"
fetched.toc = fetched.meta?.toc ? fetched.meta.toc : undefined
fetched.title = fetched.meta?.title ? fetched.meta.title : "No title"
fetched.date = fetched.meta?.date ? fetched.meta.date : "Unknown date"
fetched.author = fetched.meta?.author
? fetched.meta.author
: "Unknown author"
this.fetched = fetched
}
render() {
if (!this.fetched) return