2020-11-28 15:45:01 +00:00
|
|
|
import Head from "next/head";
|
2022-03-17 08:42:57 +00:00
|
|
|
import {useRouter} from 'next/router'
|
|
|
|
import {useEffect, useRef} from "react";
|
|
|
|
import Layout, {siteTitle} from "../components/layout";
|
|
|
|
import {getSinglePost, getGraphData} from "../lib/post";
|
|
|
|
import {Network} from "../components/graph";
|
2020-11-28 15:45:01 +00:00
|
|
|
|
2020-11-30 11:29:34 +00:00
|
|
|
|
2022-03-17 08:42:57 +00:00
|
|
|
export default function Home({content, graphdata, filenames, ...props}) {
|
|
|
|
//console.log("Index Page Props: ", content /* backlinks, filenames*/)
|
2020-11-28 15:45:01 +00:00
|
|
|
const ref = useRef(null);
|
2020-11-30 11:29:34 +00:00
|
|
|
const router = useRouter()
|
2020-12-06 19:40:20 +00:00
|
|
|
const routeQuery = router.query.id
|
|
|
|
const routeHandler = (r) => router.push(r)
|
2020-11-28 15:45:01 +00:00
|
|
|
useEffect(() => {
|
2022-03-17 08:42:57 +00:00
|
|
|
if (ref && ref.current) {
|
2020-11-28 15:45:01 +00:00
|
|
|
|
2020-12-01 20:30:06 +00:00
|
|
|
const G = Network({
|
2022-03-17 08:42:57 +00:00
|
|
|
el: ref.current,
|
2020-12-01 20:30:06 +00:00
|
|
|
graphdata,
|
2022-03-17 08:42:57 +00:00
|
|
|
current: "index",
|
2020-12-06 19:40:20 +00:00
|
|
|
routeQuery,
|
|
|
|
routeHandler,
|
2022-03-17 08:42:57 +00:00
|
|
|
allNodes: false // If true then shows every markdown file as node
|
2020-12-01 20:30:06 +00:00
|
|
|
})
|
2020-11-30 11:29:34 +00:00
|
|
|
}
|
|
|
|
}, [])
|
2020-12-01 03:28:42 +00:00
|
|
|
|
|
|
|
|
2020-11-28 15:45:01 +00:00
|
|
|
return (
|
|
|
|
<Layout home>
|
2022-03-17 08:42:57 +00:00
|
|
|
<Head>
|
|
|
|
<link rel="preconnect" href="https://fonts.googleapis.com"/>
|
|
|
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossOrigin/>
|
|
|
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;800;900&display=swap"
|
|
|
|
rel="stylesheet"/>
|
|
|
|
</Head>
|
2020-11-30 11:29:34 +00:00
|
|
|
<section>
|
2022-03-17 08:42:57 +00:00
|
|
|
<div dangerouslySetInnerHTML={{__html: content.data}}/>
|
2020-11-28 15:45:01 +00:00
|
|
|
</section>
|
|
|
|
</Layout>
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getStaticProps() {
|
2020-12-01 03:28:42 +00:00
|
|
|
const contentData = getSinglePost("index");
|
2020-11-30 11:29:34 +00:00
|
|
|
const graphdata = getGraphData();
|
2020-11-28 15:45:01 +00:00
|
|
|
return {
|
|
|
|
props: {
|
2022-03-17 08:42:57 +00:00
|
|
|
content: contentData,
|
|
|
|
graphdata: graphdata,
|
2020-11-28 15:45:01 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|