XeNote/pages/index.js

52 lines
1.5 KiB
JavaScript
Raw Normal View History

2020-11-28 15:45:01 +00:00
import Head from "next/head";
2020-11-30 11:29:34 +00:00
import { useRouter } from 'next/router'
2020-11-28 15:45:01 +00:00
import { useEffect,useRef } from "react";
import Link from 'next/link'
import Layout, { siteTitle } from "../components/layout";
2020-11-30 11:29:34 +00:00
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
export default function Home({ content, graphdata, filenames, ...props }) {
//console.log("Index Page Props: ", props /* 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-11-28 15:45:01 +00:00
//var G = jsnx.binomialGraph(filenames.length, 1)
//var G = jsnx.completeGraph(filenames.length);
useEffect(() => {
2020-11-30 11:29:34 +00:00
if (ref && ref.current){
2020-11-28 15:45:01 +00:00
2020-11-30 11:29:34 +00:00
const G = Network({el:ref.current, graphdata, current:"index", router, allNodes:true})
}
}, [])
2020-11-28 15:45:01 +00:00
return (
<Layout home>
2020-11-30 11:29:34 +00:00
<Head></Head>
<img src="https://cbsofyalioglu.fra1.digitaloceanspaces.com/cbs/digital-garden.jpg" />
<section>
<div dangerouslySetInnerHTML={{__html: content.data}} />
2020-11-28 15:45:01 +00:00
</section>
2020-11-30 11:29:34 +00:00
<hr/>
<div id="graph-box" ref={ref}>
</div>
2020-11-28 15:45:01 +00:00
</Layout>
);
}
export function getStaticProps() {
const contentData = getSinglePost("index.md");
2020-11-30 11:29:34 +00:00
const graphdata = getGraphData();
2020-11-28 15:45:01 +00:00
return {
props: {
content:contentData,
2020-11-30 11:29:34 +00:00
graphdata:graphdata,
2020-11-28 16:36:28 +00:00
//filenames:JSON.parse(filenamesRaw)
2020-11-28 15:45:01 +00:00
//sidebar:sidebarData
},
};
}