Put Side bar to both Index and post pages

Make nav bar appear on the left side.
This commit is contained in:
Tuan Cao 2022-03-24 14:43:18 +07:00
parent bae2cc6be7
commit c56bacc34b
5 changed files with 40 additions and 19 deletions

View File

@ -29,7 +29,7 @@ export default function FolderTree(props) {
router.push(currentNode.routePath)
}
}}
sx={{ height: 110, flexGrow: 1, maxWidth: 400, overflowY: 'auto' }}
sx={{ flexGrow: 1, maxWidth: 400, overflowY: 'auto' }}
>
{renderTree(props.tree)}
</TreeView>

View File

@ -1,12 +1,14 @@
import Head from 'next/head'
// import BasicTree from 'lib/MyFolderTree'
export const siteTitle = 'Digital Backroom - An Internet Archive'
import {Box} from '@mui/material'
export default function Layout({children, home}) {
return (
<div>
<main className="markdown-rendered theme-light">{children}</main>
<main className= "theme-light">
{children}
</main>
</div>
)
}

View File

@ -1,15 +1,20 @@
import Layout, {siteTitle} from "../components/layout";
import {getSinglePost, getGraphData, getDirectoryData, convertObject, getFlattenArray} from "../lib/utils";
import FolderTree from "../components/FolderTree";
import {Box} from '@mui/material'
export default function Home({content, graphdata, filenames, tree,flattenNodes, ...props}) {
export default function Home({content, graphdata, filenames, tree, flattenNodes, ...props}) {
return (
<Layout home>
<section>
<FolderTree tree={tree} flattenNodes = {flattenNodes}/>
<div dangerouslySetInnerHTML={{__html: content.data}}/>
</section>
<div className = 'container'>
<nav className="nav-bar">
<FolderTree tree={tree} flattenNodes={flattenNodes}/>
</nav>
<main className="markdown-rendered">
<div dangerouslySetInnerHTML={{__html: content.data}}/>
</main>
</div>
</Layout>
);

View File

@ -3,11 +3,12 @@ import Link from 'next/link'
import { useRouter } from 'next/router'
import { useEffect,useRef } from "react";
import Layout, { siteTitle } from "../../components/layout";
import { getPostListData, getSinglePost, getGraphData} from "../../lib/utils";
import {getPostListData, getSinglePost, getGraphData, convertObject, getDirectoryData} from "../../lib/utils";
import { Network } from "../../components/graph";
import FolderTree from "../../components/FolderTree";
import {getFlattenArray} from "../../lib/utils";
export default function Home({ note, graphdata, ...props }) {
export default function Home({ note, graphdata,tree, flattenNodes, ...props }) {
var jsnx = require('jsnetworkx');
//console.log("Note Page: ")
@ -57,14 +58,17 @@ export default function Home({ note, graphdata, ...props }) {
<Head>
{note.title && <meta name="title" content={note.title} />}
</Head>
<section
>
<div className = 'container'>
<nav className="nav-bar">
<FolderTree tree={tree} flattenNodes={flattenNodes}/>
</nav>
<div
className="article-body"
className="markdown-rendered"
dangerouslySetInnerHTML={{__html:note.data}}>
</div>
</section>
<hr/>
</div>
</Layout>
);
@ -84,12 +88,15 @@ export async function getStaticProps({ params }) {
//console.log("params2", note)
const graphdata = getGraphData();
//console.log("params3", params)
const tree = convertObject(getDirectoryData());
const flattenNodes = getFlattenArray(tree)
//console.log("note: ", params)
return {
props: {
note,
graphdata:graphdata,
tree: tree,
flattenNodes: flattenNodes
},
};
}

View File

@ -6,6 +6,10 @@ a:hover {
color: var(--text-accent-hover);
}
.container {
display: flex;
justify-content: center;
}
.markdown-rendered {
font-size: 18px;
@ -14,10 +18,13 @@ a:hover {
background-color: var(--background-primary);
color: var(--text-normal);
font-family:var(--default-font);
margin: auto;
padding: 20px;
}
.nav-bar {
width: 400px;
padding: 20px;
}
:root {
--default-font: 'Inter', sans-serif;
}