2020-11-28 15:45:01 +00:00
|
|
|
import Head from "next/head";
|
2022-03-31 08:12:00 +00:00
|
|
|
import Layout from "../../components/layout";
|
2022-04-05 04:47:41 +00:00
|
|
|
import {
|
|
|
|
getPostListData,
|
|
|
|
getSinglePost,
|
|
|
|
getGraphData,
|
|
|
|
convertObject,
|
|
|
|
getDirectoryData,
|
|
|
|
getAllFileNames
|
|
|
|
} from "../../lib/utils";
|
2022-03-24 07:43:18 +00:00
|
|
|
import FolderTree from "../../components/FolderTree";
|
|
|
|
import {getFlattenArray} from "../../lib/utils";
|
2022-03-31 09:59:10 +00:00
|
|
|
import MDContainer from "../../components/MDContainer";
|
2022-04-05 04:47:41 +00:00
|
|
|
import {Transformer} from "../../lib/transformer";
|
2020-11-30 11:29:34 +00:00
|
|
|
|
2022-04-05 04:47:41 +00:00
|
|
|
export default function Home({ note, fileNames,tree, flattenNodes}) {
|
2020-11-28 15:45:01 +00:00
|
|
|
return (
|
2022-03-31 08:46:10 +00:00
|
|
|
<Layout>
|
2020-11-30 11:29:34 +00:00
|
|
|
<Head>
|
|
|
|
{note.title && <meta name="title" content={note.title} />}
|
|
|
|
</Head>
|
2022-03-24 07:43:18 +00:00
|
|
|
<div className = 'container'>
|
|
|
|
<nav className="nav-bar">
|
|
|
|
<FolderTree tree={tree} flattenNodes={flattenNodes}/>
|
|
|
|
</nav>
|
2022-04-05 04:47:41 +00:00
|
|
|
<MDContainer post={note.data} fileNames = {fileNames}/>
|
2022-03-24 07:43:18 +00:00
|
|
|
</div>
|
2020-11-28 15:45:01 +00:00
|
|
|
</Layout>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
export async function getStaticPaths() {
|
2022-03-31 08:12:00 +00:00
|
|
|
const allPostsData = getPostListData();
|
2020-12-01 03:28:42 +00:00
|
|
|
const paths = allPostsData.map(p => ({params: {id:p}}))
|
2020-11-28 15:45:01 +00:00
|
|
|
return {
|
|
|
|
paths,
|
|
|
|
fallback:false
|
|
|
|
};
|
|
|
|
}
|
|
|
|
export async function getStaticProps({ params }) {
|
2022-03-31 08:12:00 +00:00
|
|
|
const note = getSinglePost(params.id);
|
2022-03-24 07:43:18 +00:00
|
|
|
const tree = convertObject(getDirectoryData());
|
|
|
|
const flattenNodes = getFlattenArray(tree)
|
2022-04-05 04:47:41 +00:00
|
|
|
const fileNames = getAllFileNames()
|
2020-11-28 15:45:01 +00:00
|
|
|
return {
|
|
|
|
props: {
|
|
|
|
note,
|
2022-03-24 07:43:18 +00:00
|
|
|
tree: tree,
|
2022-04-05 04:47:41 +00:00
|
|
|
flattenNodes: flattenNodes,
|
|
|
|
fileNames: fileNames
|
2020-11-28 15:45:01 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|