XeNote/pages/index.js
2022-03-31 15:12:00 +07:00

40 lines
1.4 KiB
JavaScript

import Layout from "../components/layout";
import {getSinglePost, getDirectoryData, convertObject, getFlattenArray} from "../lib/utils";
import FolderTree from "../components/FolderTree";
import Alert from '@mui/material/Alert';
import AlertTitle from '@mui/material/AlertTitle';
export default function Home({content, tree, flattenNodes}) {
return (
<Layout home>
<div className = 'container'>
<nav className="nav-bar">
<FolderTree tree={tree} flattenNodes={flattenNodes}/>
</nav>
<main className="markdown-rendered">
<Alert severity="info">
<AlertTitle>Want to know more?</AlertTitle>
🌱 <strong>Follow</strong> or <strong>DM</strong> me on Twitter at <span><a href="https://twitter.com/tuancm">@tuancm</a></span>
</Alert>
<div dangerouslySetInnerHTML={{__html: content.data}}/>
</main>
</div>
</Layout>
);
}
export function getStaticProps() {
const tree = convertObject(getDirectoryData());
const contentData = getSinglePost("index");
const flattenNodes = getFlattenArray(tree)
return {
props: {
content: contentData,
tree: tree,
flattenNodes: flattenNodes
},
};
}