From 758a8c90b4613243f5936a3d716eba544c1f2af7 Mon Sep 17 00:00:00 2001 From: Tuan Cao Date: Mon, 18 Apr 2022 12:02:05 +0700 Subject: [PATCH] - Add title back to Backlink - Remove duplicated backlink and self-reference. --- lib/utils.js | 1 + pages/note/[id].js | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/utils.js b/lib/utils.js index c7ff7ea..b521d7d 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -100,6 +100,7 @@ export function constructGraphData() { .forEach(aFilePath => { // const {currentFilePath} = getFileNames(filename) const aNode = { + title: Transformer.parseFileNameFromPath(aFilePath), slug: toSlug(aFilePath), shortSummary: getShortSummary(toSlug(aFilePath)) } diff --git a/pages/note/[id].js b/pages/note/[id].js index 38500f5..c575f58 100644 --- a/pages/note/[id].js +++ b/pages/note/[id].js @@ -55,14 +55,14 @@ 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: internalLinks, + backLinks: backLinks.filter(link => link.slug !== params.id), graphData: graphData }, };