This commit is contained in:
Tuan Cao 2022-04-18 16:37:59 +07:00
parent 1089489672
commit 0efef3cebf
4 changed files with 28 additions and 10 deletions

View File

@ -14,12 +14,12 @@ function BackLinks({linkList}) {
<div className="backlink-container">
{linkList.map(aLink =>
<div key={aLink.slug} className="backlink">
<Link href={aLink.slug}>
<a>
{/*<Link href={aLink.slug}>*/}
<a href={aLink.slug} >
<p className="backlink-title">{aLink.title}</p>
<p className="backlink-preview">{aLink.shortSummary} </p>
</a>
</Link>
{/*</Link>*/}
</div>
)}
</div>

View File

@ -42,7 +42,7 @@ export const Transformer = {
// permalink = permalink.replace("ç", "c").replace("ı", "i").replace("ş", "s")
// console.log(`/note/${toSlug(result)}`)
if (result === undefined || result.length === 0) {
console.log("Cannot resolve file path " + pageName)
// console.log("Cannot resolve file path " + pageName)
}
// console.log("Internal Link resolved: [" + pageName + "] ==> [" + temp[0] +"]")

View File

@ -106,7 +106,7 @@ export function constructGraphData() {
}
nodes.push(aNode)
console.log("Constructing graph for node: " + aFilePath )
// console.log("Constructing graph for node: " + aFilePath )
const internalLinks = Transformer.getInternalLinks(aFilePath)
internalLinks.forEach(aLink => {
@ -117,10 +117,10 @@ export function constructGraphData() {
target: aLink.slug,
}
edges.push(anEdge)
console.log("Source: " + anEdge.source)
console.log("Target: " + anEdge.target)
// console.log("Source: " + anEdge.source)
// console.log("Target: " + anEdge.target)
})
console.log("==============Constructing graph" )
// console.log("==============Constructing graph" )
}
)
@ -170,8 +170,15 @@ export function getLocalGraphData(currentNodeId) {
const localNodes = newNodes.filter(aNode => localNodeIds.includes(aNode.data.id))
var localEdges = newEdges.filter(edge => localNodeIds.includes(edge.data.source)).filter(edge => localNodeIds.includes(edge.data.target))
localEdges.forEach(edge => {
if (edge.data.target === '/') {
console.log(edge.data.target)
}
})
// Filter self-reference edges
localEdges = localEdges.filter(edge => edge.data.source !== edge.data.target)
localEdges = localEdges.filter(edge => edge.data.target !== '/')
return {
nodes: localNodes,
edges: localEdges

View File

@ -10,7 +10,7 @@ import {
import FolderTree from "../../components/FolderTree";
import {getFlattenArray} from "../../lib/utils";
import MDContent from "../../components/MDContent";
// import
import dynamic from 'next/dynamic'
const DynamicGraph = dynamic(
@ -19,6 +19,17 @@ const DynamicGraph = dynamic(
)
export default function Home({note, backLinks, fileNames, tree, flattenNodes, graphData}) {
// const router = useRouter();
//
// useEffect(() => {
// if (isMenuOpen) {
// setMenuOpen(!isMenuOpen);
// }
// }, [router.asPath]);
//
return (
<Layout>
<Head>
@ -29,7 +40,7 @@ export default function Home({note, backLinks, fileNames, tree, flattenNodes, gr
<FolderTree tree={tree} flattenNodes={flattenNodes}/>
</nav>
<MDContent content={note.data} fileNames={fileNames} handleOpenNewContent={null} backLinks={backLinks}/>
<DynamicGraph graph={graphData}/>
<DynamicGraph graph={graphData || null }/>
</div>
</Layout>