36dcfbb2bc
Boiler plate code for adding multiple MD Content
44 lines
1.3 KiB
JavaScript
44 lines
1.3 KiB
JavaScript
import Head from "next/head";
|
|
import Layout from "../../components/layout";
|
|
import {getPostListData, getSinglePost, getGraphData, convertObject, getDirectoryData} from "../../lib/utils";
|
|
import FolderTree from "../../components/FolderTree";
|
|
import {getFlattenArray} from "../../lib/utils";
|
|
import MDContainer from "../../components/MDContainer";
|
|
|
|
export default function Home({ note, graphdata,tree, flattenNodes}) {
|
|
return (
|
|
<Layout>
|
|
<Head>
|
|
{note.title && <meta name="title" content={note.title} />}
|
|
</Head>
|
|
<div className = 'container'>
|
|
<nav className="nav-bar">
|
|
<FolderTree tree={tree} flattenNodes={flattenNodes}/>
|
|
</nav>
|
|
<MDContainer post={note.data}/>
|
|
</div>
|
|
</Layout>
|
|
);
|
|
}
|
|
export async function getStaticPaths() {
|
|
const allPostsData = getPostListData();
|
|
const paths = allPostsData.map(p => ({params: {id:p}}))
|
|
return {
|
|
paths,
|
|
fallback:false
|
|
};
|
|
}
|
|
export async function getStaticProps({ params }) {
|
|
const note = getSinglePost(params.id);
|
|
const tree = convertObject(getDirectoryData());
|
|
const flattenNodes = getFlattenArray(tree)
|
|
|
|
return {
|
|
props: {
|
|
note,
|
|
tree: tree,
|
|
flattenNodes: flattenNodes
|
|
},
|
|
};
|
|
}
|