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"> <div className="backlink-container">
{linkList.map(aLink => {linkList.map(aLink =>
<div key={aLink.slug} className="backlink"> <div key={aLink.slug} className="backlink">
<Link href={aLink.slug}> {/*<Link href={aLink.slug}>*/}
<a> <a href={aLink.slug} >
<p className="backlink-title">{aLink.title}</p> <p className="backlink-title">{aLink.title}</p>
<p className="backlink-preview">{aLink.shortSummary} </p> <p className="backlink-preview">{aLink.shortSummary} </p>
</a> </a>
</Link> {/*</Link>*/}
</div> </div>
)} )}
</div> </div>

View File

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

View File

@ -106,7 +106,7 @@ export function constructGraphData() {
} }
nodes.push(aNode) nodes.push(aNode)
console.log("Constructing graph for node: " + aFilePath ) // console.log("Constructing graph for node: " + aFilePath )
const internalLinks = Transformer.getInternalLinks(aFilePath) const internalLinks = Transformer.getInternalLinks(aFilePath)
internalLinks.forEach(aLink => { internalLinks.forEach(aLink => {
@ -117,10 +117,10 @@ export function constructGraphData() {
target: aLink.slug, target: aLink.slug,
} }
edges.push(anEdge) edges.push(anEdge)
console.log("Source: " + anEdge.source) // console.log("Source: " + anEdge.source)
console.log("Target: " + anEdge.target) // 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)) 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)) 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 // Filter self-reference edges
localEdges = localEdges.filter(edge => edge.data.source !== edge.data.target) localEdges = localEdges.filter(edge => edge.data.source !== edge.data.target)
localEdges = localEdges.filter(edge => edge.data.target !== '/')
return { return {
nodes: localNodes, nodes: localNodes,
edges: localEdges edges: localEdges

View File

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