XeNote/pages/index.js

68 lines
2.2 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 }) {
2020-12-01 20:30:06 +00:00
//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)
//console.log("route", router)
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-12-01 20:30:06 +00:00
const G = Network({
el:ref.current,
graphdata,
current:"index",
2020-12-06 19:40:20 +00:00
routeQuery,
routeHandler,
2020-12-01 20:30:06 +00:00
allNodes:false // If true then shows every markdown file as node
})
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>
2020-12-01 03:28:42 +00:00
<Head>
2021-03-03 21:49:23 +00:00
<meta name="google-site-verification" content="7iZ3AXo66Mm1qElIrjOAcUD6pqBeDQGC63zZfwiGhbE" />
2020-12-01 03:28:42 +00:00
{content.title && <meta name="title" content={content.title} />}
{content.canonical && <meta name="canonical_url" content={content.canonical} />}
{content.description && <meta name="description" content={content.description} />}
</Head>
2020-11-30 11:29:34 +00:00
<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() {
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: {
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
},
};
}