From 060815395aa807e706b056106a2438aa69919423 Mon Sep 17 00:00:00 2001 From: Triston Armstrong Date: Mon, 25 Dec 2023 22:04:02 -0600 Subject: [PATCH] move construct graph function call to getStaticProps --- pages/notes/[id].js | 8 +++----- pages/notes/index.js | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/pages/notes/[id].js b/pages/notes/[id].js index 508392a..9966b50 100644 --- a/pages/notes/[id].js +++ b/pages/notes/[id].js @@ -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 ( @@ -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 }, }; } diff --git a/pages/notes/index.js b/pages/notes/index.js index ae65276..7958e85 100644 --- a/pages/notes/index.js +++ b/pages/notes/index.js @@ -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)