move construct graph function call to getStaticProps
This commit is contained in:
parent
fd45def1bf
commit
060815395a
@ -5,14 +5,14 @@ import {
|
||||
getSinglePost,
|
||||
convertObject,
|
||||
getDirectoryData,
|
||||
constructGraphData, getLocalGraphData
|
||||
constructGraphData
|
||||
} from "../../lib/utils";
|
||||
import FolderTree from "../../components/FolderTree";
|
||||
import { getFlattenArray } from "../../lib/utils";
|
||||
import MDContent from "../../components/MDContent";
|
||||
|
||||
|
||||
export default function Home({ note, backLinks, fileNames, tree, flattenNodes, graphData }) {
|
||||
export default function Home({ note, backLinks, fileNames, tree, flattenNodes }) {
|
||||
|
||||
return (
|
||||
<Layout>
|
||||
@ -40,9 +40,9 @@ export async function getStaticPaths() {
|
||||
};
|
||||
}
|
||||
|
||||
const { nodes, edges } = constructGraphData()
|
||||
|
||||
export function getStaticProps({ params }) {
|
||||
const { nodes, edges } = constructGraphData()
|
||||
const note = getSinglePost(params.id);
|
||||
const tree = convertObject(getDirectoryData());
|
||||
const flattenNodes = getFlattenArray(tree)
|
||||
@ -50,14 +50,12 @@ export function getStaticProps({ params }) {
|
||||
const listOfEdges = edges.filter(anEdge => anEdge.target === params.id)
|
||||
const internalLinks = listOfEdges.map(anEdge => nodes.find(aNode => aNode.slug === anEdge.source)).filter(element => element !== undefined)
|
||||
const backLinks = [...new Set(internalLinks)]
|
||||
const graphData = getLocalGraphData(params.id)
|
||||
return {
|
||||
props: {
|
||||
note,
|
||||
tree: tree,
|
||||
flattenNodes: flattenNodes,
|
||||
backLinks: backLinks.filter(link => link.slug !== params.id),
|
||||
graphData: graphData
|
||||
},
|
||||
};
|
||||
}
|
||||
|
@ -26,9 +26,9 @@ export default function Home({ content, tree, flattenNodes, backLinks }) {
|
||||
|
||||
}
|
||||
|
||||
const { nodes, edges } = constructGraphData()
|
||||
|
||||
export function getStaticProps() {
|
||||
const { nodes, edges } = constructGraphData()
|
||||
const tree = convertObject(getDirectoryData());
|
||||
const contentData = getSinglePost("index");
|
||||
const flattenNodes = getFlattenArray(tree)
|
||||
|
Loading…
Reference in New Issue
Block a user